2012-sep-19 12:30:27 com.jme3.renderer.lwjgl.LwjglRenderer updateShaderSourceData
VARNING: Bad compile of:
1 #define FILTER_MODE 1
2 #define HARDWARE_SHADOWS 1
3 #define PCFEDGE 1.0
4 #define SHADOWMAP_SIZE 1024.0
5 #ifdef HARDWARE_SHADOWS
6 #define SHADOWMAP sampler2DShadow
7 #define SHADOWCOMPARE(tex,coord) shadow2DProj(tex, coord).r
8 #else
9 #define SHADOWMAP sampler2D
10 #define SHADOWCOMPARE(tex,coord) step(coord.z, texture2DProj(tex, coord).r)
11 #endif
12
13 #if FILTER_MODE == 0
14 #define GETSHADOW Shadow_DoShadowCompare
15 #define KERNEL 1.0
16 #elif FILTER_MODE == 1
17 #ifdef HARDWARE_SHADOWS
18 #define GETSHADOW Shadow_DoShadowCompare
19 #else
20 #define GETSHADOW Shadow_DoBilinear_2x2
21 #endif
22 #define KERNEL 1.0
23 #elif FILTER_MODE == 2
24 #define GETSHADOW Shadow_DoDither_2x2
25 #define KERNEL 1.0
26 #elif FILTER_MODE == 3
27 #define GETSHADOW Shadow_DoPCF
28 #define KERNEL 4.0
29 #elif FILTER_MODE == 4
30 #define GETSHADOW Shadow_DoPCFPoisson
31 #define KERNEL 4
32 #elif FILTER_MODE == 5
33 #define GETSHADOW Shadow_DoPCF
34 #define KERNEL 8.0
35 #endif
36
37
38 uniform SHADOWMAP m_ShadowMap0;
39 uniform SHADOWMAP m_ShadowMap1;
40 uniform SHADOWMAP m_ShadowMap2;
41 uniform SHADOWMAP m_ShadowMap3;
42
43 uniform vec4 m_Splits;
44
45 uniform float m_ShadowIntensity;
46
47 varying vec4 projCoord0;
48 varying vec4 projCoord1;
49 varying vec4 projCoord2;
50 varying vec4 projCoord3;
51
52 varying float shadowPosition;
53
54
55 const vec2 pixSize2 = vec2(1.0 / SHADOWMAP_SIZE);
56 float scale = 1.0;
57
58 float Shadow_DoShadowCompareOffset(in SHADOWMAP tex, in vec4 projCoord, in vec2 offset){
59 vec4 coord = vec4(projCoord.xy + offset.xy * pixSize2, projCoord.zw);
60 return SHADOWCOMPARE(tex, coord);
61 }
62
63 float Shadow_DoShadowCompare(in SHADOWMAP tex, vec4 projCoord){
64 return SHADOWCOMPARE(tex, projCoord);
65 }
66
67 float Shadow_BorderCheck(in vec2 coord){
68 // Fastest, "hack" method (uses 4-5 instructions)
69 vec4 t = vec4(coord.xy, 0.0, 1.0);
70 t = step(t.wwxy, t.xyzz);
71 return dot(t,t);
72 }
73
74 float Shadow_DoDither_2x2(in SHADOWMAP tex, in vec4 projCoord){
75 float border = Shadow_BorderCheck(projCoord.xy);
76 if (border > 0.0)
77 return 1.0;
78
79
80 float shadow = 0.0;
81 vec2 o = mod(floor(gl_FragCoord.xy), 2.0);
82 shadow += Shadow_DoShadowCompareOffset(tex,projCoord,vec2(-1.5, 1.5) + o);
83 shadow += Shadow_DoShadowCompareOffset(tex,projCoord,vec2( 0.5, 1.5) + o);
84 shadow += Shadow_DoShadowCompareOffset(tex,projCoord,vec2(-1.5, -0.5) + o);
85 shadow += Shadow_DoShadowCompareOffset(tex,projCoord,vec2( 0.5, -0.5) + o);
86 shadow *= 0.25 ;
87 return shadow;
88 }
89
90 float Shadow_DoBilinear_2x2(in SHADOWMAP tex, in vec4 projCoord){
91 float border = Shadow_BorderCheck(projCoord.xy);
92 if (border > 0.0)
93 return 1.0;
94 vec4 gather = vec4(0.0);
95 gather.x = Shadow_DoShadowCompareOffset(tex, projCoord, vec2(0.0, 0.0));
96 gather.y = Shadow_DoShadowCompareOffset(tex, projCoord, vec2(1.0, 0.0));
97 gather.z = Shadow_DoShadowCompareOffset(tex, projCoord, vec2(0.0, 1.0));
98 gather.w = Shadow_DoShadowCompareOffset(tex, projCoord, vec2(1.0, 1.0));
99
100 vec2 f = fract( projCoord.xy * SHADOWMAP_SIZE );
101 vec2 mx = mix( gather.xz, gather.yw, f.x );
102 return mix( mx.x, mx.y, f.y );
103 }
104
105 float Shadow_DoPCF(in SHADOWMAP tex, in vec4 projCoord){
106 float shadow = 0.0;
107 float border = Shadow_BorderCheck(projCoord.xy);
108 if (border > 0.0)
109 return 1.0;
110 float bound = KERNEL * 0.5 - 0.5;
111 bound *= PCFEDGE;
112 for (float y = -bound; y <= bound; y += PCFEDGE){
113 for (float x = -bound; x <= bound; x += PCFEDGE){
114 shadow += clamp(Shadow_DoShadowCompareOffset(tex,projCoord,vec2(x,y)) +
115 border,
116 0.0, 1.0);
117 }
118 }
119
120 shadow = shadow / (KERNEL * KERNEL);
121 return shadow;
122 }
123
124
125 //12 tap poisson disk
126 const vec2 poissonDisk[12] =vec2[12]( vec2(-0.1711046, -0.425016),
127 vec2(-0.7829809, 0.2162201),
128 vec2(-0.2380269, -0.8835521),
129 vec2(0.4198045, 0.1687819),
130 vec2(-0.684418, -0.3186957),
131 vec2(0.6026866, -0.2587841),
132 vec2(-0.2412762, 0.3913516),
133 vec2(0.4720655, -0.7664126),
134 vec2(0.9571564, 0.2680693),
135 vec2(-0.5238616, 0.802707),
136 vec2(0.5653144, 0.60262),
137 vec2(0.0123658, 0.8627419));
138
139 float Shadow_DoPCFPoisson(in SHADOWMAP tex, in vec4 projCoord){
140 float shadow = 0.0;
141 float border = Shadow_BorderCheck(projCoord.xy);
142 if (border > 0.0)
143 return 1.0;
144
145 vec2 texelSize = vec2( 4.0 * PCFEDGE * scale);
146
147 shadow += Shadow_DoShadowCompareOffset(tex, projCoord , poissonDisk[0] * texelSize);
148 shadow += Shadow_DoShadowCompareOffset(tex, projCoord , poissonDisk[1] * texelSize);
149 shadow += Shadow_DoShadowCompareOffset(tex, projCoord , poissonDisk[2] * texelSize);
150 shadow += Shadow_DoShadowCompareOffset(tex, projCoord , poissonDisk[3] * texelSize);
151 shadow += Shadow_DoShadowCompareOffset(tex, projCoord , poissonDisk[4] * texelSize);
152 shadow += Shadow_DoShadowCompareOffset(tex, projCoord , poissonDisk[5] * texelSize);
153 shadow += Shadow_DoShadowCompareOffset(tex, projCoord , poissonDisk[6] * texelSize);
154 shadow += Shadow_DoShadowCompareOffset(tex, projCoord , poissonDisk[7] * texelSize);
155 shadow += Shadow_DoShadowCompareOffset(tex, projCoord , poissonDisk[8] * texelSize);
156 shadow += Shadow_DoShadowCompareOffset(tex, projCoord , poissonDisk[9] * texelSize);
157 shadow += Shadow_DoShadowCompareOffset(tex, projCoord , poissonDisk[10] * texelSize);
158 shadow += Shadow_DoShadowCompareOffset(tex, projCoord , poissonDisk[11] * texelSize);
159
160 shadow = shadow * 0.08333333333;//this is divided by 12
161 return shadow;
162 }
163
164 #ifdef DISCARD_ALPHA
165 #ifdef COLOR_MAP
166 uniform sampler2D m_ColorMap;
167 #else
168 uniform sampler2D m_DiffuseMap;
169 #endif
170 uniform float m_AlphaDiscardThreshold;
171 varying vec2 texCoord;
172 #endif
173
174 void main(){
175
176 #ifdef DISCARD_ALPHA
177 #ifdef COLOR_MAP
178 float alpha = texture2D(m_ColorMap,texCoord).a;
179 #else
180 float alpha = texture2D(m_DiffuseMap,texCoord).a;
181 #endif
182 if(alpha<=m_AlphaDiscardThreshold){
183 discard;
184 }
185
186 #endif
187
188
189 vec4 shadowPerSplit = vec4(0.0);
190 float shadow;
191 //shadowPosition
192 if(shadowPosition < m_Splits.x){
193 shadow= GETSHADOW(m_ShadowMap0, projCoord0);
194 }else if( shadowPosition < m_Splits.y){
195 scale = 0.5;
196 shadow = GETSHADOW(m_ShadowMap1, projCoord1);
197 }else if( shadowPosition < m_Splits.z){
198 scale = 0.25;
199 shadow= GETSHADOW(m_ShadowMap2, projCoord2);
200 }else if( shadowPosition < m_Splits.w){
201 scale = 0.125;
202 shadow= GETSHADOW(m_ShadowMap3, projCoord3);
203 }
204 /*
205 shadowPerSplit.x = GETSHADOW(m_ShadowMap0, projCoord0);
206 shadowPerSplit.y = GETSHADOW(m_ShadowMap1, projCoord1);
207 shadowPerSplit.z = GETSHADOW(m_ShadowMap2, projCoord2);
208 shadowPerSplit.w = GETSHADOW(m_ShadowMap3, projCoord3);
209 */
210
211 /*
212 vec4 less = step( shadowPosition, m_Splits );
213 vec4 more = vec4(1.0) - step( shadowPosition, vec4(0.0, m_Splits.xyz) );
214 float shadow = dot(shadowPerSplit, less * more );
215 */
216 shadow = shadow * m_ShadowIntensity + (1.0 - m_ShadowIntensity);
217
218
219 gl_FragColor = vec4(shadow, shadow, shadow, 1.0);
220
221 }

2012-sep-19 12:30:27 com.jme3.app.Application handleError

ALLVARLIG: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]

com.jme3.renderer.RendererException: compile error in:ShaderSource[name=Common/MatDefs/Shadow/PostShadowPSSM.frag, defines, type=Fragment, language=GLSL100] error:ERROR: 0:126: ‘]’ : syntax error syntax error

ERROR: 0:137: ‘;’ : syntax error syntax error