.lights loading now has the correct light intensity
torchs now spawn lights above their location so the shadow is cast down, not up
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2583
d7cf8633-e32d-0410-b094-
e92efae38249
+extern cvar_t r_shadow_bumpscale;
void Image_HeightmapToNormalmap(const unsigned char *inpixels, unsigned char *outpixels, int width, int height, int clamp, float bumpscale)
{
int x, y;
void Image_HeightmapToNormalmap(const unsigned char *inpixels, unsigned char *outpixels, int width, int height, int clamp, float bumpscale)
{
int x, y;
float iwidth, iheight, ibumpscale, n[3];
iwidth = 1.0f / width;
iheight = 1.0f / height;
float iwidth, iheight, ibumpscale, n[3];
iwidth = 1.0f / width;
iheight = 1.0f / height;
- ibumpscale = (255.0f * 3.0f) / (bumpscale * 8.0f);
+ ibumpscale = (255.0f * 3.0f) / (bumpscale * r_shadow_bumpscale.value);
out = outpixels;
for (y = 0;y < height;y++)
{
out = outpixels;
for (y = 0;y < height;y++)
{
cvar_t r_shadow_gloss = {0, "r_shadow_gloss", "1"};
cvar_t r_shadow_debuglight = {0, "r_shadow_debuglight", "-1"};
cvar_t r_shadow_scissor = {0, "r_shadow_scissor", "1"};
cvar_t r_shadow_gloss = {0, "r_shadow_gloss", "1"};
cvar_t r_shadow_debuglight = {0, "r_shadow_debuglight", "-1"};
cvar_t r_shadow_scissor = {0, "r_shadow_scissor", "1"};
+cvar_t r_shadow_bumpscale = {0, "r_shadow_bumpscale", "4"};
void R_Shadow_ClearWorldLights(void);
void R_Shadow_SaveWorldLights(void);
void R_Shadow_ClearWorldLights(void);
void R_Shadow_SaveWorldLights(void);
Cvar_RegisterVariable(&r_shadow_debuglight);
Cvar_RegisterVariable(&r_shadow_erasebydrawing);
Cvar_RegisterVariable(&r_shadow_scissor);
Cvar_RegisterVariable(&r_shadow_debuglight);
Cvar_RegisterVariable(&r_shadow_erasebydrawing);
Cvar_RegisterVariable(&r_shadow_scissor);
+ Cvar_RegisterVariable(&r_shadow_bumpscale);
R_Shadow_EditLights_Init();
R_RegisterModule("R_Shadow", r_shadow_start, r_shadow_shutdown, r_shadow_newmap);
}
R_Shadow_EditLights_Init();
R_RegisterModule("R_Shadow", r_shadow_start, r_shadow_shutdown, r_shadow_newmap);
}
Con_Printf("invalid lights file, found %d parameters on line %i, should be 14 parameters (origin[0] origin[1] origin[2] falloff light[0] light[1] light[2] subtract spotdir[0] spotdir[1] spotdir[2] spotcone distancebias style)\n", a, n + 1);
break;
}
Con_Printf("invalid lights file, found %d parameters on line %i, should be 14 parameters (origin[0] origin[1] origin[2] falloff light[0] light[1] light[2] subtract spotdir[0] spotdir[1] spotdir[2] spotcone distancebias style)\n", a, n + 1);
break;
}
- radius = sqrt(DotProduct(color, color) / (falloff * falloff * 16384.0f * 16384.0f));
+ radius = sqrt(DotProduct(color, color) / (falloff * falloff * 8192.0f * 8192.0f));
radius = bound(15, radius, 4096);
radius = bound(15, radius, 4096);
- VectorScale(color, (1.0f / 32768.0f), color);
+ VectorScale(color, (1.0f / (8388608.0f)), color);
R_Shadow_NewWorldLight(origin, radius, color, style, NULL);
s++;
n++;
R_Shadow_NewWorldLight(origin, radius, color, style, NULL);
s++;
n++;
{
int entnum, style, islight;
char key[256], value[1024];
{
int entnum, style, islight;
char key[256], value[1024];
- float origin[3], radius, color[3], light, scale;
+ float origin[3], radius, color[3], light, scale, originhack[3];
const char *data;
data = cl.worldmodel->entities;
const char *data;
data = cl.worldmodel->entities;
{
light = 0;
origin[0] = origin[1] = origin[2] = 0;
{
light = 0;
origin[0] = origin[1] = origin[2] = 0;
+ originhack[0] = originhack[1] = originhack[2] = 0;
color[0] = color[1] = color[2] = 1;
scale = 1;
style = 0;
color[0] = color[1] = color[2] = 1;
scale = 1;
style = 0;
else if (!strcmp("classname", key))
{
if (!strncmp(value, "light", 5))
else if (!strcmp("classname", key))
{
if (!strncmp(value, "light", 5))
+ if (!strcmp(value, "light_flame_large_yellow"))
+ {
+ originhack[0] = 0;
+ originhack[1] = 0;
+ originhack[2] = 40;
+ }
+ if (!strcmp(value, "light_flame_small_yellow"))
+ {
+ originhack[0] = 0;
+ originhack[1] = 0;
+ originhack[2] = 40;
+ }
+ if (!strcmp(value, "light_torch_small_white"))
+ {
+ originhack[0] = 0;
+ originhack[1] = 0;
+ originhack[2] = 40;
+ }
+ if (!strcmp(value, "light_torch_small_walltorch"))
+ {
+ originhack[0] = 0;
+ originhack[1] = 0;
+ originhack[2] = 40;
+ }
+ }
}
else if (!strcmp("style", key))
style = atoi(value);
}
else if (!strcmp("style", key))
style = atoi(value);
radius = bound(0, light / scale, 1048576) + 15.0f;
light = bound(0, light, 1048576) * (1.0f / 256.0f);
VectorScale(color, light, color);
radius = bound(0, light / scale, 1048576) + 15.0f;
light = bound(0, light, 1048576) * (1.0f / 256.0f);
VectorScale(color, light, color);
+ VectorAdd(origin, originhack, origin);
if (radius >= 15)
R_Shadow_NewWorldLight(origin, radius, color, style, NULL);
}
if (radius >= 15)
R_Shadow_NewWorldLight(origin, radius, color, style, NULL);
}