|
4 | 4 | #define LOG2 1.442695 |
5 | 5 | #define EPSILON 1e-6 |
6 | 6 |
|
| 7 | +#define square(a) a * a |
| 8 | +#define saturate(a) clamp( a, 0.0, 1.0 ) |
| 9 | +#define whiteCompliment(a) 1.0 - saturate( a ) |
| 10 | + |
7 | 11 | vec3 transformDirection( in vec3 normal, in mat4 matrix ) { |
8 | 12 |
|
9 | 13 | return normalize( ( matrix * vec4( normal, 0.0 ) ).xyz ); |
@@ -41,7 +45,7 @@ float calcLightAttenuation( float lightDistance, float cutoffDistance, float dec |
41 | 45 |
|
42 | 46 | if ( decayExponent > 0.0 ) { |
43 | 47 |
|
44 | | - return pow( clamp( -lightDistance / cutoffDistance + 1.0, 0.0, 1.0 ), decayExponent ); |
| 48 | + return pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent ); |
45 | 49 |
|
46 | 50 | } |
47 | 51 |
|
@@ -75,10 +79,10 @@ vec3 BRDF_BlinnPhong( in vec3 specularColor, in float shininess, in vec3 normal, |
75 | 79 |
|
76 | 80 | vec3 halfDir = normalize( lightDir + viewDir ); |
77 | 81 |
|
78 | | - //float dotNL = clamp( dot( normal, lightDir ), 0.0, 1.0 ); |
79 | | - //float dotNV = clamp( dot( normal, viewDir ), 0.0, 1.0 ); |
80 | | - float dotNH = clamp( dot( normal, halfDir ), 0.0, 1.0 ); |
81 | | - float dotLH = clamp( dot( lightDir, halfDir ), 0.0, 1.0 ); |
| 82 | + //float dotNL = saturate( dot( normal, lightDir ) ); |
| 83 | + //float dotNV = saturate( dot( normal, viewDir ) ); |
| 84 | + float dotNH = saturate( dot( normal, halfDir ) ); |
| 85 | + float dotLH = saturate( dot( lightDir, halfDir ) ); |
82 | 86 |
|
83 | 87 | vec3 F = F_Schlick( specularColor, dotLH ); |
84 | 88 |
|
|
0 commit comments