Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@ export default /* glsl */`

float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );

reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
float specularOcclusion = computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should use the clearcoat roughness instead, so I think you need to call the function twice.


reflectedLight.indirectSpecular *= specularOcclusion;

#if defined( USE_CLEARCOAT )
clearcoatSpecularIndirect *= specularOcclusion;
#endif


#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ struct PhysicalMaterial {
};

// temporary
vec3 clearcoatSpecular = vec3( 0.0 );
vec3 clearcoatSpecularDirect = vec3( 0.0 );
vec3 clearcoatSpecularIndirect = vec3( 0.0 );
vec3 sheenSpecular = vec3( 0.0 );

vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
Expand Down Expand Up @@ -485,7 +486,7 @@ void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geome

vec3 ccIrradiance = dotNLcc * directLight.color;

clearcoatSpecular += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );

#endif

Expand All @@ -510,7 +511,7 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia

#ifdef USE_CLEARCOAT

clearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );

#endif

Expand Down
2 changes: 1 addition & 1 deletion src/renderers/shaders/ShaderLib/meshphysical.glsl.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ void main() {

vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );

outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat;
outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;

#endif

Expand Down