瀏覽代碼

Added workaround for ANGLE bug in godrays example.

It seems ANGLE fix may not make it through to stable Chrome for a while:

http://code.google.com/p/chromium/issues/detail?id=153105

Should revisit this when stable Chrome 23 comes out.
alteredq 12 年之前
父節點
當前提交
774fa4ae04
共有 1 個文件被更改,包括 25 次插入0 次删除
  1. 25 0
      examples/js/ShaderGodRays.js

+ 25 - 0
examples/js/ShaderGodRays.js

@@ -102,6 +102,10 @@ THREE.ShaderGodRays = {
 				"vec2 uv = vUv.xy;",
 				"vec2 uv = vUv.xy;",
 				"float col = 0.0;",
 				"float col = 0.0;",
 
 
+				// This breaks ANGLE in Chrome 22
+				//	- see http://code.google.com/p/chromium/issues/detail?id=153105
+
+				/*
 				// Unrolling didnt do much on my hardware (ATI Mobility Radeon 3450),
 				// Unrolling didnt do much on my hardware (ATI Mobility Radeon 3450),
 				// so i've just left the loop
 				// so i've just left the loop
 
 
@@ -119,6 +123,27 @@ THREE.ShaderGodRays = {
 					"uv += stepv;",
 					"uv += stepv;",
 
 
 				"}",
 				"}",
+				*/
+
+				// Unrolling loop manually makes it work in ANGLE
+
+				"if ( 0.0 <= iters && uv.y < 1.0 ) col += texture2D( tInput, uv ).r;",
+				"uv += stepv;",
+
+				"if ( 1.0 <= iters && uv.y < 1.0 ) col += texture2D( tInput, uv ).r;",
+				"uv += stepv;",
+
+				"if ( 2.0 <= iters && uv.y < 1.0 ) col += texture2D( tInput, uv ).r;",
+				"uv += stepv;",
+
+				"if ( 3.0 <= iters && uv.y < 1.0 ) col += texture2D( tInput, uv ).r;",
+				"uv += stepv;",
+
+				"if ( 4.0 <= iters && uv.y < 1.0 ) col += texture2D( tInput, uv ).r;",
+				"uv += stepv;",
+
+				"if ( 5.0 <= iters && uv.y < 1.0 ) col += texture2D( tInput, uv ).r;",
+				"uv += stepv;",
 
 
 				// Should technically be dividing by 'iters', but 'TAPS_PER_PASS' smooths out
 				// Should technically be dividing by 'iters', but 'TAPS_PER_PASS' smooths out
 				// objectionable artifacts, in particular near the sun position. The side
 				// objectionable artifacts, in particular near the sun position. The side