Matteo Bruni : wined3d: Ignore lights out of maximum range for legacy FFP lighting too.
Alexandre Julliard
julliard at winehq.org
Mon May 8 17:21:23 CDT 2017
Module: wine
Branch: master
Commit: 43b6bfbc3708a0824792dc76e1e9a869a144446a
URL: http://source.winehq.org/git/wine.git/?a=commit;h=43b6bfbc3708a0824792dc76e1e9a869a144446a
Author: Matteo Bruni <mbruni at codeweavers.com>
Date: Sun May 7 20:32:38 2017 +0200
wined3d: Ignore lights out of maximum range for legacy FFP lighting too.
Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ddraw/tests/ddraw2.c | 25 +++++++++++++++++++++++++
dlls/ddraw/tests/ddraw4.c | 25 +++++++++++++++++++++++++
dlls/wined3d/glsl_shader.c | 14 ++++++--------
3 files changed, 56 insertions(+), 8 deletions(-)
diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c
index f81be7f..9d77521 100644
--- a/dlls/ddraw/tests/ddraw2.c
+++ b/dlls/ddraw/tests/ddraw2.c
@@ -7101,6 +7101,17 @@ static void test_specular_lighting(void)
100.0f,
0.0f,
1.0f, 0.0f, 0.0f,
+ },
+ point_far =
+ {
+ sizeof(D3DLIGHT2),
+ D3DLIGHT_POINT,
+ {{1.0f}, {1.0f}, {1.0f}, {0.0f}},
+ {{0.0f}, {0.0f}, {0.1f}},
+ {{0.0f}, {0.0f}, {0.0f}},
+ 1.0f,
+ 0.0f,
+ 1.0f, 0.0f, 0.0f,
};
static const struct expected_color
{
@@ -7166,6 +7177,18 @@ static void test_specular_lighting(void)
{160, 360, 0x00000000},
{320, 360, 0x00000000},
{480, 360, 0x00000000},
+ },
+ expected_point_far[] =
+ {
+ {160, 120, 0x00000000},
+ {320, 120, 0x00000000},
+ {480, 120, 0x00000000},
+ {160, 240, 0x00000000},
+ {320, 240, 0x00ffffff},
+ {480, 240, 0x00000000},
+ {160, 360, 0x00000000},
+ {320, 360, 0x00000000},
+ {480, 360, 0x00000000},
};
static const struct
{
@@ -7186,6 +7209,8 @@ static void test_specular_lighting(void)
sizeof(expected_parallelpoint) / sizeof(expected_parallelpoint[0])},
{&point_side, 0.0f, expected_point_side,
sizeof(expected_point_side) / sizeof(expected_point_side[0])},
+ {&point_far, 1.0f, expected_point_far,
+ sizeof(expected_point_far) / sizeof(expected_point_far[0])},
};
IDirect3D2 *d3d;
IDirect3DDevice2 *device;
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c
index 47b94f7..b401544 100644
--- a/dlls/ddraw/tests/ddraw4.c
+++ b/dlls/ddraw/tests/ddraw4.c
@@ -4156,6 +4156,17 @@ static void test_specular_lighting(void)
100.0f,
0.0f,
1.0f, 0.0f, 0.0f,
+ },
+ point_far =
+ {
+ sizeof(D3DLIGHT2),
+ D3DLIGHT_POINT,
+ {{1.0f}, {1.0f}, {1.0f}, {0.0f}},
+ {{0.0f}, {0.0f}, {0.1f}},
+ {{0.0f}, {0.0f}, {0.0f}},
+ 1.0f,
+ 0.0f,
+ 1.0f, 0.0f, 0.0f,
};
static const struct expected_color
{
@@ -4221,6 +4232,18 @@ static void test_specular_lighting(void)
{160, 360, 0x00000000},
{320, 360, 0x00000000},
{480, 360, 0x00000000},
+ },
+ expected_point_far[] =
+ {
+ {160, 120, 0x00000000},
+ {320, 120, 0x00000000},
+ {480, 120, 0x00000000},
+ {160, 240, 0x00000000},
+ {320, 240, 0x00ffffff},
+ {480, 240, 0x00000000},
+ {160, 360, 0x00000000},
+ {320, 360, 0x00000000},
+ {480, 360, 0x00000000},
};
static const struct
{
@@ -4246,6 +4269,8 @@ static void test_specular_lighting(void)
sizeof(expected_parallelpoint) / sizeof(expected_parallelpoint[0])},
{&point_side, TRUE, 0.0f, expected_point_side,
sizeof(expected_point_side) / sizeof(expected_point_side[0])},
+ {&point_far, TRUE, 1.0f, expected_point_far,
+ sizeof(expected_point_far) / sizeof(expected_point_far[0])},
};
IDirect3D3 *d3d;
IDirect3DDevice3 *device;
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index dfbe46d..166a4ae 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -7720,6 +7720,7 @@ static void shader_glsl_ffp_vertex_lighting(struct wined3d_string_buffer *buffer
{
shader_addline(buffer, "dst.y = (ffp_light[%u].range - dst.y) / ffp_light[%u].range;\n", idx, idx);
shader_addline(buffer, "dst.z = dst.y * dst.y;\n");
+ shader_addline(buffer, "if (dst.y > 0.0)\n{\n");
}
else
{
@@ -7732,14 +7733,12 @@ static void shader_glsl_ffp_vertex_lighting(struct wined3d_string_buffer *buffer
shader_addline(buffer, "ambient += ffp_light[%u].ambient.xyz * att;\n", idx);
if (!settings->normal)
{
- if (!legacy_lighting)
- shader_addline(buffer, "}\n");
+ shader_addline(buffer, "}\n");
continue;
}
shader_addline(buffer, "dir = normalize(dir);\n");
shader_glsl_ffp_vertex_lighting_footer(buffer, settings, i);
- if (!legacy_lighting)
- shader_addline(buffer, "}\n");
+ shader_addline(buffer, "}\n");
}
for (i = 0; i < settings->spot_light_count; ++i, ++idx)
@@ -7752,6 +7751,7 @@ static void shader_glsl_ffp_vertex_lighting(struct wined3d_string_buffer *buffer
{
shader_addline(buffer, "dst.y = (ffp_light[%u].range - dst.y) / ffp_light[%u].range;\n", idx, idx);
shader_addline(buffer, "dst.z = dst.y * dst.y;\n");
+ shader_addline(buffer, "if (dst.y > 0.0)\n{\n");
}
else
{
@@ -7775,13 +7775,11 @@ static void shader_glsl_ffp_vertex_lighting(struct wined3d_string_buffer *buffer
shader_addline(buffer, "ambient += ffp_light[%u].ambient.xyz * att;\n", idx);
if (!settings->normal)
{
- if (!legacy_lighting)
- shader_addline(buffer, "}\n");
+ shader_addline(buffer, "}\n");
continue;
}
shader_glsl_ffp_vertex_lighting_footer(buffer, settings, i);
- if (!legacy_lighting)
- shader_addline(buffer, "}\n");
+ shader_addline(buffer, "}\n");
}
for (i = 0; i < settings->directional_light_count; ++i, ++idx)
More information about the wine-cvs
mailing list