wined3d: Use clamp() instead of max() for calculating the clamped cosine in the ffp lighting calculations.
On typical hardware, the clamp() would be an instruction modifier, while the max() would need an extra instruction.
This commit is contained in:
parent
725b069e68
commit
ff6ce4c669
|
@ -4940,7 +4940,7 @@ static void shader_glsl_ffp_vertex_lighting(struct wined3d_shader_buffer *buffer
|
||||||
if (!settings->normal)
|
if (!settings->normal)
|
||||||
break;
|
break;
|
||||||
shader_addline(buffer, "dir = normalize(dir);\n");
|
shader_addline(buffer, "dir = normalize(dir);\n");
|
||||||
shader_addline(buffer, "diffuse += (max(0.0, dot(dir, normal))"
|
shader_addline(buffer, "diffuse += (clamp(dot(dir, normal), 0.0, 1.0)"
|
||||||
" * gl_LightSource[%u].diffuse.xyz) / att;\n", i);
|
" * gl_LightSource[%u].diffuse.xyz) / att;\n", i);
|
||||||
if (settings->localviewer)
|
if (settings->localviewer)
|
||||||
shader_addline(buffer, "t = dot(normal, normalize(dir - normalize(ec_pos.xyz)));\n");
|
shader_addline(buffer, "t = dot(normal, normalize(dir - normalize(ec_pos.xyz)));\n");
|
||||||
|
@ -4965,7 +4965,7 @@ static void shader_glsl_ffp_vertex_lighting(struct wined3d_shader_buffer *buffer
|
||||||
shader_addline(buffer, "ambient += gl_LightSource[%u].ambient.xyz * att;\n", i);
|
shader_addline(buffer, "ambient += gl_LightSource[%u].ambient.xyz * att;\n", i);
|
||||||
if (!settings->normal)
|
if (!settings->normal)
|
||||||
break;
|
break;
|
||||||
shader_addline(buffer, "diffuse += (max(0.0, dot(dir, normal))"
|
shader_addline(buffer, "diffuse += (clamp(dot(dir, normal), 0.0, 1.0)"
|
||||||
" * gl_LightSource[%u].diffuse.xyz) * att;\n", i);
|
" * gl_LightSource[%u].diffuse.xyz) * att;\n", i);
|
||||||
if (settings->localviewer)
|
if (settings->localviewer)
|
||||||
shader_addline(buffer, "t = dot(normal, normalize(dir - normalize(ec_pos.xyz)));\n");
|
shader_addline(buffer, "t = dot(normal, normalize(dir - normalize(ec_pos.xyz)));\n");
|
||||||
|
@ -4980,7 +4980,8 @@ static void shader_glsl_ffp_vertex_lighting(struct wined3d_shader_buffer *buffer
|
||||||
if (!settings->normal)
|
if (!settings->normal)
|
||||||
break;
|
break;
|
||||||
shader_addline(buffer, "dir = normalize(gl_LightSource[%u].position.xyz);\n", i);
|
shader_addline(buffer, "dir = normalize(gl_LightSource[%u].position.xyz);\n", i);
|
||||||
shader_addline(buffer, "diffuse += max(0.0, dot(dir, normal)) * gl_LightSource[%u].diffuse.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);
|
shader_addline(buffer, "t = dot(normal, gl_LightSource[%u].halfVector.xyz);\n", i);
|
||||||
shader_addline(buffer, "if (t > 0.0) specular += pow(t, gl_FrontMaterial.shininess)"
|
shader_addline(buffer, "if (t > 0.0) specular += pow(t, gl_FrontMaterial.shininess)"
|
||||||
" * gl_LightSource[%u].specular;\n", i);
|
" * gl_LightSource[%u].specular;\n", i);
|
||||||
|
|
Loading…
Reference in New Issue