1uniform half4 N, I, NRef; 2uniform half4 colorGreen, colorRed; 3 4half4 main(float2 xy) { 5 // These cannot be evaluated at compile-time since the intermediate values would overflow. 6 float huge = faceforward( 1, 1e30, 1e30); 7 float2 huge2 = faceforward(float2(1), float2(1e30), float2(1e30)); 8 float3 huge3 = faceforward(float3(1), float3(1e30), float3(1e30)); 9 float4 huge4 = faceforward(float4(1), float4(1e30), float4(1e30)); 10 11 // We don't care about the results; they're used here to prevent them from being optimized away. 12 half4 expectedPos = half4(huge.xxxx + huge2.xxxx); 13 half4 expectedNeg = half4(huge3.xxxx + huge4.xxxx); 14 15 const half4 constN = half4(1, 2, 3, 4); 16 const half4 constI = half4(1, 1, -100, 1); 17 const half4 constNRef = half4(1); 18 19 expectedPos = half4(1, 2, 3, 4); 20 expectedNeg = -half4(1, 2, 3, 4); 21 22 return (faceforward(N.x, I.x, NRef.x ) == expectedNeg.x && 23 faceforward(N.xy, I.xy, NRef.xy ) == expectedNeg.xy && 24 faceforward(N.xyz, I.xyz, NRef.xyz ) == expectedPos.xyz && 25 faceforward(N.xyzw, I.xyzw, NRef.xyzw ) == expectedPos.xyzw && 26 faceforward(constN.x, constI.x, constNRef.x ) == expectedNeg.x && 27 faceforward(constN.xy, constI.xy, constNRef.xy ) == expectedNeg.xy && 28 faceforward(constN.xyz, constI.xyz, constNRef.xyz ) == expectedPos.xyz && 29 faceforward(constN.xyzw, constI.xyzw, constNRef.xyzw) == expectedPos.xyzw) ? colorGreen 30 : colorRed; 31} 32