Clean up terrain shader a bit

This was SVN commit r11473.
This commit is contained in:
Ykkrosh 2012-04-10 20:55:01 +00:00
parent 9796fbf59b
commit 05008d190e
2 changed files with 15 additions and 30 deletions

View file

@ -1,25 +1,15 @@
!!ARBfp1.0
#ifdef USE_FP_SHADOW
#if USE_FP_SHADOW
OPTION ARB_fragment_program_shadow;
#endif
#ifdef LIGHTING_MODEL_old
#define CLAMP_LIGHTING
#endif
#ifdef CLAMP_LIGHTING // for compat with old scenarios that expect clamped lighting
#define MAD_MAYBE_SAT MAD_SAT
#else
#define MAD_MAYBE_SAT MAD
#endif
PARAM ambient = program.local[0];
#ifdef DECAL
#if DECAL
PARAM shadingColor = program.local[1];
#endif
#ifdef USE_SHADOW_PCF
#if USE_SHADOW_PCF
PARAM shadowOffsets1 = program.local[2];
PARAM shadowOffsets2 = program.local[3];
TEMP offset;
@ -30,7 +20,7 @@ TEMP temp;
TEMP diffuse;
TEMP color;
#ifdef BLEND
#if BLEND
// Use alpha from blend texture
// TODO: maybe we should invert the texture instead of doing SUB here?
TEX tex.a, fragment.texcoord[1], texture[1], 2D;
@ -40,16 +30,16 @@ TEMP color;
// Load diffuse colour
TEX color, fragment.texcoord[0], texture[0], 2D;
#ifdef DECAL
#if DECAL
// Use alpha from main texture
MOV result.color.a, color;
#endif
// Compute color = texture * (ambient + diffuse*shadow)
// (diffuse is 2*fragment.color due to clamp-avoidance in the vertex program)
#ifdef USE_SHADOW
#ifdef USE_FP_SHADOW
#ifdef USE_SHADOW_PCF
#if USE_SHADOW
#if USE_FP_SHADOW
#if USE_SHADOW_PCF
MOV offset.zw, fragment.texcoord[2];
ADD offset.xy, fragment.texcoord[2], shadowOffsets1;
TEX temp.x, offset, texture[2], SHADOW2D;
@ -68,16 +58,11 @@ TEX color, fragment.texcoord[0], texture[0], 2D;
MOV_SAT temp.z, fragment.texcoord[2].z;
SGE temp, tex.x, temp.z;
#endif
#ifdef CLAMP_LIGHTING
MAD_SAT diffuse.rgb, fragment.color, 2.0, ambient;
LRP temp.rgb, temp, diffuse, ambient;
#else
MUL diffuse.rgb, fragment.color, 2.0;
MAD temp.rgb, diffuse, temp, ambient;
#endif
MUL diffuse.rgb, fragment.color, 2.0;
MAD temp.rgb, diffuse, temp, ambient;
MUL color.rgb, color, temp;
#else
MAD_MAYBE_SAT temp.rgb, fragment.color, 2.0, ambient;
MAD temp.rgb, fragment.color, 2.0, ambient;
MUL color.rgb, color, temp;
#endif
@ -85,7 +70,7 @@ TEX color, fragment.texcoord[0], texture[0], 2D;
TEX tex.a, fragment.texcoord[3], texture[3], 2D;
MUL color.rgb, color, tex.a;
#ifdef DECAL
#if DECAL
MUL result.color.rgb, color, shadingColor;
#else
MOV result.color.rgb, color;

View file

@ -25,7 +25,7 @@ MUL result.color, lighting, sunColor;
//// Texture coordinates:
#ifdef DECAL
#if DECAL
MOV result.texcoord[0], vertex.texcoord[0];
#else
// Compute texcoords from position and terrain-texture-dependent transform.
@ -37,11 +37,11 @@ MUL result.color, lighting, sunColor;
MOV result.texcoord[0].w, 1;
#endif
#ifdef BLEND
#if BLEND
MOV result.texcoord[1], vertex.texcoord[1];
#endif
#ifdef USE_SHADOW
#if USE_SHADOW
DP4 result.texcoord[2].x, shadowTransform[0], position;
DP4 result.texcoord[2].y, shadowTransform[1], position;
DP4 result.texcoord[2].z, shadowTransform[2], position;