]> de.git.xonotic.org Git - xonotic/darkplaces.git/blob - shader_hlsl.h
reworked GL shader detection a bit, now works on Mac with Intel GMA 945 again
[xonotic/darkplaces.git] / shader_hlsl.h
1 "// ambient+diffuse+specular+normalmap+attenuation+cubemap+fog shader\n"
2 "// written by Forest 'LordHavoc' Hale\n"
3 "// shadowmapping enhancements by Lee 'eihrul' Salzman\n"
4 "\n"
5 "// FIXME: we need to get rid of ModelViewProjectionPosition to make room for the texcoord for this\n"
6 "#if defined(USEREFLECTION)\n"
7 "#undef USESHADOWMAPORTHO\n"
8 "#endif\n"
9 "\n"
10 "#if defined(USEFOGINSIDE) || defined(USEFOGOUTSIDE) || defined(USEFOGHEIGHTTEXTURE)\n"
11 "# define USEFOG\n"
12 "#endif\n"
13 "#if defined(MODE_LIGHTMAP) || defined(MODE_LIGHTDIRECTIONMAP_MODELSPACE) || defined(MODE_LIGHTDIRECTIONMAP_TANGENTSPACE)\n"
14 "#define USELIGHTMAP\n"
15 "#endif\n"
16 "#if defined(USESPECULAR) || defined(USEOFFSETMAPPING) || defined(USEREFLECTCUBE) || defined(MODE_FAKELIGHT)\n"
17 "#define USEEYEVECTOR\n"
18 "#endif\n"
19 "\n"
20 "#ifdef FRAGMENT_SHADER\n"
21 "#ifdef HLSL\n"
22 "//#undef USESHADOWMAPPCF\n"
23 "//#define texDepth2D(tex,texcoord) tex2D(tex,texcoord).r\n"
24 "#define texDepth2D(tex,texcoord) dot(tex2D(tex,texcoord).rgb, float3(1.0, 255.0/65536.0, 255.0/16777216.0))\n"
25 "#else\n"
26 "#define texDepth2D(tex,texcoord) tex2D(tex,texcoord).r\n"
27 "#endif\n"
28 "#endif\n"
29 "\n"
30 "#ifdef MODE_DEPTH_OR_SHADOW\n"
31 "#ifdef VERTEX_SHADER\n"
32 "void main\n"
33 "(\n"
34 "float4 gl_Vertex : POSITION,\n"
35 "uniform float4x4 ModelViewProjectionMatrix : register(c8),\n"
36 "out float4 gl_Position : POSITION,\n"
37 "out float Depth : TEXCOORD0\n"
38 ")\n"
39 "{\n"
40 "       gl_Position = mul(ModelViewProjectionMatrix, gl_Vertex);\n"
41 "       Depth = gl_Position.z;\n"
42 "}\n"
43 "#endif\n"
44 "\n"
45 "#ifdef FRAGMENT_SHADER\n"
46 "void main\n"
47 "(\n"
48 "float Depth : TEXCOORD0,\n"
49 "out float4 gl_FragColor : COLOR\n"
50 ")\n"
51 "{\n"
52 "//     float4 temp = float4(Depth,Depth*(65536.0/255.0),Depth*(16777216.0/255.0),0.0);\n"
53 "       float4 temp = float4(Depth,Depth*256.0,Depth*65536.0,0.0);\n"
54 "       temp.yz -= floor(temp.yz);\n"
55 "       gl_FragColor = temp;\n"
56 "//     gl_FragColor = float4(Depth,0,0,0);\n"
57 "}\n"
58 "#endif\n"
59 "#else // !MODE_DEPTH_ORSHADOW\n"
60 "\n"
61 "\n"
62 "\n"
63 "\n"
64 "#ifdef MODE_SHOWDEPTH\n"
65 "#ifdef VERTEX_SHADER\n"
66 "void main\n"
67 "(\n"
68 "float4 gl_Vertex : POSITION,\n"
69 "uniform float4x4 ModelViewProjectionMatrix : register(c8),\n"
70 "out float4 gl_Position : POSITION,\n"
71 "out float4 gl_FrontColor : COLOR0\n"
72 ")\n"
73 "{\n"
74 "       gl_Position = mul(ModelViewProjectionMatrix, gl_Vertex);\n"
75 "       gl_FrontColor = float4(gl_Position.z, gl_Position.z, gl_Position.z, 1.0);\n"
76 "}\n"
77 "#endif\n"
78 "\n"
79 "#ifdef FRAGMENT_SHADER\n"
80 "void main\n"
81 "(\n"
82 "float4 gl_FrontColor : COLOR0,\n"
83 "out float4 gl_FragColor : COLOR\n"
84 ")\n"
85 "{\n"
86 "       gl_FragColor = gl_FrontColor;\n"
87 "}\n"
88 "#endif\n"
89 "#else // !MODE_SHOWDEPTH\n"
90 "\n"
91 "\n"
92 "\n"
93 "\n"
94 "#ifdef MODE_POSTPROCESS\n"
95 "\n"
96 "#ifdef VERTEX_SHADER\n"
97 "void main\n"
98 "(\n"
99 "float4 gl_Vertex : POSITION,\n"
100 "uniform float4x4 ModelViewProjectionMatrix : register(c8),\n"
101 "float4 gl_MultiTexCoord0 : TEXCOORD0,\n"
102 "float4 gl_MultiTexCoord4 : TEXCOORD4,\n"
103 "out float4 gl_Position : POSITION,\n"
104 "out float2 TexCoord1 : TEXCOORD0,\n"
105 "out float2 TexCoord2 : TEXCOORD1\n"
106 ")\n"
107 "{\n"
108 "       gl_Position = mul(ModelViewProjectionMatrix, gl_Vertex);\n"
109 "       TexCoord1 = gl_MultiTexCoord0.xy;\n"
110 "#ifdef USEBLOOM\n"
111 "       TexCoord2 = gl_MultiTexCoord4.xy;\n"
112 "#endif\n"
113 "}\n"
114 "#endif\n"
115 "\n"
116 "#ifdef FRAGMENT_SHADER\n"
117 "void main\n"
118 "(\n"
119 "float2 TexCoord1 : TEXCOORD0,\n"
120 "float2 TexCoord2 : TEXCOORD1,\n"
121 "uniform sampler Texture_First : register(s0),\n"
122 "#ifdef USEBLOOM\n"
123 "uniform sampler Texture_Second : register(s1),\n"
124 "#endif\n"
125 "#ifdef USEGAMMARAMPS\n"
126 "uniform sampler Texture_GammaRamps : register(s2),\n"
127 "#endif\n"
128 "#ifdef USESATURATION\n"
129 "uniform float Saturation : register(c30),\n"
130 "#endif\n"
131 "#ifdef USEVIEWTINT\n"
132 "uniform float4 ViewTintColor : register(c41),\n"
133 "#endif\n"
134 "uniform float4 UserVec1 : register(c37),\n"
135 "uniform float4 UserVec2 : register(c38),\n"
136 "uniform float4 UserVec3 : register(c39),\n"
137 "uniform float4 UserVec4 : register(c40),\n"
138 "uniform float ClientTime : register(c2),\n"
139 "uniform float2 PixelSize : register(c25),\n"
140 "uniform float4 BloomColorSubtract : register(c43),\n"
141 "out float4 gl_FragColor : COLOR\n"
142 ")\n"
143 "{\n"
144 "       gl_FragColor = tex2D(Texture_First, TexCoord1);\n"
145 "#ifdef USEBLOOM\n"
146 "       gl_FragColor += max(float4(0,0,0,0), tex2D(Texture_Second, TexCoord2) - BloomColorSubtract);\n"
147 "#endif\n"
148 "#ifdef USEVIEWTINT\n"
149 "       gl_FragColor = lerp(gl_FragColor, ViewTintColor, ViewTintColor.a);\n"
150 "#endif\n"
151 "\n"
152 "#ifdef USEPOSTPROCESSING\n"
153 "// do r_glsl_dumpshader, edit glsl/default.glsl, and replace this by your own postprocessing if you want\n"
154 "// this code does a blur with the radius specified in the first component of r_glsl_postprocess_uservec1 and blends it using the second component\n"
155 "       float sobel = 1.0;\n"
156 "       // float2 ts = textureSize(Texture_First, 0);\n"
157 "       // float2 px = float2(1/ts.x, 1/ts.y);\n"
158 "       float2 px = PixelSize;\n"
159 "       float3 x1 = tex2D(Texture_First, TexCoord1 + float2(-px.x, px.y)).rgb;\n"
160 "       float3 x2 = tex2D(Texture_First, TexCoord1 + float2(-px.x,  0.0)).rgb;\n"
161 "       float3 x3 = tex2D(Texture_First, TexCoord1 + float2(-px.x,-px.y)).rgb;\n"
162 "       float3 x4 = tex2D(Texture_First, TexCoord1 + float2( px.x, px.y)).rgb;\n"
163 "       float3 x5 = tex2D(Texture_First, TexCoord1 + float2( px.x,  0.0)).rgb;\n"
164 "       float3 x6 = tex2D(Texture_First, TexCoord1 + float2( px.x,-px.y)).rgb;\n"
165 "       float3 y1 = tex2D(Texture_First, TexCoord1 + float2( px.x,-px.y)).rgb;\n"
166 "       float3 y2 = tex2D(Texture_First, TexCoord1 + float2(  0.0,-px.y)).rgb;\n"
167 "       float3 y3 = tex2D(Texture_First, TexCoord1 + float2(-px.x,-px.y)).rgb;\n"
168 "       float3 y4 = tex2D(Texture_First, TexCoord1 + float2( px.x, px.y)).rgb;\n"
169 "       float3 y5 = tex2D(Texture_First, TexCoord1 + float2(  0.0, px.y)).rgb;\n"
170 "       float3 y6 = tex2D(Texture_First, TexCoord1 + float2(-px.x, px.y)).rgb;\n"
171 "       float px1 = -1.0 * dot(float3(0.3, 0.59, 0.11), x1);\n"
172 "       float px2 = -2.0 * dot(float3(0.3, 0.59, 0.11), x2);\n"
173 "       float px3 = -1.0 * dot(float3(0.3, 0.59, 0.11), x3);\n"
174 "       float px4 =  1.0 * dot(float3(0.3, 0.59, 0.11), x4);\n"
175 "       float px5 =  2.0 * dot(float3(0.3, 0.59, 0.11), x5);\n"
176 "       float px6 =  1.0 * dot(float3(0.3, 0.59, 0.11), x6);\n"
177 "       float py1 = -1.0 * dot(float3(0.3, 0.59, 0.11), y1);\n"
178 "       float py2 = -2.0 * dot(float3(0.3, 0.59, 0.11), y2);\n"
179 "       float py3 = -1.0 * dot(float3(0.3, 0.59, 0.11), y3);\n"
180 "       float py4 =  1.0 * dot(float3(0.3, 0.59, 0.11), y4);\n"
181 "       float py5 =  2.0 * dot(float3(0.3, 0.59, 0.11), y5);\n"
182 "       float py6 =  1.0 * dot(float3(0.3, 0.59, 0.11), y6);\n"
183 "       sobel = 0.25 * abs(px1 + px2 + px3 + px4 + px5 + px6) + 0.25 * abs(py1 + py2 + py3 + py4 + py5 + py6);\n"
184 "       gl_FragColor += tex2D(Texture_First, TexCoord1 + PixelSize*UserVec1.x*float2(-0.987688, -0.156434)) * UserVec1.y;\n"
185 "       gl_FragColor += tex2D(Texture_First, TexCoord1 + PixelSize*UserVec1.x*float2(-0.156434, -0.891007)) * UserVec1.y;\n"
186 "       gl_FragColor += tex2D(Texture_First, TexCoord1 + PixelSize*UserVec1.x*float2( 0.891007, -0.453990)) * UserVec1.y;\n"
187 "       gl_FragColor += tex2D(Texture_First, TexCoord1 + PixelSize*UserVec1.x*float2( 0.707107,  0.707107)) * UserVec1.y;\n"
188 "       gl_FragColor += tex2D(Texture_First, TexCoord1 + PixelSize*UserVec1.x*float2(-0.453990,  0.891007)) * UserVec1.y;\n"
189 "       gl_FragColor /= (1.0 + 5.0 * UserVec1.y);\n"
190 "       gl_FragColor.rgb = gl_FragColor.rgb * (1.0 + UserVec2.x) + float3(1,1,1)*max(0.0, sobel - UserVec2.z)*UserVec2.y;\n"
191 "#endif\n"
192 "\n"
193 "#ifdef USESATURATION\n"
194 "       //apply saturation BEFORE gamma ramps, so v_glslgamma value does not matter\n"
195 "       float y = dot(gl_FragColor.rgb, float3(0.299, 0.587, 0.114));\n"
196 "       // 'vampire sight' effect, wheres red is compensated\n"
197 "       #ifdef SATURATION_REDCOMPENSATE\n"
198 "               float rboost = max(0.0, (gl_FragColor.r - max(gl_FragColor.g, gl_FragColor.b))*(1.0 - Saturation));\n"
199 "               gl_FragColor.rgb = lerp(float3(y,y,y), gl_FragColor.rgb, Saturation);\n"
200 "               gl_FragColor.r += r;\n"
201 "       #else\n"
202 "               // normal desaturation\n"
203 "               //gl_FragColor = float3(y,y,y) + (gl_FragColor.rgb - float3(y)) * Saturation;\n"
204 "               gl_FragColor.rgb = lerp(float3(y,y,y), gl_FragColor.rgb, Saturation);\n"
205 "       #endif\n"
206 "#endif\n"
207 "\n"
208 "#ifdef USEGAMMARAMPS\n"
209 "       gl_FragColor.r = tex2D(Texture_GammaRamps, float2(gl_FragColor.r, 0)).r;\n"
210 "       gl_FragColor.g = tex2D(Texture_GammaRamps, float2(gl_FragColor.g, 0)).g;\n"
211 "       gl_FragColor.b = tex2D(Texture_GammaRamps, float2(gl_FragColor.b, 0)).b;\n"
212 "#endif\n"
213 "}\n"
214 "#endif\n"
215 "#else // !MODE_POSTPROCESS\n"
216 "\n"
217 "\n"
218 "\n"
219 "\n"
220 "#ifdef MODE_GENERIC\n"
221 "#ifdef VERTEX_SHADER\n"
222 "void main\n"
223 "(\n"
224 "float4 gl_Vertex : POSITION,\n"
225 "uniform float4x4 ModelViewProjectionMatrix : register(c8),\n"
226 "float4 gl_Color : COLOR0,\n"
227 "float4 gl_MultiTexCoord0 : TEXCOORD0,\n"
228 "float4 gl_MultiTexCoord1 : TEXCOORD1,\n"
229 "out float4 gl_Position : POSITION,\n"
230 "#ifdef USEDIFFUSE\n"
231 "out float2 TexCoord1 : TEXCOORD0,\n"
232 "#endif\n"
233 "#ifdef USESPECULAR\n"
234 "out float2 TexCoord2 : TEXCOORD1,\n"
235 "#endif\n"
236 "out float4 gl_FrontColor : COLOR\n"
237 ")\n"
238 "{\n"
239 "       gl_FrontColor = gl_Color;\n"
240 "#ifdef USEDIFFUSE\n"
241 "       TexCoord1 = gl_MultiTexCoord0.xy;\n"
242 "#endif\n"
243 "#ifdef USESPECULAR\n"
244 "       TexCoord2 = gl_MultiTexCoord1.xy;\n"
245 "#endif\n"
246 "       gl_Position = mul(ModelViewProjectionMatrix, gl_Vertex);\n"
247 "}\n"
248 "#endif\n"
249 "\n"
250 "#ifdef FRAGMENT_SHADER\n"
251 "\n"
252 "void main\n"
253 "(\n"
254 "float4 gl_FrontColor : COLOR0,\n"
255 "float2 TexCoord1 : TEXCOORD0,\n"
256 "float2 TexCoord2 : TEXCOORD1,\n"
257 "#ifdef USEDIFFUSE\n"
258 "uniform sampler Texture_First : register(s0),\n"
259 "#endif\n"
260 "#ifdef USESPECULAR\n"
261 "uniform sampler Texture_Second : register(s1),\n"
262 "#endif\n"
263 "out float4 gl_FragColor : COLOR\n"
264 ")\n"
265 "{\n"
266 "#ifdef USEVIEWTINT\n"
267 "       gl_FragColor = gl_FrontColor;\n"
268 "#else\n"
269 "       gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);\n"
270 "#endif\n"
271 "#ifdef USEDIFFUSE\n"
272 "       gl_FragColor *= tex2D(Texture_First, TexCoord1);\n"
273 "#endif\n"
274 "\n"
275 "#ifdef USESPECULAR\n"
276 "       float4 tex2 = tex2D(Texture_Second, TexCoord2);\n"
277 "# ifdef USECOLORMAPPING\n"
278 "       gl_FragColor *= tex2;\n"
279 "# endif\n"
280 "# ifdef USEGLOW\n"
281 "       gl_FragColor += tex2;\n"
282 "# endif\n"
283 "# ifdef USEVERTEXTEXTUREBLEND\n"
284 "       gl_FragColor = lerp(gl_FragColor, tex2, tex2.a);\n"
285 "# endif\n"
286 "#endif\n"
287 "}\n"
288 "#endif\n"
289 "#else // !MODE_GENERIC\n"
290 "\n"
291 "\n"
292 "\n"
293 "\n"
294 "#ifdef MODE_BLOOMBLUR\n"
295 "#ifdef VERTEX_SHADER\n"
296 "void main\n"
297 "(\n"
298 "float4 gl_Vertex : POSITION,\n"
299 "uniform float4x4 ModelViewProjectionMatrix : register(c8),\n"
300 "float4 gl_MultiTexCoord0 : TEXCOORD0,\n"
301 "out float4 gl_Position : POSITION,\n"
302 "out float2 TexCoord : TEXCOORD0\n"
303 ")\n"
304 "{\n"
305 "       TexCoord = gl_MultiTexCoord0.xy;\n"
306 "       gl_Position = mul(ModelViewProjectionMatrix, gl_Vertex);\n"
307 "}\n"
308 "#endif\n"
309 "\n"
310 "#ifdef FRAGMENT_SHADER\n"
311 "\n"
312 "void main\n"
313 "(\n"
314 "float2 TexCoord : TEXCOORD0,\n"
315 "uniform sampler Texture_First : register(s0),\n"
316 "uniform float4 BloomBlur_Parameters : register(c1),\n"
317 "out float4 gl_FragColor : COLOR\n"
318 ")\n"
319 "{\n"
320 "       int i;\n"
321 "       float2 tc = TexCoord;\n"
322 "       float3 color = tex2D(Texture_First, tc).rgb;\n"
323 "       tc += BloomBlur_Parameters.xy;\n"
324 "       for (i = 1;i < SAMPLES;i++)\n"
325 "       {\n"
326 "               color += tex2D(Texture_First, tc).rgb;\n"
327 "               tc += BloomBlur_Parameters.xy;\n"
328 "       }\n"
329 "       gl_FragColor = float4(color * BloomBlur_Parameters.z + float3(BloomBlur_Parameters.w), 1);\n"
330 "}\n"
331 "#endif\n"
332 "#else // !MODE_BLOOMBLUR\n"
333 "#ifdef MODE_REFRACTION\n"
334 "#ifdef VERTEX_SHADER\n"
335 "void main\n"
336 "(\n"
337 "float4 gl_Vertex : POSITION,\n"
338 "uniform float4x4 ModelViewProjectionMatrix : register(c8),\n"
339 "float4 gl_MultiTexCoord0 : TEXCOORD0,\n"
340 "uniform float4x4 TexMatrix : register(c0),\n"
341 "uniform float3 EyePosition : register(c24),\n"
342 "out float4 gl_Position : POSITION,\n"
343 "out float2 TexCoord : TEXCOORD0,\n"
344 "out float3 EyeVector : TEXCOORD1,\n"
345 "out float4 ModelViewProjectionPosition : TEXCOORD2\n"
346 ")\n"
347 "{\n"
348 "       TexCoord = mul(TexMatrix, gl_MultiTexCoord0).xy;\n"
349 "       gl_Position = mul(ModelViewProjectionMatrix, gl_Vertex);\n"
350 "       ModelViewProjectionPosition = gl_Position;\n"
351 "}\n"
352 "#endif\n"
353 "\n"
354 "#ifdef FRAGMENT_SHADER\n"
355 "void main\n"
356 "(\n"
357 "float2 TexCoord : TEXCOORD0,\n"
358 "float3 EyeVector : TEXCOORD1,\n"
359 "float4 ModelViewProjectionPosition : TEXCOORD2,\n"
360 "uniform sampler Texture_Normal : register(s0),\n"
361 "uniform sampler Texture_Refraction : register(s3),\n"
362 "uniform sampler Texture_Reflection : register(s7),\n"
363 "uniform float4 DistortScaleRefractReflect : register(c14),\n"
364 "uniform float4 ScreenScaleRefractReflect : register(c32),\n"
365 "uniform float4 ScreenCenterRefractReflect : register(c31),\n"
366 "uniform float4 RefractColor : register(c29),\n"
367 "out float4 gl_FragColor : COLOR\n"
368 ")\n"
369 "{\n"
370 "       float2 ScreenScaleRefractReflectIW = ScreenScaleRefractReflect.xy * (1.0 / ModelViewProjectionPosition.w);\n"
371 "       //float2 ScreenTexCoord = (ModelViewProjectionPosition.xy + normalize(tex2D(Texture_Normal, TexCoord).rgb - float3(0.5,0.5,0.5)).xy * DistortScaleRefractReflect.xy * 100) * ScreenScaleRefractReflectIW + ScreenCenterRefractReflect.xy;\n"
372 "       float2 SafeScreenTexCoord = ModelViewProjectionPosition.xy * ScreenScaleRefractReflectIW + ScreenCenterRefractReflect.xy;\n"
373 "       float2 ScreenTexCoord = SafeScreenTexCoord + normalize(tex2D(Texture_Normal, TexCoord).rgb - float3(0.5,0.5,0.5)).xy * DistortScaleRefractReflect.xy;\n"
374 "       // FIXME temporary hack to detect the case that the reflection\n"
375 "       // gets blackened at edges due to leaving the area that contains actual\n"
376 "       // content.\n"
377 "       // Remove this 'ack once we have a better way to stop this thing from\n"
378 "       // 'appening.\n"
379 "       float f = min(1.0, length(tex2D(Texture_Refraction, ScreenTexCoord + float2(0.01, 0.01)).rgb) / 0.05);\n"
380 "       f      *= min(1.0, length(tex2D(Texture_Refraction, ScreenTexCoord + float2(0.01, -0.01)).rgb) / 0.05);\n"
381 "       f      *= min(1.0, length(tex2D(Texture_Refraction, ScreenTexCoord + float2(-0.01, 0.01)).rgb) / 0.05);\n"
382 "       f      *= min(1.0, length(tex2D(Texture_Refraction, ScreenTexCoord + float2(-0.01, -0.01)).rgb) / 0.05);\n"
383 "       ScreenTexCoord = lerp(SafeScreenTexCoord, ScreenTexCoord, f);\n"
384 "       gl_FragColor = float4(tex2D(Texture_Refraction, ScreenTexCoord).rgb, 1) * RefractColor;\n"
385 "}\n"
386 "#endif\n"
387 "#else // !MODE_REFRACTION\n"
388 "\n"
389 "\n"
390 "\n"
391 "\n"
392 "#ifdef MODE_WATER\n"
393 "#ifdef VERTEX_SHADER\n"
394 "\n"
395 "void main\n"
396 "(\n"
397 "float4 gl_Vertex : POSITION,\n"
398 "uniform float4x4 ModelViewProjectionMatrix : register(c8),\n"
399 "float4 gl_MultiTexCoord0 : TEXCOORD0,\n"
400 "float4 gl_MultiTexCoord1 : TEXCOORD1,\n"
401 "float4 gl_MultiTexCoord2 : TEXCOORD2,\n"
402 "float4 gl_MultiTexCoord3 : TEXCOORD3,\n"
403 "uniform float4x4 TexMatrix : register(c0),\n"
404 "uniform float3 EyePosition : register(c24),\n"
405 "out float4 gl_Position : POSITION,\n"
406 "out float2 TexCoord : TEXCOORD0,\n"
407 "out float3 EyeVector : TEXCOORD1,\n"
408 "out float4 ModelViewProjectionPosition : TEXCOORD2\n"
409 ")\n"
410 "{\n"
411 "       TexCoord = mul(TexMatrix, gl_MultiTexCoord0).xy;\n"
412 "       float3 EyeVectorModelSpace = EyePosition - gl_Vertex.xyz;\n"
413 "       EyeVector.x = dot(EyeVectorModelSpace, gl_MultiTexCoord1.xyz);\n"
414 "       EyeVector.y = dot(EyeVectorModelSpace, gl_MultiTexCoord2.xyz);\n"
415 "       EyeVector.z = dot(EyeVectorModelSpace, gl_MultiTexCoord3.xyz);\n"
416 "       gl_Position = mul(ModelViewProjectionMatrix, gl_Vertex);\n"
417 "       ModelViewProjectionPosition = gl_Position;\n"
418 "}\n"
419 "#endif\n"
420 "\n"
421 "#ifdef FRAGMENT_SHADER\n"
422 "void main\n"
423 "(\n"
424 "float2 TexCoord : TEXCOORD0,\n"
425 "float3 EyeVector : TEXCOORD1,\n"
426 "float4 ModelViewProjectionPosition : TEXCOORD2,\n"
427 "uniform sampler Texture_Normal : register(s0),\n"
428 "uniform sampler Texture_Refraction : register(s3),\n"
429 "uniform sampler Texture_Reflection : register(s7),\n"
430 "uniform float4 DistortScaleRefractReflect : register(c14),\n"
431 "uniform float4 ScreenScaleRefractReflect : register(c32),\n"
432 "uniform float4 ScreenCenterRefractReflect : register(c31),\n"
433 "uniform float4 RefractColor : register(c29),\n"
434 "uniform float4 ReflectColor : register(c26),\n"
435 "uniform float ReflectFactor : register(c27),\n"
436 "uniform float ReflectOffset : register(c28),\n"
437 "out float4 gl_FragColor : COLOR\n"
438 ")\n"
439 "{\n"
440 "       float4 ScreenScaleRefractReflectIW = ScreenScaleRefractReflect * (1.0 / ModelViewProjectionPosition.w);\n"
441 "       //float4 ScreenTexCoord = (ModelViewProjectionPosition.xyxy + normalize(tex2D(Texture_Normal, TexCoord).rgb - float3(0.5,0.5,0.5)).xyxy * DistortScaleRefractReflect * 100) * ScreenScaleRefractReflectIW + ScreenCenterRefractReflect;\n"
442 "       float4 SafeScreenTexCoord = ModelViewProjectionPosition.xyxy * ScreenScaleRefractReflectIW + ScreenCenterRefractReflect;\n"
443 "       //SafeScreenTexCoord = gl_FragCoord.xyxy * float4(1.0 / 1920.0, 1.0 / 1200.0, 1.0 / 1920.0, 1.0 / 1200.0);\n"
444 "       float4 ScreenTexCoord = SafeScreenTexCoord + float2(normalize(tex2D(Texture_Normal, TexCoord).rgb - float3(0.5,0.5,0.5)).xy).xyxy * DistortScaleRefractReflect;\n"
445 "       // FIXME temporary hack to detect the case that the reflection\n"
446 "       // gets blackened at edges due to leaving the area that contains actual\n"
447 "       // content.\n"
448 "       // Remove this 'ack once we have a better way to stop this thing from\n"
449 "       // 'appening.\n"
450 "       float f = min(1.0, length(tex2D(Texture_Refraction, ScreenTexCoord.xy + float2(0.01, 0.01)).rgb) / 0.05);\n"
451 "       f      *= min(1.0, length(tex2D(Texture_Refraction, ScreenTexCoord.xy + float2(0.01, -0.01)).rgb) / 0.05);\n"
452 "       f      *= min(1.0, length(tex2D(Texture_Refraction, ScreenTexCoord.xy + float2(-0.01, 0.01)).rgb) / 0.05);\n"
453 "       f      *= min(1.0, length(tex2D(Texture_Refraction, ScreenTexCoord.xy + float2(-0.01, -0.01)).rgb) / 0.05);\n"
454 "       ScreenTexCoord.xy = lerp(SafeScreenTexCoord.xy, ScreenTexCoord.xy, f);\n"
455 "       f  = min(1.0, length(tex2D(Texture_Reflection, ScreenTexCoord.zw + float2(0.01, 0.01)).rgb) / 0.05);\n"
456 "       f *= min(1.0, length(tex2D(Texture_Reflection, ScreenTexCoord.zw + float2(0.01, -0.01)).rgb) / 0.05);\n"
457 "       f *= min(1.0, length(tex2D(Texture_Reflection, ScreenTexCoord.zw + float2(-0.01, 0.01)).rgb) / 0.05);\n"
458 "       f *= min(1.0, length(tex2D(Texture_Reflection, ScreenTexCoord.zw + float2(-0.01, -0.01)).rgb) / 0.05);\n"
459 "       ScreenTexCoord.zw = lerp(SafeScreenTexCoord.zw, ScreenTexCoord.zw, f);\n"
460 "       float Fresnel = pow(min(1.0, 1.0 - float(normalize(EyeVector).z)), 2.0) * ReflectFactor + ReflectOffset;\n"
461 "       gl_FragColor = lerp(float4(tex2D(Texture_Refraction, ScreenTexCoord.xy).rgb, 1) * RefractColor, float4(tex2D(Texture_Reflection, ScreenTexCoord.zw).rgb, 1) * ReflectColor, Fresnel);\n"
462 "}\n"
463 "#endif\n"
464 "#else // !MODE_WATER\n"
465 "\n"
466 "\n"
467 "\n"
468 "\n"
469 "// TODO: get rid of tangentt (texcoord2) and use a crossproduct to regenerate it from tangents (texcoord1) and normal (texcoord3), this would require sending a 4 component texcoord1 with W as 1 or -1 according to which side the texcoord2 should be on\n"
470 "\n"
471 "// fragment shader specific:\n"
472 "#ifdef FRAGMENT_SHADER\n"
473 "\n"
474 "#ifdef USEFOG\n"
475 "float3 FogVertex(float4 surfacecolor, float3 FogColor, float3 EyeVectorModelSpace, float FogPlaneVertexDist, float FogRangeRecip, float FogPlaneViewDist, float FogHeightFade, sampler Texture_FogMask, sampler Texture_FogHeightTexture)\n"
476 "{\n"
477 "       float fogfrac;\n"
478 "       float3 fc = FogColor;\n"
479 "#ifdef USEFOGALPHAHACK\n"
480 "       fc *= surfacecolor.a;\n"
481 "#endif\n"
482 "#ifdef USEFOGHEIGHTTEXTURE\n"
483 "       float4 fogheightpixel = tex2D(Texture_FogHeightTexture, float2(1,1) + float2(FogPlaneVertexDist, FogPlaneViewDist) * (-2.0 * FogHeightFade));\n"
484 "       fogfrac = fogheightpixel.a;\n"
485 "       return lerp(fogheightpixel.rgb * fc, surfacecolor.rgb, tex2D(Texture_FogMask, float2(length(EyeVectorModelSpace)*fogfrac*FogRangeRecip, 0.0)).r);\n"
486 "#else\n"
487 "# ifdef USEFOGOUTSIDE\n"
488 "       fogfrac = min(0.0, FogPlaneVertexDist) / (FogPlaneVertexDist - FogPlaneViewDist) * min(1.0, min(0.0, FogPlaneVertexDist) * FogHeightFade);\n"
489 "# else\n"
490 "       fogfrac = FogPlaneViewDist / (FogPlaneViewDist - max(0.0, FogPlaneVertexDist)) * min(1.0, (min(0.0, FogPlaneVertexDist) + FogPlaneViewDist) * FogHeightFade);\n"
491 "# endif\n"
492 "       return lerp(fc, surfacecolor.rgb, tex2D(Texture_FogMask, float2(length(EyeVectorModelSpace)*fogfrac*FogRangeRecip, 0.0)).r);\n"
493 "#endif\n"
494 "}\n"
495 "#endif\n"
496 "\n"
497 "#ifdef USEOFFSETMAPPING\n"
498 "float2 OffsetMapping(float2 TexCoord, float4 OffsetMapping_ScaleSteps, float3 EyeVector, sampler Texture_Normal, float2 dPdx, float2 dPdy)\n"
499 "{\n"
500 "       float i;\n"
501 "#ifdef USEOFFSETMAPPING_RELIEFMAPPING\n"
502 "       // 14 sample relief mapping: linear search and then binary search\n"
503 "       // this basically steps forward a small amount repeatedly until it finds\n"
504 "       // itself inside solid, then jitters forward and back using decreasing\n"
505 "       // amounts to find the impact\n"
506 "       //float3 OffsetVector = float3(EyeVector.xy * ((1.0 / EyeVector.z) * OffsetMapping_ScaleSteps.x) * float2(-1, 1), -1);\n"
507 "       //float3 OffsetVector = float3(normalize(EyeVector.xy) * OffsetMapping_ScaleSteps.x * float2(-1, 1), -1);\n"
508 "       float3 OffsetVector = float3(normalize(EyeVector).xy * OffsetMapping_ScaleSteps.x * float2(-1, 1), -1);\n"
509 "       float3 RT = float3(TexCoord, 1);\n"
510 "       OffsetVector *= OffsetMapping_ScaleSteps.z;\n"
511 "       for(i = 1.0; i < OffsetMapping_ScaleSteps.y; ++i)\n"
512 "               RT += OffsetVector *  step(tex2Dgrad(Texture_Normal, RT.xy, dPdx, dPdy).a, RT.z);\n"
513 "       for(i = 0.0, f = 1.0; i < OffsetMapping_ScaleSteps.w; ++i, f *= 0.5)\n"
514 "               RT += OffsetVector * (step(tex2Dgrad(Texture_Normal, RT.xy, dPdx, dPdy).a, RT.z) * f - 0.5 * f);\n"
515 "       return RT.xy;\n"
516 "#else\n"
517 "       // 2 sample offset mapping (only 2 samples because of ATI Radeon 9500-9800/X300 limits)\n"
518 "       //float2 OffsetVector = float2(EyeVector.xy * ((1.0 / EyeVector.z) * OffsetMapping_ScaleSteps.x) * float2(-1, 1));\n"
519 "       //float2 OffsetVector = float2(normalize(EyeVector.xy) * OffsetMapping_ScaleSteps.x * float2(-1, 1));\n"
520 "       float2 OffsetVector = float2(normalize(EyeVector).xy * OffsetMapping_ScaleSteps.x * float2(-1, 1));\n"
521 "       OffsetVector *= OffsetMapping_ScaleSteps.z;\n"
522 "       for(i = 0.0; i < OffsetMapping_ScaleSteps.y; ++i)\n"
523 "               TexCoord += OffsetVector * (1.0 - tex2Dgrad(Texture_Normal, TexCoord, dPdx, dPdy).a);\n"
524 "       return TexCoord;\n"
525 "#endif\n"
526 "}\n"
527 "#endif // USEOFFSETMAPPING\n"
528 "\n"
529 "#if defined(MODE_LIGHTSOURCE) || defined(MODE_DEFERREDLIGHTSOURCE) || defined(USESHADOWMAPORTHO)\n"
530 "#if defined(USESHADOWMAP2D)\n"
531 "# ifdef USESHADOWMAPORTHO\n"
532 "#  define GetShadowMapTC2D(dir, ShadowMap_Parameters) (min(dir, ShadowMap_Parameters.xyz))\n"
533 "# else\n"
534 "#  ifdef USESHADOWMAPVSDCT\n"
535 "float3 GetShadowMapTC2D(float3 dir, float4 ShadowMap_Parameters, samplerCUBE Texture_CubeProjection)\n"
536 "{\n"
537 "       float3 adir = abs(dir);\n"
538 "       float2 aparams = ShadowMap_Parameters.xy / max(max(adir.x, adir.y), adir.z);\n"
539 "       float4 proj = texCUBE(Texture_CubeProjection, dir);\n"
540 "       return float3(lerp(dir.xy, dir.zz, proj.xy) * aparams.x + proj.zw * ShadowMap_Parameters.z, aparams.y + ShadowMap_Parameters.w);\n"
541 "}\n"
542 "#  else\n"
543 "float3 GetShadowMapTC2D(float3 dir, float4 ShadowMap_Parameters)\n"
544 "{\n"
545 "       float3 adir = abs(dir);\n"
546 "       float ma = adir.z;\n"
547 "       float4 proj = float4(dir, 2.5);\n"
548 "       if (adir.x > ma) { ma = adir.x; proj = float4(dir.zyx, 0.5); }\n"
549 "       if (adir.y > ma) { ma = adir.y; proj = float4(dir.xzy, 1.5); }\n"
550 "#ifdef HLSL\n"
551 "       return float3(proj.xy * ShadowMap_Parameters.x / ma + float2(0.5,0.5) + float2(proj.z < 0.0 ? 1.5 : 0.5, proj.w) * ShadowMap_Parameters.z, ma + 64 * ShadowMap_Parameters.w);\n"
552 "#else\n"
553 "       float2 aparams = ShadowMap_Parameters.xy / ma;\n"
554 "       return float3(proj.xy * aparams.x + float2(proj.z < 0.0 ? 1.5 : 0.5, proj.w) * ShadowMap_Parameters.z, aparams.y + ShadowMap_Parameters.w);\n"
555 "#endif\n"
556 "}\n"
557 "#  endif\n"
558 "# endif\n"
559 "#endif // defined(USESHADOWMAP2D)\n"
560 "\n"
561 "# ifdef USESHADOWMAP2D\n"
562 "#ifdef USESHADOWMAPVSDCT\n"
563 "float ShadowMapCompare(float3 dir, sampler Texture_ShadowMap2D, float4 ShadowMap_Parameters, float2 ShadowMap_TextureScale, samplerCUBE Texture_CubeProjection)\n"
564 "#else\n"
565 "float ShadowMapCompare(float3 dir, sampler Texture_ShadowMap2D, float4 ShadowMap_Parameters, float2 ShadowMap_TextureScale)\n"
566 "#endif\n"
567 "{\n"
568 "#ifdef USESHADOWMAPVSDCT\n"
569 "       float3 shadowmaptc = GetShadowMapTC2D(dir, ShadowMap_Parameters, Texture_CubeProjection);\n"
570 "#else\n"
571 "       float3 shadowmaptc = GetShadowMapTC2D(dir, ShadowMap_Parameters);\n"
572 "#endif\n"
573 "       float f;\n"
574 "\n"
575 "#  ifdef USESHADOWSAMPLER\n"
576 "#    ifdef USESHADOWMAPPCF\n"
577 "#      define texval(x, y) tex2Dproj(Texture_ShadowMap2D, float4(center + float2(x, y)*ShadowMap_TextureScale, shadowmaptc.z, 1.0)).r  \n"
578 "       float2 center = shadowmaptc.xy*ShadowMap_TextureScale;\n"
579 "       f = dot(float4(0.25,0.25,0.25,0.25), float4(texval(-0.4, 1.0), texval(-1.0, -0.4), texval(0.4, -1.0), texval(1.0, 0.4)));\n"
580 "#    else\n"
581 "       f = tex2Dproj(Texture_ShadowMap2D, float4(shadowmaptc.xy*ShadowMap_TextureScale, shadowmaptc.z, 1.0)).r;\n"
582 "#    endif\n"
583 "#  else\n"
584 "#    ifdef USESHADOWMAPPCF\n"
585 "#     if defined(GL_ARB_texture_gather) || defined(GL_AMD_texture_texture4)\n"
586 "#      ifdef GL_ARB_texture_gather\n"
587 "#        define texval(x, y) textureGatherOffset(Texture_ShadowMap2D, center, int2(x, y))\n"
588 "#      else\n"
589 "#        define texval(x, y) texture4(Texture_ShadowMap2D, center + float2(x, y)*ShadowMap_TextureScale)\n"
590 "#      endif\n"
591 "       float2 offset = frac(shadowmaptc.xy - 0.5), center = (shadowmaptc.xy - offset)*ShadowMap_TextureScale;\n"
592 "#      if USESHADOWMAPPCF > 1\n"
593 "       float4 group1 = step(shadowmaptc.z, texval(-2.0, -2.0));\n"
594 "       float4 group2 = step(shadowmaptc.z, texval( 0.0, -2.0));\n"
595 "       float4 group3 = step(shadowmaptc.z, texval( 2.0, -2.0));\n"
596 "       float4 group4 = step(shadowmaptc.z, texval(-2.0,  0.0));\n"
597 "       float4 group5 = step(shadowmaptc.z, texval( 0.0,  0.0));\n"
598 "       float4 group6 = step(shadowmaptc.z, texval( 2.0,  0.0));\n"
599 "       float4 group7 = step(shadowmaptc.z, texval(-2.0,  2.0));\n"
600 "       float4 group8 = step(shadowmaptc.z, texval( 0.0,  2.0));\n"
601 "       float4 group9 = step(shadowmaptc.z, texval( 2.0,  2.0));\n"
602 "       float4 locols = float4(group1.ab, group3.ab);\n"
603 "       float4 hicols = float4(group7.rg, group9.rg);\n"
604 "       locols.yz += group2.ab;\n"
605 "       hicols.yz += group8.rg;\n"
606 "       float4 midcols = float4(group1.rg, group3.rg) + float4(group7.ab, group9.ab) +\n"
607 "                               float4(group4.rg, group6.rg) + float4(group4.ab, group6.ab) +\n"
608 "                               lerp(locols, hicols, offset.y);\n"
609 "       float4 cols = group5 + float4(group2.rg, group8.ab);\n"
610 "       cols.xyz += lerp(midcols.xyz, midcols.yzw, offset.x);\n"
611 "       f = dot(cols, float4(1.0/25.0));\n"
612 "#      else\n"
613 "       float4 group1 = step(shadowmaptc.z, texval(-1.0, -1.0));\n"
614 "       float4 group2 = step(shadowmaptc.z, texval( 1.0, -1.0));\n"
615 "       float4 group3 = step(shadowmaptc.z, texval(-1.0,  1.0));\n"
616 "       float4 group4 = step(shadowmaptc.z, texval( 1.0,  1.0));\n"
617 "       float4 cols = float4(group1.rg, group2.rg) + float4(group3.ab, group4.ab) +\n"
618 "                               lerp(float4(group1.ab, group2.ab), float4(group3.rg, group4.rg), offset.y);\n"
619 "       f = dot(lerp(cols.xyz, cols.yzw, offset.x), float3(1.0/9.0));\n"
620 "#      endif\n"
621 "#     else\n"
622 "#      ifdef GL_EXT_gpu_shader4\n"
623 "#        define texval(x, y) tex2DOffset(Texture_ShadowMap2D, center, int2(x, y)).r\n"
624 "#      else\n"
625 "#        define texval(x, y) texDepth2D(Texture_ShadowMap2D, center + float2(x, y)*ShadowMap_TextureScale).r  \n"
626 "#      endif\n"
627 "#      if USESHADOWMAPPCF > 1\n"
628 "       float2 center = shadowmaptc.xy - 0.5, offset = frac(center);\n"
629 "       center *= ShadowMap_TextureScale;\n"
630 "       float4 row1 = step(shadowmaptc.z, float4(texval(-1.0, -1.0), texval( 0.0, -1.0), texval( 1.0, -1.0), texval( 2.0, -1.0)));\n"
631 "       float4 row2 = step(shadowmaptc.z, float4(texval(-1.0,  0.0), texval( 0.0,  0.0), texval( 1.0,  0.0), texval( 2.0,  0.0)));\n"
632 "       float4 row3 = step(shadowmaptc.z, float4(texval(-1.0,  1.0), texval( 0.0,  1.0), texval( 1.0,  1.0), texval( 2.0,  1.0)));\n"
633 "       float4 row4 = step(shadowmaptc.z, float4(texval(-1.0,  2.0), texval( 0.0,  2.0), texval( 1.0,  2.0), texval( 2.0,  2.0)));\n"
634 "       float4 cols = row2 + row3 + lerp(row1, row4, offset.y);\n"
635 "       f = dot(lerp(cols.xyz, cols.yzw, offset.x), float3(1.0/9.0));\n"
636 "#      else\n"
637 "       float2 center = shadowmaptc.xy*ShadowMap_TextureScale, offset = frac(shadowmaptc.xy);\n"
638 "       float3 row1 = step(shadowmaptc.z, float3(texval(-1.0, -1.0), texval( 0.0, -1.0), texval( 1.0, -1.0)));\n"
639 "       float3 row2 = step(shadowmaptc.z, float3(texval(-1.0,  0.0), texval( 0.0,  0.0), texval( 1.0,  0.0)));\n"
640 "       float3 row3 = step(shadowmaptc.z, float3(texval(-1.0,  1.0), texval( 0.0,  1.0), texval( 1.0,  1.0)));\n"
641 "       float3 cols = row2 + lerp(row1, row3, offset.y);\n"
642 "       f = dot(lerp(cols.xy, cols.yz, offset.x), float2(0.25,0.25));\n"
643 "#      endif\n"
644 "#     endif\n"
645 "#    else\n"
646 "       f = step(shadowmaptc.z, tex2D(Texture_ShadowMap2D, shadowmaptc.xy*ShadowMap_TextureScale).r);\n"
647 "#    endif\n"
648 "#  endif\n"
649 "#  ifdef USESHADOWMAPORTHO\n"
650 "       return lerp(ShadowMap_Parameters.w, 1.0, f);\n"
651 "#  else\n"
652 "       return f;\n"
653 "#  endif\n"
654 "}\n"
655 "# endif\n"
656 "#endif // !defined(MODE_LIGHTSOURCE) && !defined(MODE_DEFERREDLIGHTSOURCE) && !defined(USESHADOWMAPORTHO)\n"
657 "#endif // FRAGMENT_SHADER\n"
658 "\n"
659 "\n"
660 "\n"
661 "\n"
662 "#ifdef MODE_DEFERREDGEOMETRY\n"
663 "#ifdef VERTEX_SHADER\n"
664 "void main\n"
665 "(\n"
666 "float4 gl_Vertex : POSITION,\n"
667 "uniform float4x4 ModelViewProjectionMatrix : register(c8),\n"
668 "#ifdef USEVERTEXTEXTUREBLEND\n"
669 "float4 gl_Color : COLOR0,\n"
670 "#endif\n"
671 "float4 gl_MultiTexCoord0 : TEXCOORD0,\n"
672 "float4 gl_MultiTexCoord1 : TEXCOORD1,\n"
673 "float4 gl_MultiTexCoord2 : TEXCOORD2,\n"
674 "float4 gl_MultiTexCoord3 : TEXCOORD3,\n"
675 "uniform float4x4 TexMatrix : register(c0),\n"
676 "#ifdef USEVERTEXTEXTUREBLEND\n"
677 "uniform float4x4 BackgroundTexMatrix : register(c4),\n"
678 "#endif\n"
679 "uniform float4x4 ModelViewMatrix : register(c12),\n"
680 "#ifdef USEOFFSETMAPPING\n"
681 "uniform float3 EyePosition : register(c24),\n"
682 "#endif\n"
683 "out float4 gl_Position : POSITION,\n"
684 "#ifdef USEVERTEXTEXTUREBLEND\n"
685 "out float4 gl_FrontColor : COLOR,\n"
686 "#endif\n"
687 "out float4 TexCoordBoth : TEXCOORD0,\n"
688 "#ifdef USEOFFSETMAPPING\n"
689 "out float3 EyeVector : TEXCOORD2,\n"
690 "#endif\n"
691 "out float3 VectorS : TEXCOORD5, // direction of S texcoord (sometimes crudely called tangent)\n"
692 "out float3 VectorT : TEXCOORD6, // direction of T texcoord (sometimes crudely called binormal)\n"
693 "out float4 VectorR : TEXCOORD7 // direction of R texcoord (surface normal), Depth value\n"
694 ")\n"
695 "{\n"
696 "       TexCoordBoth = mul(TexMatrix, gl_MultiTexCoord0);\n"
697 "#ifdef USEVERTEXTEXTUREBLEND\n"
698 "       gl_FrontColor = gl_Color;\n"
699 "       TexCoordBoth.zw = float2(Backgroundmul(TexMatrix, gl_MultiTexCoord0));\n"
700 "#endif\n"
701 "\n"
702 "       // transform unnormalized eye direction into tangent space\n"
703 "#ifdef USEOFFSETMAPPING\n"
704 "       float3 EyeVectorModelSpace = EyePosition - gl_Vertex.xyz;\n"
705 "       EyeVector.x = dot(EyeVectorModelSpace, gl_MultiTexCoord1.xyz);\n"
706 "       EyeVector.y = dot(EyeVectorModelSpace, gl_MultiTexCoord2.xyz);\n"
707 "       EyeVector.z = dot(EyeVectorModelSpace, gl_MultiTexCoord3.xyz);\n"
708 "#endif\n"
709 "\n"
710 "       VectorS = mul(ModelViewMatrix, float4(gl_MultiTexCoord1.xyz, 0)).xyz;\n"
711 "       VectorT = mul(ModelViewMatrix, float4(gl_MultiTexCoord2.xyz, 0)).xyz;\n"
712 "       VectorR.xyz = mul(ModelViewMatrix, float4(gl_MultiTexCoord3.xyz, 0)).xyz;\n"
713 "       gl_Position = mul(ModelViewProjectionMatrix, gl_Vertex);\n"
714 "       VectorR.w = gl_Position.z;\n"
715 "}\n"
716 "#endif // VERTEX_SHADER\n"
717 "\n"
718 "#ifdef FRAGMENT_SHADER\n"
719 "void main\n"
720 "(\n"
721 "float4 TexCoordBoth : TEXCOORD0,\n"
722 "float3 EyeVector : TEXCOORD2,\n"
723 "float3 VectorS : TEXCOORD5, // direction of S texcoord (sometimes crudely called tangent)\n"
724 "float3 VectorT : TEXCOORD6, // direction of T texcoord (sometimes crudely called binormal)\n"
725 "float4 VectorR : TEXCOORD7, // direction of R texcoord (surface normal), Depth value\n"
726 "uniform sampler Texture_Normal : register(s0),\n"
727 "#ifdef USEALPHAKILL\n"
728 "uniform sampler Texture_Color : register(s1),\n"
729 "#endif\n"
730 "uniform sampler Texture_Gloss : register(s2),\n"
731 "#ifdef USEVERTEXTEXTUREBLEND\n"
732 "uniform sampler Texture_SecondaryNormal : register(s4),\n"
733 "uniform sampler Texture_SecondaryGloss : register(s6),\n"
734 "#endif\n"
735 "#ifdef USEOFFSETMAPPING\n"
736 "uniform float4 OffsetMapping_ScaleSteps : register(c24),\n"
737 "#endif\n"
738 "uniform half SpecularPower : register(c36),\n"
739 "#ifdef HLSL\n"
740 "out float4 gl_FragData0 : COLOR0,\n"
741 "out float4 gl_FragData1 : COLOR1\n"
742 "#else\n"
743 "out float4 gl_FragColor : COLOR\n"
744 "#endif\n"
745 ")\n"
746 "{\n"
747 "       float2 TexCoord = TexCoordBoth.xy;\n"
748 "#ifdef USEOFFSETMAPPING\n"
749 "       // apply offsetmapping\n"
750 "       float2 dPdx = ddx(TexCoord);\n"
751 "       float2 dPdy = ddy(TexCoord);\n"
752 "       float2 TexCoordOffset = OffsetMapping(TexCoord, OffsetMapping_ScaleSteps, EyeVector, Texture_Normal, dPdx, dPdy);\n"
753 "# define offsetMappedTexture2D(t) tex2Dgrad(t, TexCoordOffset, dPdx, dPdy)\n"
754 "#else\n"
755 "# define offsetMappedTexture2D(t) tex2D(t, TexCoord)\n"
756 "#endif\n"
757 "\n"
758 "#ifdef USEALPHAKILL\n"
759 "       if (offsetMappedTexture2D(Texture_Color).a < 0.5)\n"
760 "               discard;\n"
761 "#endif\n"
762 "\n"
763 "#ifdef USEVERTEXTEXTUREBLEND\n"
764 "       float alpha = offsetMappedTexture2D(Texture_Color).a;\n"
765 "       float terrainblend = clamp(float(gl_FrontColor.a) * alpha * 2.0 - 0.5, float(0.0), float(1.0));\n"
766 "       //float terrainblend = min(float(gl_FrontColor.a) * alpha * 2.0, float(1.0));\n"
767 "       //float terrainblend = float(gl_FrontColor.a) * alpha > 0.5;\n"
768 "#endif\n"
769 "\n"
770 "#ifdef USEVERTEXTEXTUREBLEND\n"
771 "       float3 surfacenormal = lerp(tex2D(Texture_SecondaryNormal, TexCoord2).rgb, offsetMappedTexture2D(Texture_Normal).rgb, terrainblend) - float3(0.5, 0.5, 0.5);\n"
772 "       float a = lerp(tex2D(Texture_SecondaryGloss, TexCoord2).a, offsetMappedTexture2D(Texture_Gloss).a, terrainblend);\n"
773 "#else\n"
774 "       float3 surfacenormal = offsetMappedTexture2D(Texture_Normal).rgb - float3(0.5, 0.5, 0.5);\n"
775 "       float a = offsetMappedTexture2D(Texture_Gloss).a;\n"
776 "#endif\n"
777 "\n"
778 "#ifdef HLSL\n"
779 "       gl_FragData0 = float4(normalize(surfacenormal.x * VectorS + surfacenormal.y * VectorT + surfacenormal.z * VectorR.xyz) * 0.5 + float3(0.5, 0.5, 0.5), a);\n"
780 "       float Depth = VectorR.w / 256.0;\n"
781 "       float4 depthcolor = float4(Depth,Depth*65536.0/255.0,Depth*16777216.0/255.0,0.0);\n"
782 "//     float4 depthcolor = float4(Depth,Depth*256.0,Depth*65536.0,0.0);\n"
783 "       depthcolor.yz -= floor(depthcolor.yz);\n"
784 "       gl_FragData1 = depthcolor;\n"
785 "#else\n"
786 "       gl_FragColor = float4(normalize(surfacenormal.x * VectorS + surfacenormal.y * VectorT + surfacenormal.z * VectorR) * 0.5 + float3(0.5, 0.5, 0.5), a);\n"
787 "#endif\n"
788 "}\n"
789 "#endif // FRAGMENT_SHADER\n"
790 "#else // !MODE_DEFERREDGEOMETRY\n"
791 "\n"
792 "\n"
793 "\n"
794 "\n"
795 "#ifdef MODE_DEFERREDLIGHTSOURCE\n"
796 "#ifdef VERTEX_SHADER\n"
797 "void main\n"
798 "(\n"
799 "float4 gl_Vertex : POSITION,\n"
800 "uniform float4x4 ModelViewProjectionMatrix : register(c8),\n"
801 "uniform float4x4 ModelViewMatrix : register(c12),\n"
802 "out float4 gl_Position : POSITION,\n"
803 "out float4 ModelViewPosition : TEXCOORD0\n"
804 ")\n"
805 "{\n"
806 "       ModelViewPosition = mul(ModelViewMatrix, gl_Vertex);\n"
807 "       gl_Position = mul(ModelViewProjectionMatrix, gl_Vertex);\n"
808 "}\n"
809 "#endif // VERTEX_SHADER\n"
810 "\n"
811 "#ifdef FRAGMENT_SHADER\n"
812 "void main\n"
813 "(\n"
814 "#ifdef HLSL\n"
815 "float2 Pixel : VPOS,\n"
816 "#else\n"
817 "float2 Pixel : WPOS,\n"
818 "#endif\n"
819 "float4 ModelViewPosition : TEXCOORD0,\n"
820 "uniform float4x4 ViewToLight : register(c44),\n"
821 "uniform float2 ScreenToDepth : register(c33), // ScreenToDepth = float2(Far / (Far - Near), Far * Near / (Near - Far));\n"
822 "uniform float3 LightPosition : register(c23),\n"
823 "uniform half2 PixelToScreenTexCoord : register(c42),\n"
824 "uniform half3 DeferredColor_Ambient : register(c9),\n"
825 "uniform half3 DeferredColor_Diffuse : register(c10),\n"
826 "#ifdef USESPECULAR\n"
827 "uniform half3 DeferredColor_Specular : register(c11),\n"
828 "uniform half SpecularPower : register(c36),\n"
829 "#endif\n"
830 "uniform sampler Texture_Attenuation : register(s9),\n"
831 "uniform sampler Texture_ScreenDepth : register(s13),\n"
832 "uniform sampler Texture_ScreenNormalMap : register(s14),\n"
833 "\n"
834 "#ifdef USECUBEFILTER\n"
835 "uniform samplerCUBE Texture_Cube : register(s10),\n"
836 "#endif\n"
837 "\n"
838 "#ifdef USESHADOWMAP2D\n"
839 "# ifdef USESHADOWSAMPLER\n"
840 "uniform sampler Texture_ShadowMap2D : register(s15),\n"
841 "# else\n"
842 "uniform sampler Texture_ShadowMap2D : register(s15),\n"
843 "# endif\n"
844 "#endif\n"
845 "\n"
846 "#ifdef USESHADOWMAPVSDCT\n"
847 "uniform samplerCUBE Texture_CubeProjection : register(s12),\n"
848 "#endif\n"
849 "\n"
850 "#if defined(USESHADOWMAP2D)\n"
851 "uniform float2 ShadowMap_TextureScale : register(c35),\n"
852 "uniform float4 ShadowMap_Parameters : register(c34),\n"
853 "#endif\n"
854 "\n"
855 "out float4 gl_FragData0 : COLOR0,\n"
856 "out float4 gl_FragData1 : COLOR1\n"
857 ")\n"
858 "{\n"
859 "       // calculate viewspace pixel position\n"
860 "       float2 ScreenTexCoord = Pixel * PixelToScreenTexCoord;\n"
861 "       //ScreenTexCoord.y = ScreenTexCoord.y * -1 + 1; // Cg is opposite?\n"
862 "       float3 position;\n"
863 "#ifdef HLSL\n"
864 "       position.z = texDepth2D(Texture_ScreenDepth, ScreenTexCoord) * 256.0;\n"
865 "#else\n"
866 "       position.z = ScreenToDepth.y / (texDepth2D(Texture_ScreenDepth, ScreenTexCoord) + ScreenToDepth.x);\n"
867 "#endif\n"
868 "       position.xy = ModelViewPosition.xy * (position.z / ModelViewPosition.z);\n"
869 "       // decode viewspace pixel normal\n"
870 "       half4 normalmap = half4(tex2D(Texture_ScreenNormalMap, ScreenTexCoord));\n"
871 "       half3 surfacenormal = half3(normalize(normalmap.rgb - half3(0.5,0.5,0.5)));\n"
872 "       // surfacenormal = pixel normal in viewspace\n"
873 "       // LightVector = pixel to light in viewspace\n"
874 "       // CubeVector = position in lightspace\n"
875 "       // eyevector = pixel to view in viewspace\n"
876 "       float3 CubeVector = mul(ViewToLight, float4(position,1)).xyz;\n"
877 "       half fade = half(tex2D(Texture_Attenuation, float2(length(CubeVector), 0.0)).r);\n"
878 "#ifdef USEDIFFUSE\n"
879 "       // calculate diffuse shading\n"
880 "       half3 lightnormal = half3(normalize(LightPosition - position));\n"
881 "       half diffuse = half(max(float(dot(surfacenormal, lightnormal)), 0.0));\n"
882 "#endif\n"
883 "#ifdef USESPECULAR\n"
884 "       // calculate directional shading\n"
885 "       float3 eyevector = position * -1.0;\n"
886 "#  ifdef USEEXACTSPECULARMATH\n"
887 "       half specular = half(pow(half(max(float(dot(reflect(lightnormal, surfacenormal), normalize(eyevector)))*-1.0, 0.0)), SpecularPower * normalmap.a));\n"
888 "#  else\n"
889 "       half3 specularnormal = half3(normalize(lightnormal + half3(normalize(eyevector))));\n"
890 "       half specular = half(pow(half(max(float(dot(surfacenormal, specularnormal)), 0.0)), SpecularPower * normalmap.a));\n"
891 "#  endif\n"
892 "#endif\n"
893 "\n"
894 "#if defined(USESHADOWMAP2D)\n"
895 "       fade *= half(ShadowMapCompare(CubeVector, Texture_ShadowMap2D, ShadowMap_Parameters, ShadowMap_TextureScale\n"
896 "#ifdef USESHADOWMAPVSDCT\n"
897 ", Texture_CubeProjection\n"
898 "#endif\n"
899 "       ));\n"
900 "#endif\n"
901 "\n"
902 "#ifdef USEDIFFUSE\n"
903 "       gl_FragData0 = float4((DeferredColor_Ambient + DeferredColor_Diffuse * diffuse) * fade, 1.0);\n"
904 "#else\n"
905 "       gl_FragData0 = float4(DeferredColor_Ambient * fade, 1.0);\n"
906 "#endif\n"
907 "#ifdef USESPECULAR\n"
908 "       gl_FragData1 = float4(DeferredColor_Specular * (specular * fade), 1.0);\n"
909 "#else\n"
910 "       gl_FragData1 = float4(0.0, 0.0, 0.0, 1.0);\n"
911 "#endif\n"
912 "\n"
913 "# ifdef USECUBEFILTER\n"
914 "       float3 cubecolor = texCUBE(Texture_Cube, CubeVector).rgb;\n"
915 "       gl_FragData0.rgb *= cubecolor;\n"
916 "       gl_FragData1.rgb *= cubecolor;\n"
917 "# endif\n"
918 "}\n"
919 "#endif // FRAGMENT_SHADER\n"
920 "#else // !MODE_DEFERREDLIGHTSOURCE\n"
921 "\n"
922 "\n"
923 "\n"
924 "\n"
925 "#ifdef VERTEX_SHADER\n"
926 "void main\n"
927 "(\n"
928 "float4 gl_Vertex : POSITION,\n"
929 "uniform float4x4 ModelViewProjectionMatrix : register(c8),\n"
930 "#if defined(USEVERTEXTEXTUREBLEND) || defined(MODE_VERTEXCOLOR)\n"
931 "float4 gl_Color : COLOR0,\n"
932 "#endif\n"
933 "float4 gl_MultiTexCoord0 : TEXCOORD0,\n"
934 "float4 gl_MultiTexCoord1 : TEXCOORD1,\n"
935 "float4 gl_MultiTexCoord2 : TEXCOORD2,\n"
936 "float4 gl_MultiTexCoord3 : TEXCOORD3,\n"
937 "float4 gl_MultiTexCoord4 : TEXCOORD4,\n"
938 "\n"
939 "uniform float3 EyePosition : register(c24),\n"
940 "uniform float4x4 TexMatrix : register(c0),\n"
941 "#ifdef USEVERTEXTEXTUREBLEND\n"
942 "uniform float4x4 BackgroundTexMatrix : register(c4),\n"
943 "#endif\n"
944 "#ifdef MODE_LIGHTSOURCE\n"
945 "uniform float4x4 ModelToLight : register(c20),\n"
946 "#endif\n"
947 "#ifdef MODE_LIGHTSOURCE\n"
948 "uniform float3 LightPosition : register(c27),\n"
949 "#endif\n"
950 "#ifdef MODE_LIGHTDIRECTION\n"
951 "uniform float3 LightDir : register(c26),\n"
952 "#endif\n"
953 "uniform float4 FogPlane : register(c25),\n"
954 "#ifdef MODE_DEFERREDLIGHTSOURCE\n"
955 "uniform float3 LightPosition : register(c27),\n"
956 "#endif\n"
957 "#ifdef USESHADOWMAPORTHO\n"
958 "uniform float4x4 ShadowMapMatrix : register(c16),\n"
959 "#endif\n"
960 "#if defined(MODE_VERTEXCOLOR) || defined(USEVERTEXTEXTUREBLEND)\n"
961 "out float4 gl_FrontColor : COLOR,\n"
962 "#endif\n"
963 "out float4 TexCoordBoth : TEXCOORD0,\n"
964 "#ifdef USELIGHTMAP\n"
965 "out float2 TexCoordLightmap : TEXCOORD1,\n"
966 "#endif\n"
967 "#ifdef USEEYEVECTOR\n"
968 "out float3 EyeVector : TEXCOORD2,\n"
969 "#endif\n"
970 "#ifdef USEREFLECTION\n"
971 "out float4 ModelViewProjectionPosition : TEXCOORD3,\n"
972 "#endif\n"
973 "#ifdef USEFOG\n"
974 "out float4 EyeVectorModelSpaceFogPlaneVertexDist : TEXCOORD4,\n"
975 "#endif\n"
976 "#if defined(MODE_LIGHTDIRECTION) && defined(USEDIFFUSE) || defined(USEDIFFUSE)\n"
977 "out float3 LightVector : TEXCOORD1,\n"
978 "#endif\n"
979 "#ifdef MODE_LIGHTSOURCE\n"
980 "out float3 CubeVector : TEXCOORD3,\n"
981 "#endif\n"
982 "#if defined(MODE_LIGHTDIRECTIONMAP_MODELSPACE) || defined(MODE_DEFERREDGEOMETRY) || defined(USEREFLECTCUBE)\n"
983 "out float3 VectorS : TEXCOORD5, // direction of S texcoord (sometimes crudely called tangent)\n"
984 "out float3 VectorT : TEXCOORD6, // direction of T texcoord (sometimes crudely called binormal)\n"
985 "out float3 VectorR : TEXCOORD7, // direction of R texcoord (surface normal)\n"
986 "#endif\n"
987 "#ifdef USESHADOWMAPORTHO\n"
988 "out float3 ShadowMapTC : TEXCOORD3, // CONFLICTS WITH USEREFLECTION!\n"
989 "#endif\n"
990 "out float4 gl_Position : POSITION\n"
991 ")\n"
992 "{\n"
993 "#if defined(MODE_VERTEXCOLOR) || defined(USEVERTEXTEXTUREBLEND)\n"
994 "       gl_FrontColor = gl_Color;\n"
995 "#endif\n"
996 "       // copy the surface texcoord\n"
997 "       TexCoordBoth = mul(TexMatrix, gl_MultiTexCoord0);\n"
998 "#ifdef USEVERTEXTEXTUREBLEND\n"
999 "       TexCoordBoth.zw = mul(BackgroundTexMatrix, gl_MultiTexCoord0).xy;\n"
1000 "#endif\n"
1001 "#ifdef USELIGHTMAP\n"
1002 "       TexCoordLightmap = gl_MultiTexCoord4.xy;\n"
1003 "#endif\n"
1004 "\n"
1005 "#ifdef MODE_LIGHTSOURCE\n"
1006 "       // transform vertex position into light attenuation/cubemap space\n"
1007 "       // (-1 to +1 across the light box)\n"
1008 "       CubeVector = mul(ModelToLight, gl_Vertex).xyz;\n"
1009 "\n"
1010 "# ifdef USEDIFFUSE\n"
1011 "       // transform unnormalized light direction into tangent space\n"
1012 "       // (we use unnormalized to ensure that it interpolates correctly and then\n"
1013 "       //  normalize it per pixel)\n"
1014 "       float3 lightminusvertex = LightPosition - gl_Vertex.xyz;\n"
1015 "       LightVector.x = dot(lightminusvertex, gl_MultiTexCoord1.xyz);\n"
1016 "       LightVector.y = dot(lightminusvertex, gl_MultiTexCoord2.xyz);\n"
1017 "       LightVector.z = dot(lightminusvertex, gl_MultiTexCoord3.xyz);\n"
1018 "# endif\n"
1019 "#endif\n"
1020 "\n"
1021 "#if defined(MODE_LIGHTDIRECTION) && defined(USEDIFFUSE)\n"
1022 "       LightVector.x = dot(LightDir, gl_MultiTexCoord1.xyz);\n"
1023 "       LightVector.y = dot(LightDir, gl_MultiTexCoord2.xyz);\n"
1024 "       LightVector.z = dot(LightDir, gl_MultiTexCoord3.xyz);\n"
1025 "#endif\n"
1026 "\n"
1027 "       // transform unnormalized eye direction into tangent space\n"
1028 "#ifdef USEEYEVECTOR\n"
1029 "       float3 EyeVectorModelSpace = EyePosition - gl_Vertex.xyz;\n"
1030 "       EyeVector.x = dot(EyeVectorModelSpace, gl_MultiTexCoord1.xyz);\n"
1031 "       EyeVector.y = dot(EyeVectorModelSpace, gl_MultiTexCoord2.xyz);\n"
1032 "       EyeVector.z = dot(EyeVectorModelSpace, gl_MultiTexCoord3.xyz);\n"
1033 "#endif\n"
1034 "\n"
1035 "#ifdef USEFOG\n"
1036 "       EyeVectorModelSpaceFogPlaneVertexDist.xyz = EyePosition - gl_Vertex.xyz;\n"
1037 "       EyeVectorModelSpaceFogPlaneVertexDist.w = dot(FogPlane, gl_Vertex);\n"
1038 "#endif\n"
1039 "\n"
1040 "#ifdef MODE_LIGHTDIRECTIONMAP_MODELSPACE\n"
1041 "       VectorS = gl_MultiTexCoord1.xyz;\n"
1042 "       VectorT = gl_MultiTexCoord2.xyz;\n"
1043 "       VectorR = gl_MultiTexCoord3.xyz;\n"
1044 "#endif\n"
1045 "\n"
1046 "       // transform vertex to camera space, using ftransform to match non-VS rendering\n"
1047 "       gl_Position = mul(ModelViewProjectionMatrix, gl_Vertex);\n"
1048 "\n"
1049 "#ifdef USESHADOWMAPORTHO\n"
1050 "       ShadowMapTC = mul(ShadowMapMatrix, gl_Position).xyz;\n"
1051 "#endif\n"
1052 "\n"
1053 "#ifdef USEREFLECTION\n"
1054 "       ModelViewProjectionPosition = gl_Position;\n"
1055 "#endif\n"
1056 "}\n"
1057 "#endif // VERTEX_SHADER\n"
1058 "\n"
1059 "\n"
1060 "\n"
1061 "\n"
1062 "#ifdef FRAGMENT_SHADER\n"
1063 "void main\n"
1064 "(\n"
1065 "#ifdef USEDEFERREDLIGHTMAP\n"
1066 "#ifdef HLSL\n"
1067 "float2 Pixel : VPOS,\n"
1068 "#else\n"
1069 "float2 Pixel : WPOS,\n"
1070 "#endif\n"
1071 "#endif\n"
1072 "float4 gl_FrontColor : COLOR,\n"
1073 "float4 TexCoordBoth : TEXCOORD0,\n"
1074 "#ifdef USELIGHTMAP\n"
1075 "float2 TexCoordLightmap : TEXCOORD1,\n"
1076 "#endif\n"
1077 "#ifdef USEEYEVECTOR\n"
1078 "float3 EyeVector : TEXCOORD2,\n"
1079 "#endif\n"
1080 "#ifdef USEREFLECTION\n"
1081 "float4 ModelViewProjectionPosition : TEXCOORD3,\n"
1082 "#endif\n"
1083 "#ifdef USEFOG\n"
1084 "float4 EyeVectorModelSpaceFogPlaneVertexDist : TEXCOORD4,\n"
1085 "#endif\n"
1086 "#if defined(MODE_LIGHTSOURCE) || defined(MODE_LIGHTDIRECTION)\n"
1087 "float3 LightVector : TEXCOORD1,\n"
1088 "#endif\n"
1089 "#ifdef MODE_LIGHTSOURCE\n"
1090 "float3 CubeVector : TEXCOORD3,\n"
1091 "#endif\n"
1092 "#ifdef MODE_DEFERREDLIGHTSOURCE\n"
1093 "float4 ModelViewPosition : TEXCOORD0,\n"
1094 "#endif\n"
1095 "#if defined(MODE_LIGHTDIRECTIONMAP_MODELSPACE) || defined(MODE_DEFERREDGEOMETRY) || defined(USEREFLECTCUBE)\n"
1096 "float3 VectorS : TEXCOORD5, // direction of S texcoord (sometimes crudely called tangent)\n"
1097 "float3 VectorT : TEXCOORD6, // direction of T texcoord (sometimes crudely called binormal)\n"
1098 "float3 VectorR : TEXCOORD7, // direction of R texcoord (surface normal)\n"
1099 "#endif\n"
1100 "#ifdef USESHADOWMAPORTHO\n"
1101 "float3 ShadowMapTC : TEXCOORD3, // CONFLICTS WITH USEREFLECTION!\n"
1102 "#endif\n"
1103 "\n"
1104 "uniform sampler Texture_Normal : register(s0),\n"
1105 "uniform sampler Texture_Color : register(s1),\n"
1106 "#if defined(USESPECULAR) || defined(USEDEFERREDLIGHTMAP)\n"
1107 "uniform sampler Texture_Gloss : register(s2),\n"
1108 "#endif\n"
1109 "#ifdef USEGLOW\n"
1110 "uniform sampler Texture_Glow : register(s3),\n"
1111 "#endif\n"
1112 "#ifdef USEVERTEXTEXTUREBLEND\n"
1113 "uniform sampler Texture_SecondaryNormal : register(s4),\n"
1114 "uniform sampler Texture_SecondaryColor : register(s5),\n"
1115 "#if defined(USESPECULAR) || defined(USEDEFERREDLIGHTMAP)\n"
1116 "uniform sampler Texture_SecondaryGloss : register(s6),\n"
1117 "#endif\n"
1118 "#ifdef USEGLOW\n"
1119 "uniform sampler Texture_SecondaryGlow : register(s7),\n"
1120 "#endif\n"
1121 "#endif\n"
1122 "#ifdef USECOLORMAPPING\n"
1123 "uniform sampler Texture_Pants : register(s4),\n"
1124 "uniform sampler Texture_Shirt : register(s7),\n"
1125 "#endif\n"
1126 "#ifdef USEFOG\n"
1127 "uniform sampler Texture_FogHeightTexture : register(s14),\n"
1128 "uniform sampler Texture_FogMask : register(s8),\n"
1129 "#endif\n"
1130 "#ifdef USELIGHTMAP\n"
1131 "uniform sampler Texture_Lightmap : register(s9),\n"
1132 "#endif\n"
1133 "#if defined(MODE_LIGHTDIRECTIONMAP_MODELSPACE) || defined(MODE_LIGHTDIRECTIONMAP_TANGENTSPACE)\n"
1134 "uniform sampler Texture_Deluxemap : register(s10),\n"
1135 "#endif\n"
1136 "#ifdef USEREFLECTION\n"
1137 "uniform sampler Texture_Reflection : register(s7),\n"
1138 "#endif\n"
1139 "\n"
1140 "#ifdef MODE_DEFERREDLIGHTSOURCE\n"
1141 "uniform sampler Texture_ScreenDepth : register(s13),\n"
1142 "uniform sampler Texture_ScreenNormalMap : register(s14),\n"
1143 "#endif\n"
1144 "#ifdef USEDEFERREDLIGHTMAP\n"
1145 "uniform sampler Texture_ScreenDepth : register(s13),\n"
1146 "uniform sampler Texture_ScreenNormalMap : register(s14),\n"
1147 "uniform sampler Texture_ScreenDiffuse : register(s11),\n"
1148 "uniform sampler Texture_ScreenSpecular : register(s12),\n"
1149 "#endif\n"
1150 "\n"
1151 "#ifdef USECOLORMAPPING\n"
1152 "uniform half3 Color_Pants : register(c7),\n"
1153 "uniform half3 Color_Shirt : register(c8),\n"
1154 "#endif\n"
1155 "#ifdef USEFOG\n"
1156 "uniform float3 FogColor : register(c16),\n"
1157 "uniform float FogRangeRecip : register(c20),\n"
1158 "uniform float FogPlaneViewDist : register(c19),\n"
1159 "uniform float FogHeightFade : register(c17),\n"
1160 "#endif\n"
1161 "\n"
1162 "#ifdef USEOFFSETMAPPING\n"
1163 "uniform float4 OffsetMapping_ScaleSteps : register(c24),\n"
1164 "#endif\n"
1165 "\n"
1166 "#ifdef USEDEFERREDLIGHTMAP\n"
1167 "uniform half2 PixelToScreenTexCoord : register(c42),\n"
1168 "uniform half3 DeferredMod_Diffuse : register(c12),\n"
1169 "uniform half3 DeferredMod_Specular : register(c13),\n"
1170 "#endif\n"
1171 "uniform half3 Color_Ambient : register(c3),\n"
1172 "uniform half3 Color_Diffuse : register(c4),\n"
1173 "uniform half3 Color_Specular : register(c5),\n"
1174 "uniform half SpecularPower : register(c36),\n"
1175 "#ifdef USEGLOW\n"
1176 "uniform half3 Color_Glow : register(c6),\n"
1177 "#endif\n"
1178 "uniform half Alpha : register(c0),\n"
1179 "#ifdef USEREFLECTION\n"
1180 "uniform float4 DistortScaleRefractReflect : register(c14),\n"
1181 "uniform float4 ScreenScaleRefractReflect : register(c32),\n"
1182 "uniform float4 ScreenCenterRefractReflect : register(c31),\n"
1183 "uniform half4 ReflectColor : register(c26),\n"
1184 "#endif\n"
1185 "#ifdef USEREFLECTCUBE\n"
1186 "uniform float4x4 ModelToReflectCube : register(c48),\n"
1187 "uniform sampler Texture_ReflectMask : register(s5),\n"
1188 "uniform samplerCUBE Texture_ReflectCube : register(s6),\n"
1189 "#endif\n"
1190 "#ifdef MODE_LIGHTDIRECTION\n"
1191 "uniform half3 LightColor : register(c21),\n"
1192 "#endif\n"
1193 "#ifdef MODE_LIGHTSOURCE\n"
1194 "uniform half3 LightColor : register(c21),\n"
1195 "#endif\n"
1196 "\n"
1197 "#if defined(MODE_LIGHTSOURCE) || defined(MODE_DEFERREDLIGHTSOURCE)\n"
1198 "uniform sampler Texture_Attenuation : register(s9),\n"
1199 "uniform samplerCUBE Texture_Cube : register(s10),\n"
1200 "#endif\n"
1201 "\n"
1202 "#if defined(MODE_LIGHTSOURCE) || defined(MODE_DEFERREDLIGHTSOURCE) || defined(USESHADOWMAPORTHO)\n"
1203 "\n"
1204 "#ifdef USESHADOWMAP2D\n"
1205 "# ifdef USESHADOWSAMPLER\n"
1206 "uniform sampler Texture_ShadowMap2D : register(s15),\n"
1207 "# else\n"
1208 "uniform sampler Texture_ShadowMap2D : register(s15),\n"
1209 "# endif\n"
1210 "#endif\n"
1211 "\n"
1212 "#ifdef USESHADOWMAPVSDCT\n"
1213 "uniform samplerCUBE Texture_CubeProjection : register(s12),\n"
1214 "#endif\n"
1215 "\n"
1216 "#if defined(USESHADOWMAP2D)\n"
1217 "uniform float2 ShadowMap_TextureScale : register(c35),\n"
1218 "uniform float4 ShadowMap_Parameters : register(c34),\n"
1219 "#endif\n"
1220 "#endif // !defined(MODE_LIGHTSOURCE) && !defined(MODE_DEFERREDLIGHTSOURCE) && !defined(USESHADOWMAPORTHO)\n"
1221 "\n"
1222 "out float4 gl_FragColor : COLOR\n"
1223 ")\n"
1224 "{\n"
1225 "       float2 TexCoord = TexCoordBoth.xy;\n"
1226 "#ifdef USEVERTEXTEXTUREBLEND\n"
1227 "       float2 TexCoord2 = TexCoordBoth.zw;\n"
1228 "#endif\n"
1229 "#ifdef USEOFFSETMAPPING\n"
1230 "       // apply offsetmapping\n"
1231 "       float2 dPdx = ddx(TexCoord);\n"
1232 "       float2 dPdy = ddy(TexCoord);\n"
1233 "       float2 TexCoordOffset = OffsetMapping(TexCoord, OffsetMapping_ScaleSteps, EyeVector, Texture_Normal, dPdx, dPdy);\n"
1234 "# define offsetMappedTexture2D(t) tex2Dgrad(t, TexCoordOffset, dPdx, dPdy)\n"
1235 "#else\n"
1236 "# define offsetMappedTexture2D(t) tex2D(t, TexCoord)\n"
1237 "#endif\n"
1238 "\n"
1239 "       // combine the diffuse textures (base, pants, shirt)\n"
1240 "       half4 color = half4(offsetMappedTexture2D(Texture_Color));\n"
1241 "#ifdef USEALPHAKILL\n"
1242 "       if (color.a < 0.5)\n"
1243 "               discard;\n"
1244 "#endif\n"
1245 "       color.a *= Alpha;\n"
1246 "#ifdef USECOLORMAPPING\n"
1247 "       color.rgb += half3(offsetMappedTexture2D(Texture_Pants).rgb) * Color_Pants + half3(offsetMappedTexture2D(Texture_Shirt).rgb) * Color_Shirt;\n"
1248 "#endif\n"
1249 "#ifdef USEVERTEXTEXTUREBLEND\n"
1250 "#ifdef USEBOTHALPHAS\n"
1251 "       half4 color2 = half4(tex2D(Texture_SecondaryColor, TexCoord2));\n"
1252 "       half terrainblend = clamp(half(gl_FrontColor.a) * color.a, half(1.0 - color2.a), half(1.0));\n"
1253 "       color.rgb = lerp(color2.rgb, color.rgb, terrainblend);\n"
1254 "#else\n"
1255 "       half terrainblend = clamp(half(gl_FrontColor.a) * color.a * 2.0 - 0.5, half(0.0), half(1.0));\n"
1256 "       //half terrainblend = min(half(gl_FrontColor.a) * color.a * 2.0, half(1.0));\n"
1257 "       //half terrainblend = half(gl_FrontColor.a) * color.a > 0.5;\n"
1258 "       color.rgb = half3(lerp(tex2D(Texture_SecondaryColor, TexCoord2).rgb, float3(color.rgb), terrainblend));\n"
1259 "       color.a = 1.0;\n"
1260 "       //color = half4(lerp(float4(1, 0, 0, 1), color, terrainblend));\n"
1261 "#endif\n"
1262 "#endif\n"
1263 "\n"
1264 "       // get the surface normal\n"
1265 "#ifdef USEVERTEXTEXTUREBLEND\n"
1266 "       half3 surfacenormal = normalize(half3(lerp(tex2D(Texture_SecondaryNormal, TexCoord2).rgb, offsetMappedTexture2D(Texture_Normal).rgb, terrainblend)) - half3(0.5, 0.5, 0.5));\n"
1267 "#else\n"
1268 "       half3 surfacenormal = half3(normalize(half3(offsetMappedTexture2D(Texture_Normal).rgb) - half3(0.5, 0.5, 0.5)));\n"
1269 "#endif\n"
1270 "\n"
1271 "       // get the material colors\n"
1272 "       half3 diffusetex = color.rgb;\n"
1273 "#if defined(USESPECULAR) || defined(USEDEFERREDLIGHTMAP)\n"
1274 "# ifdef USEVERTEXTEXTUREBLEND\n"
1275 "       half4 glosstex = half4(lerp(tex2D(Texture_SecondaryGloss, TexCoord2), offsetMappedTexture2D(Texture_Gloss), terrainblend));\n"
1276 "# else\n"
1277 "       half4 glosstex = half4(offsetMappedTexture2D(Texture_Gloss));\n"
1278 "# endif\n"
1279 "#endif\n"
1280 "\n"
1281 "#ifdef USEREFLECTCUBE\n"
1282 "       float3 TangentReflectVector = reflect(-EyeVector, surfacenormal);\n"
1283 "       float3 ModelReflectVector = TangentReflectVector.x * VectorS + TangentReflectVector.y * VectorT + TangentReflectVector.z * VectorR;\n"
1284 "       float3 ReflectCubeTexCoord = mul(ModelToReflectCube, float4(ModelReflectVector, 0)).xyz;\n"
1285 "       diffusetex += half3(offsetMappedTexture2D(Texture_ReflectMask).rgb) * half3(texCUBE(Texture_ReflectCube, ReflectCubeTexCoord).rgb);\n"
1286 "#endif\n"
1287 "\n"
1288 "\n"
1289 "\n"
1290 "\n"
1291 "#ifdef MODE_LIGHTSOURCE\n"
1292 "       // light source\n"
1293 "#ifdef USEDIFFUSE\n"
1294 "       half3 lightnormal = half3(normalize(LightVector));\n"
1295 "       half diffuse = half(max(float(dot(surfacenormal, lightnormal)), 0.0));\n"
1296 "       color.rgb = diffusetex * (Color_Ambient + diffuse * Color_Diffuse);\n"
1297 "#ifdef USESPECULAR\n"
1298 "#ifdef USEEXACTSPECULARMATH\n"
1299 "       half specular = half(pow(half(max(float(dot(reflect(lightnormal, surfacenormal), normalize(EyeVector)))*-1.0, 0.0)), SpecularPower * glosstex.a));\n"
1300 "#else\n"
1301 "       half3 specularnormal = half3(normalize(lightnormal + half3(normalize(EyeVector))));\n"
1302 "       half specular = half(pow(half(max(float(dot(surfacenormal, specularnormal)), 0.0)), SpecularPower * glosstex.a));\n"
1303 "#endif\n"
1304 "       color.rgb += glosstex.rgb * (specular * Color_Specular);\n"
1305 "#endif\n"
1306 "#else\n"
1307 "       color.rgb = diffusetex * Color_Ambient;\n"
1308 "#endif\n"
1309 "       color.rgb *= LightColor;\n"
1310 "       color.rgb *= half(tex2D(Texture_Attenuation, float2(length(CubeVector), 0.0)).r);\n"
1311 "#if defined(USESHADOWMAP2D)\n"
1312 "       color.rgb *= half(ShadowMapCompare(CubeVector, Texture_ShadowMap2D, ShadowMap_Parameters, ShadowMap_TextureScale\n"
1313 "#ifdef USESHADOWMAPVSDCT\n"
1314 ", Texture_CubeProjection\n"
1315 "#endif\n"
1316 "       ));\n"
1317 "\n"
1318 "#endif\n"
1319 "# ifdef USECUBEFILTER\n"
1320 "       color.rgb *= half3(texCUBE(Texture_Cube, CubeVector).rgb);\n"
1321 "# endif\n"
1322 "\n"
1323 "#ifdef USESHADOWMAP2D\n"
1324 "#ifdef USESHADOWMAPVSDCT\n"
1325 "//     float3 shadowmaptc = GetShadowMapTC2D(CubeVector, ShadowMap_Parameters, Texture_CubeProjection);\n"
1326 "#else\n"
1327 "//     float3 shadowmaptc = GetShadowMapTC2D(CubeVector, ShadowMap_Parameters);\n"
1328 "#endif\n"
1329 "//     color.rgb = half3(tex2D(Texture_ShadowMap2D, float2(0.1,0.1)).rgb);\n"
1330 "//     color.rgb = half3(tex2D(Texture_ShadowMap2D, shadowmaptc.xy * ShadowMap_TextureScale).rgb);\n"
1331 "//     color.rgb = half3(shadowmaptc.xyz * float3(ShadowMap_TextureScale,1.0));\n"
1332 "//     color.r = half(texDepth2D(Texture_ShadowMap2D, shadowmaptc.xy * ShadowMap_TextureScale));\n"
1333 "//     color.rgb = half3(tex2D(Texture_ShadowMap2D, float2(0.1,0.1)).rgb);\n"
1334 "//     color.rgb = half3(tex2D(Texture_ShadowMap2D, shadowmaptc.xy * ShadowMap_TextureScale).rgb);\n"
1335 "//     color.rgb = half3(shadowmaptc.xyz * float3(ShadowMap_TextureScale,1.0));\n"
1336 "//     color.r = half(texDepth2D(Texture_ShadowMap2D, shadowmaptc.xy * ShadowMap_TextureScale));\n"
1337 "//     color.r = half(shadowmaptc.z - texDepth2D(Texture_ShadowMap2D, shadowmaptc.xy * ShadowMap_TextureScale));\n"
1338 "//     color.r = half(shadowmaptc.z);\n"
1339 "//     color.r = half(texDepth2D(Texture_ShadowMap2D, shadowmaptc.xy * ShadowMap_TextureScale));\n"
1340 "//     color.r = half(shadowmaptc.z);\n"
1341 "//     color.r = 1;\n"
1342 "//     color.rgb = abs(CubeVector);\n"
1343 "#endif\n"
1344 "//     color.rgb = half3(1,1,1);\n"
1345 "#endif // MODE_LIGHTSOURCE\n"
1346 "\n"
1347 "\n"
1348 "\n"
1349 "\n"
1350 "#ifdef MODE_LIGHTDIRECTION\n"
1351 "#define SHADING\n"
1352 "#ifdef USEDIFFUSE\n"
1353 "       half3 lightnormal = half3(normalize(LightVector));\n"
1354 "#endif\n"
1355 "#define lightcolor LightColor\n"
1356 "#endif // MODE_LIGHTDIRECTION\n"
1357 "#ifdef MODE_LIGHTDIRECTIONMAP_MODELSPACE\n"
1358 "#define SHADING\n"
1359 "       // deluxemap lightmapping using light vectors in modelspace (q3map2 -light -deluxe)\n"
1360 "       half3 lightnormal_modelspace = half3(tex2D(Texture_Deluxemap, TexCoordLightmap).rgb) * 2.0 + half3(-1.0, -1.0, -1.0);\n"
1361 "       half3 lightcolor = half3(tex2D(Texture_Lightmap, TexCoordLightmap).rgb);\n"
1362 "       // convert modelspace light vector to tangentspace\n"
1363 "       half3 lightnormal;\n"
1364 "       lightnormal.x = dot(lightnormal_modelspace, half3(VectorS));\n"
1365 "       lightnormal.y = dot(lightnormal_modelspace, half3(VectorT));\n"
1366 "       lightnormal.z = dot(lightnormal_modelspace, half3(VectorR));\n"
1367 "       // calculate directional shading (and undoing the existing angle attenuation on the lightmap by the division)\n"
1368 "       // note that q3map2 is too stupid to calculate proper surface normals when q3map_nonplanar\n"
1369 "       // is used (the lightmap and deluxemap coords correspond to virtually random coordinates\n"
1370 "       // on that luxel, and NOT to its center, because recursive triangle subdivision is used\n"
1371 "       // to map the luxels to coordinates on the draw surfaces), which also causes\n"
1372 "       // deluxemaps to be wrong because light contributions from the wrong side of the surface\n"
1373 "       // are added up. To prevent divisions by zero or strong exaggerations, a max()\n"
1374 "       // nudge is done here at expense of some additional fps. This is ONLY needed for\n"
1375 "       // deluxemaps, tangentspace deluxemap avoid this problem by design.\n"
1376 "       lightcolor *= 1.0 / max(0.25, lightnormal.z);\n"
1377 "#endif // MODE_LIGHTDIRECTIONMAP_MODELSPACE\n"
1378 "#ifdef MODE_LIGHTDIRECTIONMAP_TANGENTSPACE\n"
1379 "#define SHADING\n"
1380 "       // deluxemap lightmapping using light vectors in tangentspace (hmap2 -light)\n"
1381 "       half3 lightnormal = half3(tex2D(Texture_Deluxemap, TexCoordLightmap).rgb) * 2.0 + half3(-1.0, -1.0, -1.0);\n"
1382 "       half3 lightcolor = half3(tex2D(Texture_Lightmap, TexCoordLightmap).rgb);\n"
1383 "#endif\n"
1384 "\n"
1385 "\n"
1386 "\n"
1387 "\n"
1388 "#ifdef MODE_FAKELIGHT\n"
1389 "#define SHADING\n"
1390 "half3 lightnormal = half3(normalize(EyeVector));\n"
1391 "half3 lightcolor = half3(1.0,1.0,1.0);\n"
1392 "#endif // MODE_FAKELIGHT\n"
1393 "\n"
1394 "\n"
1395 "\n"
1396 "\n"
1397 "#ifdef MODE_LIGHTMAP\n"
1398 "       color.rgb = diffusetex * (Color_Ambient + half3(tex2D(Texture_Lightmap, TexCoordLightmap).rgb) * Color_Diffuse);\n"
1399 "#endif // MODE_LIGHTMAP\n"
1400 "#ifdef MODE_VERTEXCOLOR\n"
1401 "       color.rgb = diffusetex * (Color_Ambient + half3(gl_FrontColor.rgb) * Color_Diffuse);\n"
1402 "#endif // MODE_VERTEXCOLOR\n"
1403 "#ifdef MODE_FLATCOLOR\n"
1404 "       color.rgb = diffusetex * Color_Ambient;\n"
1405 "#endif // MODE_FLATCOLOR\n"
1406 "\n"
1407 "\n"
1408 "\n"
1409 "\n"
1410 "#ifdef SHADING\n"
1411 "# ifdef USEDIFFUSE\n"
1412 "       half diffuse = half(max(float(dot(surfacenormal, lightnormal)), 0.0));\n"
1413 "#  ifdef USESPECULAR\n"
1414 "#   ifdef USEEXACTSPECULARMATH\n"
1415 "       half specular = half(pow(half(max(float(dot(reflect(lightnormal, surfacenormal), normalize(EyeVector)))*-1.0, 0.0)), SpecularPower * glosstex.a));\n"
1416 "#   else\n"
1417 "       half3 specularnormal = half3(normalize(lightnormal + half3(normalize(EyeVector))));\n"
1418 "       half specular = half(pow(half(max(float(dot(surfacenormal, specularnormal)), 0.0)), SpecularPower * glosstex.a));\n"
1419 "#   endif\n"
1420 "       color.rgb = diffusetex * Color_Ambient + (diffusetex * Color_Diffuse * diffuse + glosstex.rgb * Color_Specular * specular) * lightcolor;\n"
1421 "#  else\n"
1422 "       color.rgb = diffusetex * (Color_Ambient + Color_Diffuse * diffuse * lightcolor);\n"
1423 "#  endif\n"
1424 "# else\n"
1425 "       color.rgb = diffusetex * Color_Ambient;\n"
1426 "# endif\n"
1427 "#endif\n"
1428 "\n"
1429 "#ifdef USESHADOWMAPORTHO\n"
1430 "       color.rgb *= half(ShadowMapCompare(ShadowMapTC, Texture_ShadowMap2D, ShadowMap_Parameters, ShadowMap_TextureScale));\n"
1431 "#endif\n"
1432 "\n"
1433 "#ifdef USEDEFERREDLIGHTMAP\n"
1434 "       float2 ScreenTexCoord = Pixel * PixelToScreenTexCoord;\n"
1435 "       color.rgb += diffusetex * half3(tex2D(Texture_ScreenDiffuse, ScreenTexCoord).rgb) * DeferredMod_Diffuse;\n"
1436 "       color.rgb += glosstex.rgb * half3(tex2D(Texture_ScreenSpecular, ScreenTexCoord).rgb) * DeferredMod_Specular;\n"
1437 "//     color.rgb = half3(tex2D(Texture_ScreenDepth, ScreenTexCoord).rgb);\n"
1438 "//     color.r = half(texDepth2D(Texture_ScreenDepth, ScreenTexCoord)) * 1.0;\n"
1439 "#endif\n"
1440 "\n"
1441 "#ifdef USEGLOW\n"
1442 "#ifdef USEVERTEXTEXTUREBLEND\n"
1443 "       color.rgb += half3(lerp(tex2D(Texture_SecondaryGlow, TexCoord2).rgb, offsetMappedTexture2D(Texture_Glow).rgb, terrainblend)) * Color_Glow;\n"
1444 "#else\n"
1445 "       color.rgb += half3(offsetMappedTexture2D(Texture_Glow).rgb) * Color_Glow;\n"
1446 "#endif\n"
1447 "#endif\n"
1448 "\n"
1449 "#ifdef USEFOG\n"
1450 "       color.rgb = half3(FogVertex(color, FogColor, EyeVectorModelSpaceFogPlaneVertexDist.xyz, EyeVectorModelSpaceFogPlaneVertexDist.w, FogRangeRecip, FogPlaneViewDist, FogHeightFade, Texture_FogMask, Texture_FogHeightTexture));\n"
1451 "#endif\n"
1452 "\n"
1453 "       // reflection must come last because it already contains exactly the correct fog (the reflection render preserves camera distance from the plane, it only flips the side) and ContrastBoost/SceneBrightness\n"
1454 "#ifdef USEREFLECTION\n"
1455 "       float4 ScreenScaleRefractReflectIW = ScreenScaleRefractReflect * (1.0 / ModelViewProjectionPosition.w);\n"
1456 "       //float4 ScreenTexCoord = (ModelViewProjectionPosition.xyxy + normalize(half3(offsetMappedTexture2D(Texture_Normal).rgb) - half3(0.5,0.5,0.5)).xyxy * DistortScaleRefractReflect * 100) * ScreenScaleRefractReflectIW + ScreenCenterRefractReflect;\n"
1457 "       float2 SafeScreenTexCoord = ModelViewProjectionPosition.xy * ScreenScaleRefractReflectIW.zw + ScreenCenterRefractReflect.zw;\n"
1458 "       float2 ScreenTexCoord = SafeScreenTexCoord + float3(normalize(half3(offsetMappedTexture2D(Texture_Normal).rgb) - half3(0.5,0.5,0.5))).xy * DistortScaleRefractReflect.zw;\n"
1459 "       // FIXME temporary hack to detect the case that the reflection\n"
1460 "       // gets blackened at edges due to leaving the area that contains actual\n"
1461 "       // content.\n"
1462 "       // Remove this 'ack once we have a better way to stop this thing from\n"
1463 "       // 'appening.\n"
1464 "       float f = min(1.0, length(tex2D(Texture_Reflection, ScreenTexCoord + float2(0.01, 0.01)).rgb) / 0.05);\n"
1465 "       f      *= min(1.0, length(tex2D(Texture_Reflection, ScreenTexCoord + float2(0.01, -0.01)).rgb) / 0.05);\n"
1466 "       f      *= min(1.0, length(tex2D(Texture_Reflection, ScreenTexCoord + float2(-0.01, 0.01)).rgb) / 0.05);\n"
1467 "       f      *= min(1.0, length(tex2D(Texture_Reflection, ScreenTexCoord + float2(-0.01, -0.01)).rgb) / 0.05);\n"
1468 "       ScreenTexCoord = lerp(SafeScreenTexCoord, ScreenTexCoord, f);\n"
1469 "       color.rgb = lerp(color.rgb, half3(tex2D(Texture_Reflection, ScreenTexCoord).rgb) * ReflectColor.rgb, ReflectColor.a);\n"
1470 "#endif\n"
1471 "\n"
1472 "       gl_FragColor = float4(color);\n"
1473 "}\n"
1474 "#endif // FRAGMENT_SHADER\n"
1475 "\n"
1476 "#endif // !MODE_DEFERREDLIGHTSOURCE\n"
1477 "#endif // !MODE_DEFERREDGEOMETRY\n"
1478 "#endif // !MODE_WATER\n"
1479 "#endif // !MODE_REFRACTION\n"
1480 "#endif // !MODE_BLOOMBLUR\n"
1481 "#endif // !MODE_GENERIC\n"
1482 "#endif // !MODE_POSTPROCESS\n"
1483 "#endif // !MODE_SHOWDEPTH\n"
1484 "#endif // !MODE_DEPTH_OR_SHADOW\n"