Skip to content

Commit

Permalink
Merge pull request #6 from ux3d/fix/ambient_occlusion_order
Browse files Browse the repository at this point in the history
Apply Ambient Occlusion only to IBL (diffuse part)
  • Loading branch information
UX3D-becher authored Nov 5, 2020
2 parents 87a2574 + f6beb38 commit de6f6b4
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/shaders/pbr.frag
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,13 @@ void main()
#endif
#endif

float ao = 1.0;
// Apply optional PBR terms for additional (optional) shading
#ifdef HAS_OCCLUSION_MAP
ao = texture(u_OcclusionSampler, getOcclusionUV()).r;
f_diffuse = mix(f_diffuse, f_diffuse * ao, u_OcclusionStrength);
#endif

#ifdef USE_PUNCTUAL
for (int i = 0; i < LIGHT_COUNT; ++i)
{
Expand Down Expand Up @@ -645,13 +652,6 @@ void main()

color = (f_emissive + diffuse + f_specular + f_subsurface + (1.0 - reflectance) * f_sheen) * (1.0 - clearcoatFactor * clearcoatFresnel) + f_clearcoat * clearcoatFactor;

float ao = 1.0;
// Apply optional PBR terms for additional (optional) shading
#ifdef HAS_OCCLUSION_MAP
ao = texture(u_OcclusionSampler, getOcclusionUV()).r;
color = mix(color, color * ao, u_OcclusionStrength);
#endif

#ifndef DEBUG_OUTPUT // no debug

#ifdef ALPHAMODE_MASK
Expand Down

0 comments on commit de6f6b4

Please sign in to comment.