Commit 693d9ded authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

wined3d: Properly set the fog frag coord according to the FOGTABLEMODE.

This also fixes the test that an earlier patch broke, so the todo_wine can be removed again.
parent 8dcd5128
......@@ -1539,17 +1539,11 @@ static void fog_with_shader_test(IDirect3DDevice9 *device)
/* As the red and green component are the result of blending use 5% tolerance on the expected value */
color = getPixelColor(device, 128, 240);
if(test_data[i].vshader == 1 && test_data[i].tfog == 0 && color != test_data[i].color[j]) {
todo_wine ok(color_match(color, test_data[i].color[j], 13),
"fog vs%i ps%i fvm%i ftm%i %d: got color %08x, expected %08x +-5%%(todo)\n",
test_data[i].vshader, test_data[i].pshader, test_data[i].vfog, test_data[i].tfog, j, color, test_data[i].color[j]);
} else {
ok(color_match(color, test_data[i].color[j], 13),
"fog vs%i ps%i fvm%i ftm%i %d: got color %08x, expected %08x +-5%%\n",
test_data[i].vshader, test_data[i].pshader, test_data[i].vfog, test_data[i].tfog, j, color, test_data[i].color[j]);
}
}
}
/* reset states */
hr = IDirect3DDevice9_SetVertexShader(device, NULL);
......
......@@ -2068,9 +2068,16 @@ static GLuint shader_arb_generate_vshader(IWineD3DVertexShader *iface, SHADER_BU
/* Base Shader Body */
shader_generate_main( (IWineD3DBaseShader*) This, buffer, reg_maps, function);
/* If this shader doesn't use fog copy the z coord to the fog coord so that we can use table fog */
if (!reg_maps->fog)
/* The D3DRS_FOGTABLEMODE render state defines if the shader-generated fog coord is used
* or if the fragment depth is used. If the fragment depth is used(FOGTABLEMODE != NONE),
* the fog frag coord is thrown away. If the fog frag coord is used, but not written by
* the shader, it is set to 0.0(fully fogged, since start = 1.0, end = 0.0)
*/
if(args->fog_src == VS_FOG_Z) {
shader_addline(buffer, "MOV result.fogcoord, TMP_OUT.z;\n");
} else if (!reg_maps->fog) {
shader_addline(buffer, "MOV result.fogcoord, 0.0;\n");
}
/* Write the final position.
*
......
......@@ -3912,9 +3912,16 @@ static GLuint shader_glsl_generate_vshader(IWineD3DVertexShader *iface, SHADER_B
if (reg_maps->shader_version >= WINED3DVS_VERSION(3,0)) shader_addline(buffer, "order_ps_input(OUT);\n");
else shader_addline(buffer, "order_ps_input();\n");
/* If this shader doesn't use fog copy the z coord to the fog coord so that we can use table fog */
if (!reg_maps->fog)
/* The D3DRS_FOGTABLEMODE render state defines if the shader-generated fog coord is used
* or if the fragment depth is used. If the fragment depth is used(FOGTABLEMODE != NONE),
* the fog frag coord is thrown away. If the fog frag coord is used, but not written by
* the shader, it is set to 0.0(fully fogged, since start = 1.0, end = 0.0)
*/
if(args->fog_src == VS_FOG_Z) {
shader_addline(buffer, "gl_FogFragCoord = gl_Position.z;\n");
} else if (!reg_maps->fog) {
shader_addline(buffer, "gl_FogFragCoord = 0.0;\n");
}
/* Write the final position.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment