3D engine that AI agents drive
Write the squared horizon share as one pow call to keep agent-scene within the goal gate (part of #50)
Nguyen Xuan And8fc7cbf9769
diff --git a/src/shaders.js b/src/shaders.jsindex b240fc1c..a01ce4cb 100644--- a/src/shaders.js+++ b/src/shaders.js@@ -646,11 +646,8 @@ ${featureCode("linkArea")} vec3 lightNormal = areaLightNormals[index].xyz;if (USES_OCCLUSION_MAP) occlusion = mix(1.0, texture(occlusionMap, mapUV(hasOcclusionMap)).r, occlusionStrength);// Trees and terrain bake how much sky each vertex sees; everything else carries 1.occlusion *= splatCavity * vertexSkyVisibility;- if (USES_NORMAL_MAP) {- // Squared: Cycles also drops the sky lobe below the surface, so a tilt reads darker than the linear share.- float horizon = 0.5 + 0.5 * dot(normal, geometricNormal);- occlusion *= horizon * horizon;- }+ // Squared: Cycles also drops the sky lobe below the surface, so a tilt reads darker than the linear share.+ if (USES_NORMAL_MAP) occlusion *= pow(0.5 + 0.5 * dot(normal, geometricNormal), 2.0);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));diff --git a/tests/shader-features.test.js b/tests/shader-features.test.jsindex e2610a84..9016bb7c 100644--- a/tests/shader-features.test.js+++ b/tests/shader-features.test.js@@ -12,7 +12,7 @@ test('the default fragment shader keeps every feature', () => {test('a mapped normal takes the sky light below the surface plane out of the ambient term', () => {assert.match(fragmentShader, /vec3 geometricNormal = normal;\s+if \(USES_NORMAL_MAP\) normal = /);- assert.match(fragmentShader, /float horizon = 0\.5 \+ 0\.5 \* dot\(normal, geometricNormal\);\s+occlusion \*= horizon \* horizon;/);+ assert.match(fragmentShader, /if \(USES_NORMAL_MAP\) occlusion \*= pow\(0\.5 \+ 0\.5 \* dot\(normal, geometricNormal\), 2\.0\);/);});test('a feature that a scene does not use becomes a constant false', () => {