wined3d: Implement WINED3D_LIGHT_PARALLELPOINT support in the GLSL ffp.

This commit is contained in:
Matteo Bruni 2015-04-30 23:22:18 +02:00 committed by Alexandre Julliard
parent e35f82665c
commit 213f7d9f45
3 changed files with 25 additions and 4 deletions

View File

@ -175,9 +175,6 @@ static HRESULT WINAPI d3d_light_SetLight(IDirect3DLight *iface, D3DLIGHT *data)
if ((!data->dltType) || (data->dltType > D3DLIGHT_PARALLELPOINT))
return DDERR_INVALIDPARAMS;
if (data->dltType == D3DLIGHT_PARALLELPOINT)
FIXME("D3DLIGHT_PARALLELPOINT not implemented.\n");
/* Translate D3DLIGHT2 structure to D3DLIGHT7. */
light7->dltType = data->dltType;
light7->dcvDiffuse = data->dcvColor;

View File

@ -1455,7 +1455,6 @@ HRESULT CDECL wined3d_device_set_light(struct wined3d_device *device,
{
case WINED3D_LIGHT_POINT:
case WINED3D_LIGHT_SPOT:
case WINED3D_LIGHT_PARALLELPOINT:
case WINED3D_LIGHT_GLSPOT:
/* Incorrect attenuation values can cause the gl driver to crash.
* Happens with Need for speed most wanted. */
@ -1467,6 +1466,7 @@ HRESULT CDECL wined3d_device_set_light(struct wined3d_device *device,
break;
case WINED3D_LIGHT_DIRECTIONAL:
case WINED3D_LIGHT_PARALLELPOINT:
/* Ignores attenuation */
break;
@ -1582,6 +1582,13 @@ HRESULT CDECL wined3d_device_set_light(struct wined3d_device *device,
/* FIXME: Range */
break;
case WINED3D_LIGHT_PARALLELPOINT:
object->position.x = light->position.x;
object->position.y = light->position.y;
object->position.z = light->position.z;
object->position.w = 1.0f;
break;
default:
FIXME("Unrecognized light type %#x.\n", light->type);
}

View File

@ -1186,6 +1186,11 @@ static void shader_glsl_ffp_vertex_light_uniform(const struct wined3d_context *c
GL_EXTCALL(glUniform3fv(prog->vs.light_location[light].direction, 1, &vec4.x));
break;
case WINED3D_LIGHT_PARALLELPOINT:
multiply_vector_matrix(&vec4, &light_info->position, view);
GL_EXTCALL(glUniform4fv(prog->vs.light_location[light].position, 1, &vec4.x));
break;
default:
FIXME("Unrecognized light type %#x.\n", light_info->OriginalParms.type);
}
@ -5538,6 +5543,18 @@ static void shader_glsl_ffp_vertex_lighting(struct wined3d_string_buffer *buffer
" * ffp_light[%u].specular;\n", i);
break;
case WINED3D_LIGHT_PARALLELPOINT:
shader_addline(buffer, "ambient += ffp_light[%u].ambient.xyz;\n", i);
if (!settings->normal)
break;
shader_addline(buffer, "dir = normalize(ffp_light[%u].position.xyz);\n", i);
shader_addline(buffer, "diffuse += clamp(dot(dir, normal), 0.0, 1.0)"
" * ffp_light[%u].diffuse.xyz;\n", i);
shader_addline(buffer, "t = dot(normal, normalize(dir - normalize(ec_pos.xyz)));\n");
shader_addline(buffer, "if (t > 0.0) specular += pow(t, ffp_material.shininess)"
" * ffp_light[%u].specular;\n", i);
break;
default:
if (light_type)
FIXME("Unhandled light type %#x.\n", light_type);