[PATCH 2/5] wined3d: Fix specular lighting for non-local viewer.
Matteo Bruni
mbruni at codeweavers.com
Thu Apr 23 15:41:13 CDT 2015
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 adb62c4..901a6f5 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -5271,7 +5271,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;
@@ -5296,7 +5296,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;
@@ -5308,7 +5308,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;
--
2.0.5
More information about the wine-patches
mailing list