Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorBenoit Bolsee <benoit.bolsee@online.be>2009-05-13 10:42:15 +0400
committerBenoit Bolsee <benoit.bolsee@online.be>2009-05-13 10:42:15 +0400
commit82b4975ccfa8fe2c72278388a3cf3a8432cc9fb0 (patch)
tree3bd0fb8c0c858fd4556f6865e3d79e1e5e9faac5 /source
parentc19baf85cca1ecdd0b07c35a61a4999bc27d1e6b (diff)
BGE #18732: Python Light options don't work with GLSL materials. Commited patch from dfelinto and moguri, thanks for the good work.
Diffstat (limited to 'source')
-rw-r--r--source/blender/gpu/GPU_material.h1
-rw-r--r--source/blender/gpu/intern/gpu_material.c12
-rw-r--r--source/blender/src/drawview.c2
-rw-r--r--source/gameengine/Ketsji/KX_Light.cpp9
-rw-r--r--source/gameengine/Ketsji/KX_Light.h1
5 files changed, 25 insertions, 0 deletions
diff --git a/source/blender/gpu/GPU_material.h b/source/blender/gpu/GPU_material.h
index ccc687858f4..49c0dc166c1 100644
--- a/source/blender/gpu/GPU_material.h
+++ b/source/blender/gpu/GPU_material.h
@@ -159,6 +159,7 @@ void GPU_lamp_shadow_buffer_bind(GPULamp *lamp, float viewmat[][4], int *winsize
void GPU_lamp_shadow_buffer_unbind(GPULamp *lamp);
void GPU_lamp_update(GPULamp *lamp, int lay, float obmat[][4]);
+void GPU_lamp_update_colors(GPULamp *lamp, float r, float g, float b, float energy);
int GPU_lamp_shadow_layer(GPULamp *lamp);
#ifdef __cplusplus
diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c
index 87703bc73bf..f7052694fc7 100644
--- a/source/blender/gpu/intern/gpu_material.c
+++ b/source/blender/gpu/intern/gpu_material.c
@@ -1306,6 +1306,18 @@ void GPU_lamp_update(GPULamp *lamp, int lay, float obmat[][4])
Mat4Invert(lamp->imat, mat);
}
+void GPU_lamp_update_colors(GPULamp *lamp, float r, float g, float b, float energy)
+{
+ lamp->la->energy = energy;
+ lamp->la->r = r;
+ lamp->la->g = g;
+ lamp->la->b = b;
+
+ lamp->col[0]= lamp->la->r*lamp->energy;
+ lamp->col[1]= lamp->la->g*lamp->energy;
+ lamp->col[2]= lamp->la->b*lamp->energy;
+}
+
static void gpu_lamp_from_blender(Scene *scene, Object *ob, Object *par, Lamp *la, GPULamp *lamp)
{
float temp, angle, pixsize, wsize;
diff --git a/source/blender/src/drawview.c b/source/blender/src/drawview.c
index d6184f42410..9b2f7fe53d9 100644
--- a/source/blender/src/drawview.c
+++ b/source/blender/src/drawview.c
@@ -3152,12 +3152,14 @@ typedef struct View3DShadow{
static void gpu_render_lamp_update(View3D *v3d, Object *ob, Object *par, float obmat[][4], ListBase *shadows)
{
GPULamp *lamp;
+ Lamp *la = (Lamp*)ob->data;
View3DShadow *shadow;
lamp = GPU_lamp_from_blender(G.scene, ob, par);
if(lamp) {
GPU_lamp_update(lamp, ob->lay, obmat);
+ GPU_lamp_update_colors(lamp, la->r, la->g, la->b, la->energy);
if((ob->lay & v3d->lay) && GPU_lamp_has_shadow_buffer(lamp)) {
shadow= MEM_callocN(sizeof(View3DShadow), "View3DShadow");
diff --git a/source/gameengine/Ketsji/KX_Light.cpp b/source/gameengine/Ketsji/KX_Light.cpp
index 777a7f32629..3af34c39123 100644
--- a/source/gameengine/Ketsji/KX_Light.cpp
+++ b/source/gameengine/Ketsji/KX_Light.cpp
@@ -61,6 +61,11 @@ KX_LightObject::KX_LightObject(void* sgReplicationInfo,SG_Callbacks callbacks,
m_rendertools->AddLight(&m_lightobj);
m_glsl = glsl;
m_blenderscene = ((KX_Scene*)sgReplicationInfo)->GetBlenderScene();
+
+ m_initialvalues[0] = lightobj.m_red;
+ m_initialvalues[1] = lightobj.m_green;
+ m_initialvalues[2] = lightobj.m_blue;
+ m_initialvalues[3] = lightobj.m_energy;
};
@@ -71,6 +76,8 @@ KX_LightObject::~KX_LightObject()
if((lamp = GetGPULamp())) {
float obmat[4][4] = {{0}};
GPU_lamp_update(lamp, 0, obmat);
+ GPU_lamp_update_colors(lamp, m_initialvalues[0], m_initialvalues[1],
+ m_initialvalues[2], m_initialvalues[3]);
}
m_rendertools->RemoveLight(&m_lightobj);
@@ -114,6 +121,8 @@ void KX_LightObject::Update()
obmat[i][j] = (float)*dobmat;
GPU_lamp_update(lamp, m_lightobj.m_layer, obmat);
+ GPU_lamp_update_colors(lamp, m_lightobj.m_red, m_lightobj.m_green,
+ m_lightobj.m_blue, m_lightobj.m_energy);
}
}
diff --git a/source/gameengine/Ketsji/KX_Light.h b/source/gameengine/Ketsji/KX_Light.h
index 35f25515e3b..690231ff090 100644
--- a/source/gameengine/Ketsji/KX_Light.h
+++ b/source/gameengine/Ketsji/KX_Light.h
@@ -44,6 +44,7 @@ class KX_LightObject : public KX_GameObject
Py_Header;
protected:
RAS_LightObject m_lightobj;
+ float m_initialvalues [4];
class RAS_IRenderTools* m_rendertools; //needed for registering and replication of lightobj
bool m_glsl;
Scene* m_blenderscene;