"#ifdef USEGAMMARAMPS\n"
"uniform sampler Texture_GammaRamps : register(s2),\n"
"#endif\n"
+"uniform half Alpha : register(c0),\n"
"out float4 dp_FragColor : COLOR\n"
")\n"
"{\n"
" dp_FragColor.g = tex2D(Texture_GammaRamps, vec2(dp_FragColor.g, 0)).g;\n"
" dp_FragColor.b = tex2D(Texture_GammaRamps, vec2(dp_FragColor.b, 0)).b;\n"
"#endif\n"
+"#ifdef USEALPHAKILL\n"
+" dp_FragColor.a *= Alpha;\n"
+"#endif\n"
"}\n"
"#endif\n"
"#else // !MODE_GENERIC\n"
"(\n"
"float4 gl_Vertex : POSITION,\n"
"uniform float4x4 ModelViewProjectionMatrix : register(c8),\n"
+"#ifdef USEALPHAGENVERTEX\n"
+"float4 gl_Color : COLOR0,\n"
+"#endif\n"
"float4 gl_MultiTexCoord0 : TEXCOORD0,\n"
"uniform float4x4 TexMatrix : register(c0),\n"
"uniform float3 EyePosition : register(c24),\n"
+"#ifdef USEALPHAGENVERTEX\n"
+"out float4 gl_FrontColor : COLOR,\n"
+"#endif\n"
"out float4 gl_Position : POSITION,\n"
"out float2 TexCoord : TEXCOORD0,\n"
"out float3 EyeVector : TEXCOORD1,\n"
"out float4 ModelViewProjectionPosition : TEXCOORD2\n"
")\n"
"{\n"
+"#ifdef USEALPHAGENVERTEX\n"
+" gl_FrontColor = gl_Color;\n"
+"#endif\n"
" TexCoord = mul(TexMatrix, gl_MultiTexCoord0).xy;\n"
" gl_Position = mul(ModelViewProjectionMatrix, gl_Vertex);\n"
" ModelViewProjectionPosition = gl_Position;\n"
"#ifdef FRAGMENT_SHADER\n"
"void main\n"
"(\n"
+"#ifdef USEALPHAGENVERTEX\n"
+"float4 gl_FrontColor : COLOR,\n"
+"#endif\n"
"float2 TexCoord : TEXCOORD0,\n"
"float3 EyeVector : TEXCOORD1,\n"
"float4 ModelViewProjectionPosition : TEXCOORD2,\n"
" float2 ScreenScaleRefractReflectIW = ScreenScaleRefractReflect.xy * (1.0 / ModelViewProjectionPosition.w);\n"
" //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"
" float2 SafeScreenTexCoord = ModelViewProjectionPosition.xy * ScreenScaleRefractReflectIW + ScreenCenterRefractReflect.xy;\n"
-" float2 ScreenTexCoord = SafeScreenTexCoord + normalize(tex2D(Texture_Normal, TexCoord).rgb - float3(0.5,0.5,0.5)).xy * DistortScaleRefractReflect.xy;\n"
+"#ifdef USEALPHAGENVERTEX\n"
+" float2 distort = DistortScaleRefractReflect.xy * gl_FrontColor.a;\n"
+" float4 refractcolor = mix(RefractColor, vec4(1.0, 1.0, 1.0, 1.0), gl_FrontColor.a);\n"
+"#else\n"
+" float2 distort = DistortScaleRefractReflect.xy;\n"
+" float4 refractcolor = RefractColor;\n"
+"#endif\n"
+" float2 ScreenTexCoord = SafeScreenTexCoord + normalize(tex2D(Texture_Normal, TexCoord).rgb - float3(0.5,0.5,0.5)).xy * distort;\n"
" // FIXME temporary hack to detect the case that the reflection\n"
" // gets blackened at edges due to leaving the area that contains actual\n"
" // content.\n"
" f *= min(1.0, length(tex2D(Texture_Refraction, ScreenTexCoord + float2(-0.01, 0.01)).rgb) / 0.05);\n"
" f *= min(1.0, length(tex2D(Texture_Refraction, ScreenTexCoord + float2(-0.01, -0.01)).rgb) / 0.05);\n"
" ScreenTexCoord = lerp(SafeScreenTexCoord, ScreenTexCoord, f);\n"
-" dp_FragColor = float4(tex2D(Texture_Refraction, ScreenTexCoord).rgb, 1) * RefractColor;\n"
+" dp_FragColor = float4(tex2D(Texture_Refraction, ScreenTexCoord).rgb, 1) * refractcolor;\n"
"}\n"
"#endif\n"
"#else // !MODE_REFRACTION\n"
"(\n"
"float4 gl_Vertex : POSITION,\n"
"uniform float4x4 ModelViewProjectionMatrix : register(c8),\n"
+"#ifdef USEALPHAGENVERTEX\n"
+"float4 gl_Color : COLOR0,\n"
+"#endif\n"
"float4 gl_MultiTexCoord0 : TEXCOORD0,\n"
"float4 gl_MultiTexCoord1 : TEXCOORD1,\n"
"float4 gl_MultiTexCoord2 : TEXCOORD2,\n"
"float4 gl_MultiTexCoord3 : TEXCOORD3,\n"
"uniform float4x4 TexMatrix : register(c0),\n"
"uniform float3 EyePosition : register(c24),\n"
+"#ifdef USEALPHAGENVERTEX\n"
+"out float4 gl_FrontColor : COLOR,\n"
+"#endif\n"
"out float4 gl_Position : POSITION,\n"
"out float2 TexCoord : TEXCOORD0,\n"
"out float3 EyeVector : TEXCOORD1,\n"
"out float4 ModelViewProjectionPosition : TEXCOORD2\n"
")\n"
"{\n"
+"#ifdef USEALPHAGENVERTEX\n"
+" gl_FrontColor = gl_Color;\n"
+"#endif\n"
" TexCoord = mul(TexMatrix, gl_MultiTexCoord0).xy;\n"
" float3 EyeVectorModelSpace = EyePosition - gl_Vertex.xyz;\n"
" EyeVector = float3(dot(EyeVectorModelSpace, gl_MultiTexCoord1.xyz), dot(EyeVectorModelSpace, gl_MultiTexCoord2.xyz), dot(EyeVectorModelSpace, gl_MultiTexCoord3.xyz));\n"
"#ifdef FRAGMENT_SHADER\n"
"void main\n"
"(\n"
+"#ifdef USEALPHAGENVERTEX\n"
+"float4 gl_FrontColor : COLOR,\n"
+"#endif\n"
"float2 TexCoord : TEXCOORD0,\n"
"float3 EyeVector : TEXCOORD1,\n"
"float4 ModelViewProjectionPosition : TEXCOORD2,\n"
" //float4 ScreenTexCoord = (ModelViewProjectionPosition.xyxy + normalize(tex2D(Texture_Normal, TexCoord).rgb - float3(0.5,0.5,0.5)).xyxy * DistortScaleRefractReflect * 100) * ScreenScaleRefractReflectIW + ScreenCenterRefractReflect;\n"
" float4 SafeScreenTexCoord = ModelViewProjectionPosition.xyxy * ScreenScaleRefractReflectIW + ScreenCenterRefractReflect;\n"
" //SafeScreenTexCoord = gl_FragCoord.xyxy * float4(1.0 / 1920.0, 1.0 / 1200.0, 1.0 / 1920.0, 1.0 / 1200.0);\n"
-" float4 ScreenTexCoord = SafeScreenTexCoord + float2(normalize(tex2D(Texture_Normal, TexCoord).rgb - float3(0.5,0.5,0.5)).xy).xyxy * DistortScaleRefractReflect;\n"
+"#ifdef USEALPHAGENVERTEX\n"
+" float4 distort = DistortScaleRefractReflect * gl_FrontColor.a;\n"
+" float reflectoffset = ReflectOffset * gl_FrontColor.a;\n"
+" float reflectfactor = ReflectFactor * gl_FrontColor.a;\n"
+" float4 refractcolor = mix(RefractColor, vec4(1.0, 1.0, 1.0, 1.0), gl_FrontColor.a);\n"
+"#else\n"
+" float4 distort = DistortScaleRefractReflect;\n"
+" float reflectoffset = ReflectOffset;\n"
+" float reflectfactor = ReflectFactor;\n"
+" float4 refractcolor = RefractColor;\n"
+"#endif\n"
+" float4 ScreenTexCoord = SafeScreenTexCoord + float2(normalize(tex2D(Texture_Normal, TexCoord).rgb - float3(0.5,0.5,0.5)).xy).xyxy * distort;\n"
" // FIXME temporary hack to detect the case that the reflection\n"
" // gets blackened at edges due to leaving the area that contains actual\n"
" // content.\n"
" f *= min(1.0, length(tex2D(Texture_Reflection, ScreenTexCoord.zw + float2(-0.01, 0.01)).rgb) / 0.05);\n"
" f *= min(1.0, length(tex2D(Texture_Reflection, ScreenTexCoord.zw + float2(-0.01, -0.01)).rgb) / 0.05);\n"
" ScreenTexCoord.zw = lerp(SafeScreenTexCoord.zw, ScreenTexCoord.zw, f);\n"
-" float Fresnel = pow(min(1.0, 1.0 - float(normalize(EyeVector).z)), 2.0) * ReflectFactor + ReflectOffset;\n"
-" dp_FragColor = lerp(float4(tex2D(Texture_Refraction, ScreenTexCoord.xy).rgb, 1) * RefractColor, float4(tex2D(Texture_Reflection, ScreenTexCoord.zw).rgb, 1) * ReflectColor, Fresnel);\n"
+" float Fresnel = pow(min(1.0, 1.0 - float(normalize(EyeVector).z)), 2.0) * reflectfactor + reflectoffset;\n"
+" dp_FragColor = lerp(float4(tex2D(Texture_Refraction, ScreenTexCoord.xy).rgb, 1) * refractcolor, float4(tex2D(Texture_Reflection, ScreenTexCoord.zw).rgb, 1) * ReflectColor, Fresnel);\n"
"}\n"
"#endif\n"
"#else // !MODE_WATER\n"
" float i;\n"
" // distance-based LOD\n"
"#ifdef USEOFFSETMAPPING_LOD\n"
-" float LODFactor = min(1.0, OffsetMapping_LodDistance / EyeVectorFogDepth.z);\n"
-" mediump vec4 ScaleSteps = float4(OffsetMapping_ScaleSteps.x, OffsetMapping_ScaleSteps.y * LODFactor, OffsetMapping_ScaleSteps.z / LODFactor, OffsetMapping_ScaleSteps.w * LODFactor);\n"
+" //float LODFactor = min(1.0, OffsetMapping_LodDistance / EyeVectorFogDepth.z);\n"
+" //float4 ScaleSteps = float4(OffsetMapping_ScaleSteps.x, OffsetMapping_ScaleSteps.y * LODFactor, OffsetMapping_ScaleSteps.z / LODFactor, OffsetMapping_ScaleSteps.w * LODFactor);\n"
+" float GuessLODFactor = min(1.0, OffsetMapping_LodDistance / EyeVectorFogDepth.z);\n"
+"#ifdef USEOFFSETMAPPING_RELIEFMAPPING\n"
+" // stupid workaround because 1-step and 2-step reliefmapping is void\n"
+" float LODSteps = max(3.0, ceil(GuessLODFactor * OffsetMapping_ScaleSteps.y));\n"
+"#else\n"
+" float LODSteps = ceil(GuessLODFactor * OffsetMapping_ScaleSteps.y);\n"
+"#endif\n"
+" float LODFactor = LODSteps / OffsetMapping_ScaleSteps.y;\n"
+" float4 ScaleSteps = float4(OffsetMapping_ScaleSteps.x, LODSteps, 1.0 / LODSteps, OffsetMapping_ScaleSteps.w * LODFactor);\n"
"#else\n"
" #define ScaleSteps OffsetMapping_ScaleSteps\n"
"#endif\n"
"#ifdef USESHADOWMAPORTHO\n"
"uniform float4x4 ShadowMapMatrix : register(c16),\n"
"#endif\n"
-"#if defined(MODE_VERTEXCOLOR) || defined(USEVERTEXTEXTUREBLEND)\n"
+"#if defined(MODE_VERTEXCOLOR) || defined(USEVERTEXTEXTUREBLEND) || defined(MODE_LIGHTDIRECTIONMAP_FORCED_VERTEXCOLOR) || defined(USEALPHAGENVERTEX)\n"
"out float4 gl_FrontColor : COLOR,\n"
"#endif\n"
"out float4 TexCoordBoth : TEXCOORD0,\n"
"out float4 gl_Position : POSITION\n"
")\n"
"{\n"
-"#if defined(MODE_VERTEXCOLOR) || defined(USEVERTEXTEXTUREBLEND)\n"
+"#if defined(MODE_VERTEXCOLOR) || defined(USEVERTEXTEXTUREBLEND) || defined(MODE_LIGHTDIRECTIONMAP_FORCED_VERTEXCOLOR) || defined(USEALPHAGENVERTEX)\n"
" gl_FrontColor = gl_Color;\n"
"#endif\n"
" // copy the surface texcoord\n"
" //color = half4(lerp(float4(1, 0, 0, 1), color, terrainblend));\n"
"#endif\n"
"#endif\n"
+"#ifdef USEALPHAGENVERTEX\n"
+" color.a *= gl_FrontColor.a;\n"
+"#endif\n"
"\n"
" // get the surface normal\n"
"#ifdef USEVERTEXTEXTUREBLEND\n"