Skip to content

armgit / 67.js

Public Imported from GitHub
0

3D engine that AI agents drive

Merge origin/main into feat/shadow-depth

Nguyen Xuan An0919cddc3848
diff --cc src/shaders.js
index 796cb2db,2ba1ad7d..cea78f22
--- a/src/shaders.js
+++ b/src/shaders.js
@@@ -867,11 -870,8 +870,12 @@@ ${featureCode("linkArea")} vec3 li
vec3 reflectance = fresnel(max(dot(normal, viewDirection), 0.0), baseReflectance);
float occlusion = 1.0;
if (USES_OCCLUSION_MAP) occlusion = mix(1.0, texture(occlusionMap, mapUV(hasOcclusionMap)).r, occlusionStrength);
- occlusion *= splatCavity;
+ // Trees and terrain bake how much sky each vertex sees; everything else carries 1.
+ occlusion *= splatCavity * vertexSkyVisibility;
+ if (ENVIRONMENT_ENABLED) {
+ float room = 1.0 - smoothstep(0.01, 0.06, dot(environmentDiffuse(vec3(0, 1, 0)), vec3(1)) / max(dot(keyColor, vec3(1)), 0.003));
+ occlusion *= mix(1.0, mix(0.25, 1.0, visibility), room * (1.0 - metallic));
+ }
// Leaf and grass cards keep a faint sheen; full sky reflection washed grazing cards grey-blue.
float skyReflection = canopyShaded ? 0.3 : 1.0;
if (ENVIRONMENT_ENABLED) {