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.
This commit is contained in:
Matteo Bruni 2015-04-23 22:41:13 +02:00 committed by Alexandre Julliard
parent b963c73abb
commit d6db6c7295
1 changed files with 8 additions and 3 deletions

View File

@ -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;