Skip to content

Commit f0d9801

Browse files
committed
Merge pull request mrdoob#8346 from bhouston/minor_brdf_cleanup
minor brdf clean up - adopt pow2(x) and sqrt(x) were appropriate
2 parents e6bfff3 + 50a7ec1 commit f0d9801

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/renderers/shaders/ShaderChunk/bsdfs.glsl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ float G_GGX_Smith( const in float alpha, const in float dotNL, const in float do
5757

5858
// geometry term = G(l)⋅G(v) / 4(n⋅l)(n⋅v)
5959

60-
float a2 = alpha * alpha;
60+
float a2 = pow2( alpha );
6161

62-
float gl = dotNL + pow( a2 + ( 1.0 - a2 ) * pow2( dotNL ), 0.5 );
62+
float gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
6363

64-
float gv = dotNV + pow( a2 + ( 1.0 - a2 ) * pow2( dotNV ), 0.5 );
64+
float gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
6565

6666
return 1.0 / ( gl * gv );
6767

@@ -85,7 +85,7 @@ float D_GGX( const in float alpha, const in float dotNH ) {
8585
// GGX Distribution, Schlick Fresnel, GGX-Smith Visibility
8686
vec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {
8787

88-
float alpha = roughness * roughness; // UE4's roughness
88+
float alpha = pow2( roughness ); // UE4's roughness
8989

9090
vec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );
9191

0 commit comments

Comments
 (0)