From 826b67e395cdc62da03277e234d2a20172beb158 Mon Sep 17 00:00:00 2001 From: Paul Gofman Date: Fri, 29 Mar 2019 13:56:36 +0300 Subject: [PATCH] wined3d: Treat zero shininess as no specular lighting in legacy lighting mode. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=42572 Signed-off-by: Paul Gofman Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/wined3d/glsl_shader.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index 5844b0c0b16..6c9ed16b1c8 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -8998,7 +8998,7 @@ static const char *shader_glsl_ffp_mcs(enum wined3d_material_color_source mcs, c } static void shader_glsl_ffp_vertex_lighting_footer(struct wined3d_string_buffer *buffer, - const struct wined3d_ffp_vs_settings *settings, unsigned int idx) + const struct wined3d_ffp_vs_settings *settings, unsigned int idx, BOOL legacy_lighting) { shader_addline(buffer, "diffuse += clamp(dot(dir, normal), 0.0, 1.0)" " * ffp_light[%u].diffuse.xyz * att;\n", idx); @@ -9006,8 +9006,9 @@ static void shader_glsl_ffp_vertex_lighting_footer(struct wined3d_string_buffer shader_addline(buffer, "t = dot(normal, normalize(dir - normalize(ec_pos.xyz)));\n"); else shader_addline(buffer, "t = dot(normal, normalize(dir + vec3(0.0, 0.0, -1.0)));\n"); - shader_addline(buffer, "if (dot(dir, normal) > 0.0 && t > 0.0) specular +=" - " pow(t, ffp_material.shininess) * ffp_light[%u].specular * att;\n", idx); + shader_addline(buffer, "if (dot(dir, normal) > 0.0 && t > 0.0%s) specular +=" + " pow(t, ffp_material.shininess) * ffp_light[%u].specular * att;\n", + legacy_lighting ? " && ffp_material.shininess > 0.0" : "", idx); } static void shader_glsl_ffp_vertex_lighting(struct wined3d_string_buffer *buffer, @@ -9062,7 +9063,7 @@ static void shader_glsl_ffp_vertex_lighting(struct wined3d_string_buffer *buffer continue; } shader_addline(buffer, "dir = normalize(dir);\n"); - shader_glsl_ffp_vertex_lighting_footer(buffer, settings, idx); + shader_glsl_ffp_vertex_lighting_footer(buffer, settings, idx, legacy_lighting); shader_addline(buffer, "}\n"); } @@ -9103,7 +9104,7 @@ static void shader_glsl_ffp_vertex_lighting(struct wined3d_string_buffer *buffer shader_addline(buffer, "}\n"); continue; } - shader_glsl_ffp_vertex_lighting_footer(buffer, settings, idx); + shader_glsl_ffp_vertex_lighting_footer(buffer, settings, idx, legacy_lighting); shader_addline(buffer, "}\n"); } @@ -9114,7 +9115,7 @@ static void shader_glsl_ffp_vertex_lighting(struct wined3d_string_buffer *buffer continue; shader_addline(buffer, "att = 1.0;\n"); shader_addline(buffer, "dir = normalize(ffp_light[%u].direction.xyz);\n", idx); - shader_glsl_ffp_vertex_lighting_footer(buffer, settings, idx); + shader_glsl_ffp_vertex_lighting_footer(buffer, settings, idx, legacy_lighting); } for (i = 0; i < settings->parallel_point_light_count; ++i, ++idx) @@ -9124,7 +9125,7 @@ static void shader_glsl_ffp_vertex_lighting(struct wined3d_string_buffer *buffer continue; shader_addline(buffer, "att = 1.0;\n"); shader_addline(buffer, "dir = normalize(ffp_light[%u].position.xyz);\n", idx); - shader_glsl_ffp_vertex_lighting_footer(buffer, settings, idx); + shader_glsl_ffp_vertex_lighting_footer(buffer, settings, idx, legacy_lighting); } shader_addline(buffer, "ffp_varying_diffuse.xyz = %s.xyz * ambient + %s.xyz * diffuse + %s.xyz;\n",