From f86e9a8cd6f039e9d4e1125d2c476bd0709e30c1 Mon Sep 17 00:00:00 2001 From: David Rose Date: Thu, 8 Jan 2009 23:42:44 +0000 Subject: [PATCH] fix flickering light --- panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx b/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx index f1dbbdddaa..87b54f4e7e 100644 --- a/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx +++ b/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx @@ -2609,7 +2609,6 @@ bind_light(DirectionalLight *light_obj, const NodePath &light, int light_id) { ZeroMemory(&fdata, sizeof(D3DLIGHT8)); fdata.Type = D3DLIGHT_DIRECTIONAL; - fdata.Diffuse = get_light_color(light_obj); fdata.Ambient = black ; fdata.Specular = *(D3DCOLORVALUE *)(light_obj->get_specular_color().get_data()); @@ -2623,6 +2622,11 @@ bind_light(DirectionalLight *light_obj, const NodePath &light, int light_id) { fdata.Attenuation2 = 0.0f; // quadratic } + // We have to reset the Diffuse color at each call, because it might + // have changed independently of the light object itself (due to + // color_scale_via_lighting being in effect). + fdata.Diffuse = get_light_color(light_obj); + HRESULT hr = _d3d_device->SetLight(light_id, &fdata); if (FAILED(hr)) { wdxdisplay8_cat.warning()