VectorSet(ent->render.render_modellight_ambient, 1, 1, 1);
VectorSet(ent->render.render_modellight_diffuse, 0, 0, 0);
VectorSet(ent->render.render_modellight_specular, 0, 0, 0);
- VectorSet(ent->render.render_modellight_lightdir, 0, 0, 1);
+ VectorSet(ent->render.render_modellight_lightdir_world, 0, 0, 1);
+ VectorSet(ent->render.render_modellight_lightdir_local, 0, 0, 1); // local doesn't matter because no diffuse/specular color
VectorSet(ent->render.render_lightmap_ambient, 0, 0, 0);
VectorSet(ent->render.render_lightmap_diffuse, 1, 1, 1);
VectorSet(ent->render.render_lightmap_specular, 1, 1, 1);
ent->render_modellight_ambient[q] = a[q] * ent->colormod[q];
ent->render_modellight_diffuse[q] = c[q] * ent->colormod[q];
ent->render_modellight_specular[q] = c[q];
- ent->render_modellight_lightdir[q] = dir[q];
+ ent->render_modellight_lightdir_world[q] = dir[q];
ent->render_lightmap_ambient[q] = ent->colormod[q] * r_refdef.scene.ambientintensity;
ent->render_lightmap_diffuse[q] = ent->colormod[q] * r_refdef.scene.lightmapintensity;
ent->render_lightmap_specular[q] = r_refdef.scene.lightmapintensity;
for (q = 0; q < 3; q++)
ent->render_rtlight_diffuse[q] = ent->render_rtlight_specular[q] = q;
- if (VectorLength2(ent->render_modellight_lightdir) == 0)
- VectorSet(ent->render_modellight_lightdir, 0, 0, 1); // have to set SOME valid vector here
- VectorNormalize(ent->render_modellight_lightdir);
+ if (VectorLength2(ent->render_modellight_lightdir_world) == 0)
+ VectorSet(ent->render_modellight_lightdir_world, 0, 0, 1); // have to set SOME valid vector here
+ VectorNormalize(ent->render_modellight_lightdir_world);
+ // transform into local space for the entity as well
+ Matrix4x4_Transform3x3(&ent->inversematrix, ent->render_modellight_lightdir_world, ent->render_modellight_lightdir_local);
+ VectorNormalize(ent->render_modellight_lightdir_local);
}
// MATERIALFLAG_MODELLIGHT uses these parameters
float render_modellight_ambient[3];
float render_modellight_diffuse[3];
- float render_modellight_lightdir[3];
+ float render_modellight_lightdir_world[3];
+ float render_modellight_lightdir_local[3];
float render_modellight_specular[3];
// lightmap rendering (not MATERIALFLAG_MODELLIGHT)
float render_lightmap_ambient[3];
if (r_glsl_permutation->loc_DeferredMod_Diffuse >= 0) qglUniform3f(r_glsl_permutation->loc_DeferredMod_Diffuse, t->render_rtlight_diffuse[0], t->render_rtlight_diffuse[1], t->render_rtlight_diffuse[2]);
if (r_glsl_permutation->loc_DeferredMod_Specular >= 0) qglUniform3f(r_glsl_permutation->loc_DeferredMod_Specular, t->render_rtlight_specular[0], t->render_rtlight_specular[1], t->render_rtlight_specular[2]);
if (r_glsl_permutation->loc_LightColor >= 0) qglUniform3f(r_glsl_permutation->loc_LightColor, 1, 1, 1); // DEPRECATED
- if (r_glsl_permutation->loc_LightDir >= 0) qglUniform3f(r_glsl_permutation->loc_LightDir, t->render_modellight_lightdir[0], t->render_modellight_lightdir[1], t->render_modellight_lightdir[2]);
+ if (r_glsl_permutation->loc_LightDir >= 0) qglUniform3f(r_glsl_permutation->loc_LightDir, t->render_modellight_lightdir_local[0], t->render_modellight_lightdir_local[1], t->render_modellight_lightdir_local[2]);
}
else
{
for (q = 0; q < 3; q++)
{
t->render_glowmod[q] = rsurface.entity->glowmod[q];
- t->render_modellight_lightdir[q] = q == 2;
+ t->render_modellight_lightdir_world[q] = q == 2;
+ t->render_modellight_lightdir_local[q] = q == 2;
t->render_modellight_ambient[q] = 1;
t->render_modellight_diffuse[q] = 0;
t->render_modellight_specular[q] = 0;
{
t->render_glowmod[q] = rsurface.entity->render_glowmod[q] * r_refdef.view.colorscale;
t->render_modellight_ambient[q] = rsurface.entity->render_fullbright[q] * r_refdef.view.colorscale;
- t->render_modellight_lightdir[q] = q == 2;
+ t->render_modellight_lightdir_world[q] = q == 2;
+ t->render_modellight_lightdir_local[q] = q == 2;
t->render_modellight_diffuse[q] = 0;
t->render_modellight_specular[q] = 0;
t->render_lightmap_ambient[q] = 0;
for (q = 0; q < 3; q++)
{
t->render_glowmod[q] = rsurface.entity->render_glowmod[q] * r_refdef.view.colorscale;
- t->render_modellight_lightdir[q] = q == 2;
+ t->render_modellight_lightdir_world[q] = q == 2;
+ t->render_modellight_lightdir_local[q] = q == 2;
t->render_modellight_ambient[q] = 0;
t->render_modellight_diffuse[q] = 0;
t->render_modellight_specular[q] = 0;
for (q = 0; q < 3; q++)
{
t->render_glowmod[q] = rsurface.entity->render_glowmod[q] * r_refdef.view.colorscale;
- t->render_modellight_lightdir[q] = rsurface.entity->render_modellight_lightdir[q];
+ t->render_modellight_lightdir_world[q] = rsurface.entity->render_modellight_lightdir_world[q];
+ t->render_modellight_lightdir_local[q] = rsurface.entity->render_modellight_lightdir_local[q];
t->render_modellight_ambient[q] = rsurface.entity->render_modellight_ambient[q] * r_refdef.view.colorscale;
t->render_modellight_diffuse[q] = rsurface.entity->render_modellight_diffuse[q] * r_refdef.view.colorscale;
t->render_modellight_specular[q] = rsurface.entity->render_modellight_specular[q] * r_refdef.view.colorscale;
for (q = 0; q < 3; q++)
{
t->render_glowmod[q] = rsurface.entity->render_glowmod[q] * r_refdef.view.colorscale;
- t->render_modellight_lightdir[q] = q == 2;
+ t->render_modellight_lightdir_world[q] = q == 2;
+ t->render_modellight_lightdir_local[q] = q == 2;
t->render_modellight_ambient[q] = 0;
t->render_modellight_diffuse[q] = 0;
t->render_modellight_specular[q] = 0;
for (q = 0; q < 3; q++)
{
t->render_glowmod[q] = rsurface.entity->render_glowmod[q] * r_refdef.view.colorscale;
- t->render_modellight_lightdir[q] = q == 2;
+ t->render_modellight_lightdir_world[q] = q == 2;
+ t->render_modellight_lightdir_local[q] = q == 2;
t->render_modellight_ambient[q] = 0;
t->render_modellight_diffuse[q] = 0;
t->render_modellight_specular[q] = 0;
// MATERIALFLAG_MODELLIGHT uses these parameters
float render_modellight_ambient[3];
float render_modellight_diffuse[3];
- float render_modellight_lightdir[3];
+ float render_modellight_lightdir_world[3];
+ float render_modellight_lightdir_local[3];
float render_modellight_specular[3];
// lightmap rendering (not MATERIALFLAG_MODELLIGHT)
float render_lightmap_ambient[3];