소스 검색

Update SkyShader.js to fix random dark sky due to float precision (#9888)

* Previously if you put sun at vec3(0.0, 1.0, 0.0) and move it along the Y axis, the sky will suddenly become super dark at some random position. Further investigation shows the value passed into function sunIntensity is slightly larger than 1.0 due to float precision issue. Add a clamp will help get rid of such problems.
Hao Zhang 8 년 전
부모
커밋
bc48aed587
1개의 변경된 파일1개의 추가작업 그리고 0개의 파일을 삭제
  1. 1 0
      examples/js/SkyShader.js

+ 1 - 0
examples/js/SkyShader.js

@@ -66,6 +66,7 @@ THREE.ShaderLib[ 'sky' ] = {
 
 		"float sunIntensity(float zenithAngleCos)",
 		"{",
+		    	"zenithAngleCos = clamp(zenithAngleCos, -1.0, 1.0);",
 			"return EE * max(0.0, 1.0 - pow(e, -((cutoffAngle - acos(zenithAngleCos))/steepness)));",
 		"}",