diff --git a/hw/xbox/nv2a_psh.c b/hw/xbox/nv2a_psh.c index ae69c53d2d..c366a45127 100644 --- a/hw/xbox/nv2a_psh.c +++ b/hw/xbox/nv2a_psh.c @@ -539,6 +539,7 @@ static QString* psh_convert(struct PixelShader *ps) qstring_append(preflight, "\n"); qstring_append(preflight, "out vec4 fragColor;\n"); qstring_append(preflight, "\n"); + qstring_append(preflight, "uniform vec4 fogColor;\n"); /* calculate perspective-correct inputs */ QString *vars = qstring_new(); @@ -546,7 +547,7 @@ static QString* psh_convert(struct PixelShader *ps) qstring_append(vars, "vec4 pD1 = vtx.D1 / vtx.inv_w;\n"); qstring_append(vars, "vec4 pB0 = vtx.B0 / vtx.inv_w;\n"); qstring_append(vars, "vec4 pB1 = vtx.B1 / vtx.inv_w;\n"); - qstring_append(vars, "vec4 pFog = clamp(vtx.Fog / vtx.inv_w, 0.0, 1.0);\n"); + qstring_append(vars, "vec4 pFog = vec4(fogColor.rgb, clamp(vtx.Fog / vtx.inv_w, 0.0, 1.0));\n"); qstring_append(vars, "vec4 pT0 = vtx.T0 / vtx.inv_w;\n"); qstring_append(vars, "vec4 pT1 = vtx.T1 / vtx.inv_w;\n"); qstring_append(vars, "vec4 pT2 = vtx.T2 / vtx.inv_w;\n"); diff --git a/hw/xbox/nv2a_shaders.c b/hw/xbox/nv2a_shaders.c index e18940f8cd..1fc57e9964 100644 --- a/hw/xbox/nv2a_shaders.c +++ b/hw/xbox/nv2a_shaders.c @@ -329,12 +329,11 @@ static QString* generate_fixed_function(const ShaderState state, break; } /* FIXME: What about fog alpha?! */ - qstring_append(s, "vec4 tFog = vec4(fogColor.rgb, fogFactor);\n"); + qstring_append(s, "float tFog = fogFactor;\n"); } else { /* FIXME: Is the fog still calculated / passed somehow?! - * Maybe vec4(fogColor, fogCoord) ? */ - qstring_append(s, "vec4 tFog = vec4(0.0);\n"); + qstring_append(s, "float tFog = 0.0;\n"); } /* If skinning is off the composite matrix already includes the MV matrix */ diff --git a/hw/xbox/nv2a_shaders_common.h b/hw/xbox/nv2a_shaders_common.h index 19e0f88067..c8e1a962ff 100644 --- a/hw/xbox/nv2a_shaders_common.h +++ b/hw/xbox/nv2a_shaders_common.h @@ -27,7 +27,7 @@ " vec4 D1;\n" \ " vec4 B0;\n" \ " vec4 B1;\n" \ - " vec4 Fog;\n" \ + " float Fog;\n" \ " vec4 T0;\n" \ " vec4 T1;\n" \ " vec4 T2;\n" \ diff --git a/hw/xbox/nv2a_vsh.c b/hw/xbox/nv2a_vsh.c index 8313cddb75..3e43a284cc 100644 --- a/hw/xbox/nv2a_vsh.c +++ b/hw/xbox/nv2a_vsh.c @@ -737,6 +737,7 @@ QString* vsh_translate(uint16_t version, qstring_append(header, STRUCT_VERTEX_DATA); qstring_append_fmt(header, "noperspective out VertexData %c_vtx;\n", out_prefix); qstring_append_fmt(header, "#define vtx %c_vtx", out_prefix); + qstring_append(header, "\n" "uniform mat4 texMat0;\n" "uniform mat4 texMat1;\n" @@ -780,7 +781,7 @@ QString* vsh_translate(uint16_t version, qstring_append(body, "vtx.D1 = clamp(oD1, 0.0, 1.0) * vtx.inv_w;\n"); qstring_append(body, "vtx.B0 = clamp(oB0, 0.0, 1.0) * vtx.inv_w;\n"); qstring_append(body, "vtx.B1 = clamp(oB1, 0.0, 1.0) * vtx.inv_w;\n"); - qstring_append(body, "vtx.Fog = oFog * vtx.inv_w;\n"); + qstring_append(body, "vtx.Fog = oFog.x * vtx.inv_w;\n"); qstring_append(body, "vtx.T0 = oT0 * vtx.inv_w;\n"); qstring_append(body, "vtx.T1 = oT1 * vtx.inv_w;\n"); qstring_append(body, "vtx.T2 = oT2 * vtx.inv_w;\n");