Fog uses depth from z texture if it is available.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2330 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
donkopunchstania 2009-02-21 06:59:44 +00:00
parent 228652b070
commit 5a66927610
1 changed files with 5 additions and 5 deletions

View File

@ -134,7 +134,7 @@ static void WriteStage(char *&p, int n, u32 texture_mask);
static void WrapNonPow2Tex(char* &p, const char* var, int texmap, u32 texture_mask); static void WrapNonPow2Tex(char* &p, const char* var, int texmap, u32 texture_mask);
static void WriteAlphaCompare(char *&p, int num, int comp); static void WriteAlphaCompare(char *&p, int num, int comp);
static bool WriteAlphaTest(char *&p); static bool WriteAlphaTest(char *&p);
static void WriteFog(char *&p); static void WriteFog(char *&p, bool bOutputZ);
const float epsilon8bit = 1.0f / 255.0f; const float epsilon8bit = 1.0f / 255.0f;
@ -533,7 +533,7 @@ const char *GeneratePixelShader(u32 texture_mask, bool has_zbuffer_target, bool
WRITE(p, " ocol0 = float4(prev.rgb,"I_ALPHA"[0].w);\n"); WRITE(p, " ocol0 = float4(prev.rgb,"I_ALPHA"[0].w);\n");
else else
*/ */
WriteFog(p); WriteFog(p, bOutputZ);
WRITE(p, " ocol0 = prev;\n"); WRITE(p, " ocol0 = prev;\n");
} }
} }
@ -943,7 +943,7 @@ static bool WriteAlphaTest(char *&p)
return true; return true;
} }
static void WriteFog(char *&p) static void WriteFog(char *&p, bool bOutputZ)
{ {
bool enabled = bpmem.fog.c_proj_fsel.fsel == 0 ? false : true; bool enabled = bpmem.fog.c_proj_fsel.fsel == 0 ? false : true;
@ -951,11 +951,11 @@ static void WriteFog(char *&p)
if (bpmem.fog.c_proj_fsel.proj == 0) { if (bpmem.fog.c_proj_fsel.proj == 0) {
// perspective // perspective
// ze = A/(B - Zs) // ze = A/(B - Zs)
WRITE (p, " float ze = "I_FOG"[1].x / ("I_FOG"[1].y - zCoord);\n"); WRITE (p, " float ze = "I_FOG"[1].x / ("I_FOG"[1].y - %s);\n", bOutputZ ? "depth" : "zCoord");
} else { } else {
// orthographic // orthographic
// ze = a*Zs // ze = a*Zs
WRITE (p, " float ze = "I_FOG"[1].x * zCoord;\n"); WRITE (p, " float ze = "I_FOG"[1].x * %s;\n", bOutputZ ? "depth" : "zCoord");
} }
WRITE (p, " float fog = clamp(ze - "I_FOG"[1].z, 0.0f, 1.0f);\n"); WRITE (p, " float fog = clamp(ze - "I_FOG"[1].z, 0.0f, 1.0f);\n");