diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index f7e41e054f4..6c26c6a0b75 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -1539,15 +1539,9 @@ 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]); - } + 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]); } } diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c index b3627fd0fdf..6bc152abdfd 100644 --- a/dlls/wined3d/arb_program_shader.c +++ b/dlls/wined3d/arb_program_shader.c @@ -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. * diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index 75f8b03b603..d83eecbeb87 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -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. *