Module: wine Branch: master Commit: d6db6c729532f5f9320db1d376ef034342450a84 URL: http://source.winehq.org/git/wine.git/?a=commit;h=d6db6c729532f5f9320db1d376...
Author: Matteo Bruni mbruni@codeweavers.com Date: Thu Apr 23 22:41:13 2015 +0200
wined3d: Fix specular lighting for non-local viewer.
The viewer is in the (0.0, 0.0, -1.0) direction in the D3D coordinate system.
---
dlls/wined3d/glsl_shader.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index 7874a69..4c0266f 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -5280,7 +5280,7 @@ static void shader_glsl_ffp_vertex_lighting(struct wined3d_shader_buffer *buffer if (settings->localviewer) 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, "t = dot(normal, normalize(dir + vec3(0.0, 0.0, -1.0)));\n"); shader_addline(buffer, "if (t > 0.0) specular += (pow(t, gl_FrontMaterial.shininess)" " * gl_LightSource[%u].specular) / att;\n", i); break; @@ -5305,7 +5305,7 @@ static void shader_glsl_ffp_vertex_lighting(struct wined3d_shader_buffer *buffer if (settings->localviewer) 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, "t = dot(normal, normalize(dir + vec3(0.0, 0.0, -1.0)));\n"); shader_addline(buffer, "if (t > 0.0) specular += (pow(t, gl_FrontMaterial.shininess)" " * gl_LightSource[%u].specular) * att;\n", i); break; @@ -5317,7 +5317,12 @@ static void shader_glsl_ffp_vertex_lighting(struct wined3d_shader_buffer *buffer shader_addline(buffer, "dir = normalize(gl_LightSource[%u].position.xyz);\n", i); shader_addline(buffer, "diffuse += clamp(dot(dir, normal), 0.0, 1.0)" " * gl_LightSource[%u].diffuse.xyz;\n", i); - shader_addline(buffer, "t = dot(normal, gl_LightSource[%u].halfVector.xyz);\n", i); + /* TODO: In the non-local viewer case the halfvector is constant + * and could be precomputed and stored in a uniform. */ + if (settings->localviewer) + 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 (t > 0.0) specular += pow(t, gl_FrontMaterial.shininess)" " * gl_LightSource[%u].specular;\n", i); break;