`While compiling fragment program renderprogs/AmbientOcclusion_AO.pixel
1: // filename renderprogs/AmbientOcclusion_AO.pixel
2: #version 300 es
3: #define PC
4: precision mediump float;
5: precision lowp sampler2D;
6: precision lowp sampler2DShadow;
7: precision lowp sampler2DArray;
8: precision lowp sampler2DArrayShadow;
9: precision lowp samplerCube;
10: precision lowp samplerCubeShadow;
11: precision lowp sampler3D;
12:
13: void clip( float v ) { if ( v < 0.0 ) { discard; } }
14: void clip( vec2 v ) { if ( any( lessThan( v, vec2( 0.0 ) ) ) ) { discard; } }
15: void clip( vec3 v ) { if ( any( lessThan( v, vec3( 0.0 ) ) ) ) { discard; } }
16: void clip( vec4 v ) { if ( any( lessThan( v, vec4( 0.0 ) ) ) ) { discard; } }
17:
18: float saturate( float v ) { return clamp( v, 0.0, 1.0 ); }
19: vec2 saturate( vec2 v ) { return clamp( v, 0.0, 1.0 ); }
20: vec3 saturate( vec3 v ) { return clamp( v, 0.0, 1.0 ); }
21: vec4 saturate( vec4 v ) { return clamp( v, 0.0, 1.0 ); }
22:
23: vec4 tex2D( sampler2D sampler, vec2 texcoord ) { return texture( sampler, texcoord.xy ); }
24: vec4 tex2D( sampler2DShadow sampler, vec3 texcoord ) { return vec4( texture( sampler, texcoord.xyz ) ); }
25:
26: vec4 tex2D( sampler2D sampler, vec2 texcoord, vec2 dx, vec2 dy ) { return textureGrad( sampler, texcoord.xy, dx, dy ); }
27: vec4 tex2D( sampler2DShadow sampler, vec3 texcoord, vec2 dx, vec2 dy ) { return vec4( textureGrad( sampler, texcoord.xyz, dx, dy ) ); }
28:
29: vec4 texCUBE( samplerCube sampler, vec3 texcoord ) { return texture( sampler, texcoord.xyz ); }
30: vec4 texCUBE( samplerCubeShadow sampler, vec4 texcoord ) { return vec4( texture( sampler, texcoord.xyzw ) ); }
31:
32: vec4 tex2Dproj( sampler2D sampler, vec3 texcoord ) { return textureProj( sampler, texcoord ); }
33: vec4 tex3Dproj( sampler3D sampler, vec4 texcoord ) { return textureProj( sampler, texcoord ); }
34:
35: vec4 tex2Dbias( sampler2D sampler, vec4 texcoord ) { return texture( sampler, texcoord.xy, texcoord.w ); }
36: vec4 tex3Dbias( sampler3D sampler, vec4 texcoord ) { return texture( sampler, texcoord.xyz, texcoord.w ); }
37: vec4 texCUBEbias( samplerCube sampler, vec4 texcoord ) { return texture( sampler, texcoord.xyz, texcoord.w ); }
38:
39: vec4 tex2Dlod( sampler2D sampler, vec4 texcoord ) { return textureLod( sampler, texcoord.xy, texcoord.w ); }
40: vec4 tex3Dlod( sampler3D sampler, vec4 texcoord ) { return textureLod( sampler, texcoord.xyz, texcoord.w ); }
41: vec4 texCUBElod( samplerCube sampler, vec4 texcoord ) { return textureLod( sampler, texcoord.xyz, texcoord.w ); }
42:
43:
44: uniform vec4 fa[5];
45:
46: float dot4 (vec4 a , vec4 b ) {return dot ( a , b ) ; }
47: float dot4 (vec2 a , vec4 b ) {return dot ( vec4 ( a , 0 , 1 ) , b ) ; }
48: const float DOOM_TO_METERS = 0.0254;
49: const float METERS_TO_DOOM = ( 1.0 / DOOM_TO_METERS );
50: const float radius = 1.0 * METERS_TO_DOOM;
51: const float radius2 = radius * radius;
52: const float invRadius2 = 1.0 / radius2;
53: const float bias = 0.01 * METERS_TO_DOOM;
54: const float intensity = 0.6;
55: const float projScale = 500.0;
56: uniform sampler2D samp0;
57: uniform sampler2D samp1;
58:
59: in vec2 vofi_TexCoord0;
60:
61: out vec4 fo_FragColor;
62:
63: vec3 reconstructCSPosition (vec2 S , float z ) {
64: vec4 P ;
65: P. z = z * 2.0 - 1.0 ;
66: P. xy = ( S * fa[0 /* rpScreenCorrectionFactor /] . xy ) * 2.0 - 1.0 ;
67: P. w = 1.0 ;
68: vec4 csP ;
69: csP. x = dot4 ( P , fa[1 / rpModelMatrixX /] ) ;
70: csP. y = dot4 ( P , fa[2 / rpModelMatrixY /] ) ;
71: csP. z = dot4 ( P , fa[3 / rpModelMatrixZ /] ) ;
72: csP. w = dot4 ( P , fa[4 / rpModelMatrixW */] ) ;
73: csP. xyz /= csP. w ;
74: return csP. xyz ;
75: }
76: vec3 sampleNormal (sampler2D normalBuffer , ivec2 ssC , int mipLevel ) {
77: return texelFetch ( normalBuffer , ssC , mipLevel ). xyz * 2.0 - 1.0 ;
78: }
79: vec2 tapLocation (int sampleNumber , float spinAngle , out float ssR ) {
80: float alpha = float ( sampleNumber + 0.5 ) * ( 1.0 / 11 ) ;
81: float angle = alpha * ( 7 * 6.28 ) + spinAngle ;
82: ssR = alpha ;
83: return vec2 ( cos ( angle ) , sin ( angle ) ) ;
84: }
85: vec3 getPosition (ivec2 ssP , sampler2D cszBuffer ) {
86: vec3 P ;
87: P. z = texelFetch ( cszBuffer , ssP , 0 ). r ;
88: P = reconstructCSPosition ( vec2 ( ssP ) + vec2 ( 0.5 ) , P. z ) ;
89: return P ;
90: }
91: void computeMipInfo (float ssR , ivec2 ssP , sampler2D cszBuffer , out int mipLevel , out ivec2 mipP ) {
92: mipLevel = clamp ( int ( floor ( log2 ( ssR ) ) ) - ( 3 ) , 0 , ( 5 ) ) ;
93: mipP = clamp ( ssP >> mipLevel , ivec2 ( 0 ) , textureSize ( cszBuffer , mipLevel ) - ivec2 ( 1 ) ) ;
94: }
95: vec3 getOffsetPosition (ivec2 issC , vec2 unitOffset , float ssR , sampler2D cszBuffer , float invCszBufferScale ) {
96: ivec2 ssP = ivec2 ( ssR * unitOffset ) + issC ;
97: vec3 P ;
98: int mipLevel ;
99: ivec2 mipP ;
100: computeMipInfo ( ssR , ssP , cszBuffer , mipLevel , mipP ) ;
101: P. z = texelFetch ( cszBuffer , mipP , mipLevel ). r ;
102: P = reconstructCSPosition ( vec2 ( ssP ) + vec2 ( 0.5 ) , P. z ) ;
103: return P ;
104: }
105: float fallOffFunction (float vv , float vn , float epsilon ) {
106: float f = max ( 1.0 - vv * invRadius2 , 0.0 ) ;
107: return f * max ( ( vn - bias ) * inversesqrt ( epsilon + vv ) , 0.0 ) ;
108: }
109: float aoValueFromPositionsAndNormal (vec3 C , vec3 n_C , vec3 Q ) {
110: vec3 v = Q - C ;
111: float vv = dot ( v , v ) ;
112: float vn = dot ( v , n_C ) ;
113: const float epsilon = 0.001 ;
114: return fallOffFunction ( vv , vn , epsilon ) * mix ( 1.0 , max ( 0.0 , 1.5 * n_C. z ) , 0.35 ) ;
115: }
116: float sampleAO (ivec2 issC , in vec3 C , in vec3 n_C , in float ssDiskRadius , in int tapIndex , in float randomPatternRotationAngle , in sampler2D cszBuffer , in float invCszBufferScale ) {
117: float ssR ;
118: vec2 unitOffset = tapLocation ( tapIndex , randomPatternRotationAngle , ssR ) ;
119: ssR = max ( 0.75 , ssR * ssDiskRadius ) ;
120: vec3 Q = getOffsetPosition ( issC , unitOffset , ssR , cszBuffer , invCszBufferScale ) ;
121: return aoValueFromPositionsAndNormal ( C , n_C , Q ) ;
122: }
123: const float MIN_RADIUS = 3.0;
124: void main() {
125: fo_FragColor = vec4 ( 1.0 , 0.0 , 0.0 , 1.0 ) ;
126: ivec2 ssP = ivec2 ( gl_FragCoord. xy ) ;
127: vec3 C = getPosition ( ssP , samp1 ) ;
128: fo_FragColor . r = 0.0 ;
129: vec3 n_C = sampleNormal ( samp0 , ssP , 0 ) ;
130: if ( length ( n_C ) < 0.01 )
131: {
132: fo_FragColor . r = 1.0 ;
133: return ;
134: }
135: n_C = normalize ( n_C ) ;
136: float randomPatternRotationAngle = ( ( ( 3 * ssP. x ) ^ ( ssP. y + ssP. x * ssP. y ) )
137: ) * 10 ;
138: float ssDiskRadius = - projScale * radius / C. z ;
139: if ( ssDiskRadius <= MIN_RADIUS )
140: {
141: fo_FragColor . r = 1.0 ;
142: return ;
143: }
144: float sum = 0.0 ;
145: for ( int i = 0 ; i < 11 ; ++ i )
146: {
147: sum += sampleAO ( ssP , C , n_C , ssDiskRadius , i , randomPatternRotationAngle , samp1 , 1 ) ;
148: }
149: float A = pow ( max ( 0.0 , 1.0 - sqrt ( sum * ( 3.0 / 11 ) ) ) , intensity ) ;
150: fo_FragColor . r = mix ( 1.0 , A , saturate ( ssDiskRadius - MIN_RADIUS ) ) ;
151: }
0:80(24): error: could not implicitly convert operands to arithmetic operator
0:80(16): error: cannot construct float' from a non-numeric data type 0:80(49): error: could not implicitly convert operands to arithmetic operator 0:80(16): error: operands to arithmetic operators must be numeric 0:81(16): warning:
alpha' used uninitialized
0:81(26): error: could not implicitly convert operands to arithmetic operator
0:81(16): error: operands to arithmetic operators must be numeric
0:81(16): error: operands to arithmetic operators must be numeric
0:82(8): warning: alpha' used uninitialized 0:83(22): warning:
angle' used uninitialized
0:83(38): warning: angle' used uninitialized 0:100(43): warning:
mipLevel' used uninitialized
0:100(54): warning: mipP' used uninitialized 0:118(74): warning:
ssR' used uninitialized
0:136(2): error: initializer of type int cannot be assigned to variable of type float
0:147(9): error: no matching function for call to sampleAO(ivec2, vec3, vec3, float, int, int, sampler2D, int)'; candidates are: 0:147(9): error: float sampleAO(ivec2, vec3, vec3, float, int, float, sampler2D, float) 0:147(2): error: operands to arithmetic operators must be numeric 0:149(51): error: could not implicitly convert operands to arithmetic operator 0:149(43): error: operands to arithmetic operators must be numeric 0:149(36): error: no matching function for call to
sqrt(error)'; candidates are:
0:149(36): error: float sqrt(float)
0:149(36): error: vec2 sqrt(vec2)
0:149(36): error: vec3 sqrt(vec3)
0:149(36): error: vec4 sqrt(vec4)
0:149(30): error: operands to arithmetic operators must be numeric
0:149(18): error: no matching function for call to max(float, error)'; candidates are: 0:149(18): error: float max(float, float) 0:149(18): error: float max(float, float) 0:149(18): error: vec2 max(vec2, float) 0:149(18): error: vec3 max(vec3, float) 0:149(18): error: vec4 max(vec4, float) 0:149(18): error: vec2 max(vec2, vec2) 0:149(18): error: vec3 max(vec3, vec3) 0:149(18): error: vec4 max(vec4, vec4) 0:149(18): error: int max(int, int) 0:149(18): error: ivec2 max(ivec2, int) 0:149(18): error: ivec3 max(ivec3, int) 0:149(18): error: ivec4 max(ivec4, int) 0:149(18): error: ivec2 max(ivec2, ivec2) 0:149(18): error: ivec3 max(ivec3, ivec3) 0:149(18): error: ivec4 max(ivec4, ivec4) 0:149(18): error: uint max(uint, uint) 0:149(18): error: uvec2 max(uvec2, uint) 0:149(18): error: uvec3 max(uvec3, uint) 0:149(18): error: uvec4 max(uvec4, uint) 0:149(18): error: uvec2 max(uvec2, uvec2) 0:149(18): error: uvec3 max(uvec3, uvec3) 0:149(18): error: uvec4 max(uvec4, uvec4) 0:149(12): error: no matching function for call to
pow(error, float)'; candidates are:
0:149(12): error: float pow(float, float)
0:149(12): error: vec2 pow(vec2, vec2)
0:149(12): error: vec3 pow(vec3, vec3)
0:149(12): error: vec4 pow(vec4, vec4)
0:150(33): warning: `A' used uninitialized
``