Fix T42074, textured lamps influncing other layers

The solution is to do the multiplication with the energy in the shader
after texture application.

We might be able to avoid setting dyncol completely, but this needs
better investigation. Some shader paths also look a bit redundant.

Also, texture mapping is not supported very well for light lamps, might
also need investigation.
This commit is contained in:
2014-10-07 11:06:38 +02:00
parent 5e809c45ed
commit 14c57b6c78
2 changed files with 19 additions and 7 deletions

View File

@@ -739,8 +739,9 @@ static void shade_one_light(GPUShadeInput *shi, GPUShadeResult *shr, GPULamp *la
i = is;
GPU_link(mat, "shade_visifac", i, visifac, shi->refl, &i);
GPU_link(mat, "set_value", GPU_dynamic_uniform(lamp->dyncol, GPU_DYNAMIC_LAMP_DYNCOL, lamp->ob), &lcol);
GPU_link(mat, "set_value_v3", GPU_dynamic_uniform(lamp->dyncol, GPU_DYNAMIC_LAMP_DYNCOL, lamp->ob), &lcol);
shade_light_textures(mat, lamp, &lcol);
GPU_link(mat, "shade_mul_value_v3", GPU_dynamic_uniform(&lamp->dynenergy, GPU_DYNAMIC_LAMP_DYNENERGY, lamp->ob), lcol, &lcol);
#if 0
if (ma->mode & MA_TANGENT_VN)
@@ -1716,9 +1717,9 @@ void GPU_lamp_update_colors(GPULamp *lamp, float r, float g, float b, float ener
lamp->energy = energy;
if (lamp->mode & LA_NEG) lamp->energy= -lamp->energy;
lamp->col[0]= r* lamp->energy;
lamp->col[1]= g* lamp->energy;
lamp->col[2]= b* lamp->energy;
lamp->col[0]= r;
lamp->col[1]= g;
lamp->col[2]= b;
}
void GPU_lamp_update_distance(GPULamp *lamp, float distance, float att1, float att2)
@@ -1750,9 +1751,9 @@ static void gpu_lamp_from_blender(Scene *scene, Object *ob, Object *par, Lamp *l
lamp->energy = la->energy;
if (lamp->mode & LA_NEG) lamp->energy= -lamp->energy;
lamp->col[0]= la->r*lamp->energy;
lamp->col[1]= la->g*lamp->energy;
lamp->col[2]= la->b*lamp->energy;
lamp->col[0]= la->r;
lamp->col[1]= la->g;
lamp->col[2]= la->b;
GPU_lamp_update(lamp, ob->lay, (ob->restrictflag & OB_RESTRICT_RENDER), ob->obmat);
@@ -2015,6 +2016,7 @@ GPUNodeLink *GPU_lamp_get_data(GPUMaterial *mat, GPULamp *lamp, GPUNodeLink **co
*col = GPU_dynamic_uniform(lamp->dyncol, GPU_DYNAMIC_LAMP_DYNCOL, lamp->ob);
visifac = lamp_get_visibility(mat, lamp, lv, dist);
/* looks like it's not used? psy-fi */
shade_light_textures(mat, lamp, col);
if (GPU_lamp_has_shadow_buffer(lamp)) {

View File

@@ -385,6 +385,11 @@ void set_value(float val, out float outval)
outval = val;
}
void set_value_v3(vec3 val, out vec3 outval)
{
outval = val;
}
void set_rgb(vec3 col, out vec3 outcol)
{
outcol = col;
@@ -1960,6 +1965,11 @@ void shade_mul_value(float fac, vec4 col, out vec4 outcol)
outcol = col*fac;
}
void shade_mul_value_v3(float fac, vec3 col, out vec3 outcol)
{
outcol = col*fac;
}
void shade_obcolor(vec4 col, vec4 obcol, out vec4 outcol)
{
outcol = vec4(col.rgb*obcol.rgb, col.a);