Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions build/three.cjs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions build/three.module.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/three.module.min.js

Large diffs are not rendered by default.

Binary file modified examples/screenshots/webgl_animation_keyframes.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/screenshots/webgl_loader_gltf_iridescence.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ export default /* glsl */`
// reads channel R, compatible with a combined OcclusionRoughnessMetallic (RGB) texture
float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;

reflectedLight.indirectDiffuse *= ambientOcclusion;
// Multi-bounce AO accounts for inter-reflections based on surface albedo
reflectedLight.indirectDiffuse *= gtaoMultiBounce( ambientOcclusion, material.diffuseColor );

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

#if defined( USE_SHEEN )
#if defined( USE_SHEEN )
sheenSpecularIndirect *= ambientOcclusion;
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -546,10 +546,31 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia
#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
#define RE_IndirectSpecular RE_IndirectSpecular_Physical

// Multi-bounce approximation for ambient occlusion.
// Accumulates light from multiple surface bounces based on albedo.
// ref: https://www.activision.com/cdn/research/Practical_Real_Time_Strategies_for_Accurate_Indirect_Occlusion_NEW%20VERSION_COLOR.pdf
vec3 gtaoMultiBounce( const in float ao, const in vec3 albedo ) {

vec3 a = 2.0404 * albedo - 0.3324;
vec3 b = -4.7951 * albedo + 0.6417;
vec3 c = 2.7552 * albedo + 0.6903;

return max( vec3( ao ), ( ( ao * a + b ) * ao + c ) * ao );

}

// Improved specular occlusion with better roughness handling.
// ref: https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {

return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
float a = roughness * roughness;
float specularOcclusion = saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * a - 1.0 ) ) - 1.0 + ambientOcclusion );

// Reduce occlusion for very rough surfaces
float roughnessFactor = a * a;
specularOcclusion = mix( specularOcclusion, ambientOcclusion, roughnessFactor );

return specularOcclusion;

}
`;