void r_shadow_newmap(void)
{
- if (r_refdef.scene.worldmodel && strncmp(r_refdef.scene.worldmodel->name, r_shadow_mapname, sizeof(r_shadow_mapname)))
+ if (cl.worldmodel && strncmp(cl.worldmodel->name, r_shadow_mapname, sizeof(r_shadow_mapname)))
R_Shadow_EditLights_Reload_f();
}
R_Shadow_MakeTextures_MakeCorona();
// Editor light sprites
- r_editlights_sprcursor = Draw_CachePic("gfx/editlights/cursor", true);
- r_editlights_sprlight = Draw_CachePic("gfx/editlights/light", true);
- r_editlights_sprnoshadowlight = Draw_CachePic("gfx/editlights/noshadow", true);
- r_editlights_sprcubemaplight = Draw_CachePic("gfx/editlights/cubemaplight", true);
- r_editlights_sprcubemapnoshadowlight = Draw_CachePic("gfx/editlights/cubemapnoshadowlight", true);
- r_editlights_sprselection = Draw_CachePic("gfx/editlights/selection", true);
+ r_editlights_sprcursor = Draw_CachePic ("gfx/editlights/cursor");
+ r_editlights_sprlight = Draw_CachePic ("gfx/editlights/light");
+ r_editlights_sprnoshadowlight = Draw_CachePic ("gfx/editlights/noshadow");
+ r_editlights_sprcubemaplight = Draw_CachePic ("gfx/editlights/cubemaplight");
+ r_editlights_sprcubemapnoshadowlight = Draw_CachePic ("gfx/editlights/cubemapnoshadowlight");
+ r_editlights_sprselection = Draw_CachePic ("gfx/editlights/selection");
}
void R_Shadow_ValidateCvars(void)
void R_Shadow_RenderMode_Reset(void)
{
CHECKGLERROR
- if (r_shadow_rendermode == R_SHADOW_RENDERMODE_LIGHT_GLSL)
- {
- qglUseProgramObjectARB(0);CHECKGLERROR
- }
- else if (r_shadow_rendermode == R_SHADOW_RENDERMODE_STENCILTWOSIDE)
+ if (r_shadow_rendermode == R_SHADOW_RENDERMODE_STENCILTWOSIDE)
{
qglDisable(GL_STENCIL_TEST_TWO_SIDE_EXT);CHECKGLERROR
}
GL_Color(1, 1, 1, 1);
GL_ColorMask(r_refdef.view.colormask[0], r_refdef.view.colormask[1], r_refdef.view.colormask[2], 1);
GL_BlendFunc(GL_ONE, GL_ZERO);
+ R_SetupGenericShader(false);
}
void R_Shadow_RenderMode_StencilShadowVolumes(qboolean clearstencil)
R_Shadow_RenderMode_Reset();
GL_ColorMask(0, 0, 0, 0);
GL_PolygonOffset(r_refdef.shadowpolygonfactor, r_refdef.shadowpolygonoffset);CHECKGLERROR
+ R_SetupDepthOrShadowShader();
qglDepthFunc(GL_LESS);CHECKGLERROR
qglEnable(GL_STENCIL_TEST);CHECKGLERROR
r_shadow_rendermode = r_shadow_shadowingrendermode;
// do global setup needed for the chosen lighting mode
if (r_shadow_rendermode == R_SHADOW_RENDERMODE_LIGHT_GLSL)
{
- R_Mesh_TexBind(0, R_GetTexture(r_texture_blanknormalmap)); // normal
- R_Mesh_TexBind(1, R_GetTexture(r_texture_white)); // diffuse
- R_Mesh_TexBind(2, R_GetTexture(r_texture_white)); // gloss
- R_Mesh_TexBindCubeMap(3, R_GetTexture(rsurface.rtlight->currentcubemap)); // light filter
- R_Mesh_TexBind(4, R_GetTexture(r_texture_fogattenuation)); // fog
- R_Mesh_TexBind(5, R_GetTexture(r_texture_white)); // pants
- R_Mesh_TexBind(6, R_GetTexture(r_texture_white)); // shirt
- R_Mesh_TexBind(7, R_GetTexture(r_texture_white)); // lightmap
- R_Mesh_TexBind(8, R_GetTexture(r_texture_blanknormalmap)); // deluxemap
- R_Mesh_TexBind(9, R_GetTexture(r_texture_black)); // glow
- //R_Mesh_TexMatrix(3, rsurface.entitytolight); // light filter matrix
- GL_BlendFunc(GL_SRC_ALPHA, GL_ONE);
+ R_Mesh_TexBindCubeMap(GL20TU_CUBE, R_GetTexture(rsurface.rtlight->currentcubemap)); // light filter
GL_ColorMask(r_refdef.view.colormask[0], r_refdef.view.colormask[1], r_refdef.view.colormask[2], 0);
- CHECKGLERROR
}
+ else if (r_shadow_rendermode == R_SHADOW_RENDERMODE_LIGHT_VERTEX)
+ R_Mesh_ColorPointer(rsurface.array_color4f, 0, 0);
+ GL_BlendFunc(GL_SRC_ALPHA, GL_ONE);
}
void R_Shadow_RenderMode_VisibleShadowVolumes(void)
static void R_Shadow_RenderLighting_VisibleLighting(int firstvertex, int numvertices, int numtriangles, const int *element3i, int element3i_bufferobject, size_t element3i_bufferoffset, const vec3_t lightcolorbase, const vec3_t lightcolorpants, const vec3_t lightcolorshirt, rtexture_t *basetexture, rtexture_t *pantstexture, rtexture_t *shirttexture, rtexture_t *normalmaptexture, rtexture_t *glosstexture, float ambientscale, float diffusescale, float specularscale, qboolean dopants, qboolean doshirt)
{
// used to display how many times a surface is lit for level design purposes
- GL_Color(0.1 * r_refdef.view.colorscale, 0.025 * r_refdef.view.colorscale, 0, 1);
- R_Mesh_ColorPointer(NULL, 0, 0);
- R_Mesh_ResetTextureState();
R_Mesh_Draw(firstvertex, numvertices, numtriangles, element3i, element3i_bufferobject, element3i_bufferoffset);
}
{
// ARB2 GLSL shader path (GFFX5200, Radeon 9500)
R_SetupSurfaceShader(lightcolorbase, false, ambientscale, diffusescale, specularscale, RSURFPASS_RTLIGHT);
+ if ((rsurface.texture->currentmaterialflags & MATERIALFLAG_VERTEXTEXTUREBLEND))
+ R_Mesh_ColorPointer(rsurface.modellightmapcolor4f, rsurface.modellightmapcolor4f_bufferobject, rsurface.modellightmapcolor4f_bufferoffset);
+ else
+ R_Mesh_ColorPointer(NULL, 0, 0);
R_Mesh_TexMatrix(0, &rsurface.texture->currenttexmatrix);
- R_Mesh_TexBind(0, R_GetTexture(rsurface.texture->currentskinframe->nmap));
- R_Mesh_TexBind(1, R_GetTexture(rsurface.texture->basetexture));
- R_Mesh_TexBind(2, R_GetTexture(rsurface.texture->glosstexture));
- R_Mesh_TexBindCubeMap(3, R_GetTexture(rsurface.rtlight->currentcubemap));
- R_Mesh_TexBind(4, R_GetTexture(r_texture_fogattenuation));
- R_Mesh_TexBind(5, R_GetTexture(rsurface.texture->currentskinframe->pants));
- R_Mesh_TexBind(6, R_GetTexture(rsurface.texture->currentskinframe->shirt));
- R_Mesh_TexBind(10, R_GetTexture(r_shadow_attenuationgradienttexture));
+ R_Mesh_TexBind(GL20TU_NORMAL, R_GetTexture(rsurface.texture->currentskinframe->nmap));
+ R_Mesh_TexBind(GL20TU_COLOR, R_GetTexture(rsurface.texture->basetexture));
+ R_Mesh_TexBind(GL20TU_GLOSS, R_GetTexture(rsurface.texture->glosstexture));
+ if (rsurface.texture->backgroundcurrentskinframe)
+ {
+ R_Mesh_TexBind(GL20TU_SECONDARY_NORMAL, R_GetTexture(rsurface.texture->backgroundcurrentskinframe->nmap));
+ R_Mesh_TexBind(GL20TU_SECONDARY_COLOR, R_GetTexture(rsurface.texture->backgroundbasetexture));
+ R_Mesh_TexBind(GL20TU_SECONDARY_GLOSS, R_GetTexture(rsurface.texture->backgroundglosstexture));
+ }
+ //R_Mesh_TexBindCubeMap(GL20TU_CUBE, R_GetTexture(rsurface.rtlight->currentcubemap));
+ R_Mesh_TexBind(GL20TU_FOGMASK, R_GetTexture(r_texture_fogattenuation));
+ R_Mesh_TexBind(GL20TU_PANTS, R_GetTexture(rsurface.texture->currentskinframe->pants));
+ R_Mesh_TexBind(GL20TU_SHIRT, R_GetTexture(rsurface.texture->currentskinframe->shirt));
+ R_Mesh_TexBind(GL20TU_ATTENUATION, R_GetTexture(r_shadow_attenuationgradienttexture));
R_Mesh_TexCoordPointer(0, 2, rsurface.texcoordtexture2f, rsurface.texcoordtexture2f_bufferobject, rsurface.texcoordtexture2f_bufferoffset);
R_Mesh_TexCoordPointer(1, 3, rsurface.svector3f, rsurface.svector3f_bufferobject, rsurface.svector3f_bufferoffset);
R_Mesh_TexCoordPointer(2, 3, rsurface.tvector3f, rsurface.tvector3f_bufferobject, rsurface.tvector3f_bufferoffset);
VectorScale(lightcolorpants, diffusescale * 2 * r_refdef.view.colorscale, diffusecolorpants);
VectorScale(lightcolorshirt, ambientscale * 2 * r_refdef.view.colorscale, ambientcolorshirt);
VectorScale(lightcolorshirt, diffusescale * 2 * r_refdef.view.colorscale, diffusecolorshirt);
- GL_BlendFunc(GL_SRC_ALPHA, GL_ONE);
- R_Mesh_ColorPointer(rsurface.array_color4f, 0, 0);
memset(&m, 0, sizeof(m));
m.tex[0] = R_GetTexture(basetexture);
m.texmatrix[0] = rsurface.texture->currenttexmatrix;
{
// set up properties for rendering light onto this entity
RSurf_ActiveModelEntity(ent, true, true);
+ GL_AlphaTest(false);
Matrix4x4_Concat(&rsurface.entitytolight, &rsurface.rtlight->matrix_worldtolight, &ent->matrix);
Matrix4x4_Concat(&rsurface.entitytoattenuationxyz, &matrix_attenuationxyz, &rsurface.entitytolight);
Matrix4x4_Concat(&rsurface.entitytoattenuationz, &matrix_attenuationz, &rsurface.entitytolight);
// set up properties for rendering light onto this entity
RSurf_ActiveWorldEntity();
+ GL_AlphaTest(false);
rsurface.entitytolight = rsurface.rtlight->matrix_worldtolight;
Matrix4x4_Concat(&rsurface.entitytoattenuationxyz, &matrix_attenuationxyz, &rsurface.entitytolight);
Matrix4x4_Concat(&rsurface.entitytoattenuationz, &matrix_attenuationz, &rsurface.entitytolight);
// count this light in the r_speeds
r_refdef.stats.lights++;
- if (r_showshadowvolumes.integer && r_refdef.view.showdebug && numsurfaces + numshadowentities + numshadowentities_noselfshadow && rtlight->shadow && (rtlight->isstatic ? r_refdef.rtworldshadows : r_refdef.rtdlightshadows))
+ if (r_showshadowvolumes.integer && r_refdef.view.showdebug && numsurfaces + numshadowentities + numshadowentities_noselfshadow && rtlight->shadow && (rtlight->isstatic ? r_refdef.scene.rtworldshadows : r_refdef.scene.rtdlightshadows))
{
// optionally draw visible shape of the shadow volumes
// for performance analysis by level designers
R_Shadow_DrawEntityShadow(shadowentities_noselfshadow[i]);
}
- if (gl_stencil && numsurfaces + numshadowentities + numshadowentities_noselfshadow && rtlight->shadow && (rtlight->isstatic ? r_refdef.rtworldshadows : r_refdef.rtdlightshadows))
+ if (gl_stencil && numsurfaces + numshadowentities + numshadowentities_noselfshadow && rtlight->shadow && (rtlight->isstatic ? r_refdef.scene.rtworldshadows : r_refdef.scene.rtdlightshadows))
{
// draw stencil shadow volumes to mask off pixels that are in shadow
// so that they won't receive lighting
R_Shadow_RenderMode_Begin();
- flag = r_refdef.rtworld ? LIGHTFLAG_REALTIMEMODE : LIGHTFLAG_NORMALMODE;
+ flag = r_refdef.scene.rtworld ? LIGHTFLAG_REALTIMEMODE : LIGHTFLAG_NORMALMODE;
if (r_shadow_debuglight.integer >= 0)
{
lightindex = r_shadow_debuglight.integer;
R_DrawRTLight(&light->rtlight, visible);
}
}
- if (r_refdef.rtdlight)
+ if (r_refdef.scene.rtdlight)
for (lnum = 0;lnum < r_refdef.scene.numlights;lnum++)
R_DrawRTLight(&r_refdef.scene.lights[lnum], visible);
R_Shadow_RenderMode_End();
}
-extern void R_SetupView(void);
+extern void R_SetupView(qboolean allowwaterclippingplane);
extern cvar_t r_shadows_throwdistance;
void R_DrawModelShadows(void)
{
R_Mesh_Draw(0, 4, 2, polygonelements, 0, 0);
// restoring the perspective view is done by R_RenderScene
- //R_SetupView();
+ //R_SetupView(true);
// restore other state to normal
R_Shadow_RenderMode_End();
if (r_coronas.value < (1.0f / 256.0f) && !gl_flashblend.integer)
return;
R_Mesh_Matrix(&identitymatrix);
- flag = r_refdef.rtworld ? LIGHTFLAG_REALTIMEMODE : LIGHTFLAG_NORMALMODE;
+ flag = r_refdef.scene.rtworld ? LIGHTFLAG_REALTIMEMODE : LIGHTFLAG_NORMALMODE;
// FIXME: these traces should scan all render entities instead of cl.world
for (lightindex = 0;lightindex < Mem_ExpandableArray_IndexRange(&r_shadow_worldlightsarray);lightindex++)
{
// if a cubemap loaded, upload it
if (cubemappixels)
{
+ if (developer_loading.integer)
+ Con_Printf("loading cubemap \"%s\"\n", basename);
+
if (!r_shadow_filters_texturepool)
r_shadow_filters_texturepool = R_AllocTexturePool();
cubemaptexture = R_LoadTextureCubeMap(r_shadow_filters_texturepool, basename, cubemapsize, cubemappixels, TEXTYPE_BGRA, TEXF_PRECACHE | (gl_texturecompression_lightcubemaps.integer ? TEXF_COMPRESS : 0), NULL);
}
else
{
- Con_Printf("Failed to load Cubemap \"%s\", tried ", basename);
- for (j = 0;j < 3;j++)
- for (i = 0;i < 6;i++)
- Con_Printf("%s\"%s%s.tga\"", j + i > 0 ? ", " : "", basename, suffix[j][i].suffix);
- Con_Print(" and was unable to find any of them.\n");
+ Con_DPrintf("failed to load cubemap \"%s\"\n", basename);
+ if (developer_loading.integer)
+ {
+ Con_Printf("(tried tried images ");
+ for (j = 0;j < 3;j++)
+ for (i = 0;i < 6;i++)
+ Con_Printf("%s\"%s%s.tga\"", j + i > 0 ? ", " : "", basename, suffix[j][i].suffix);
+ Con_Print(" and was unable to find any of them).\n");
+ }
}
return cubemaptexture;
}
void R_Shadow_FreeCubemaps(void)
{
+ int i;
+ for (i = 0;i < numcubemaps;i++)
+ {
+ if (developer_loading.integer)
+ Con_Printf("unloading cubemap \"%s\"\n", cubemaps[i].basename);
+ R_FreeTexture(cubemaps[i].texture);
+ }
+
numcubemaps = 0;
R_FreeTexturePool(&r_shadow_filters_texturepool);
}
int n, a, style, shadow, flags;
char tempchar, *lightsstring, *s, *t, name[MAX_QPATH], cubemapname[MAX_QPATH];
float origin[3], radius, color[3], angles[3], corona, coronasizescale, ambientscale, diffusescale, specularscale;
- if (r_refdef.scene.worldmodel == NULL)
+ if (cl.worldmodel == NULL)
{
Con_Print("No map loaded.\n");
return;
}
- FS_StripExtension (r_refdef.scene.worldmodel->name, name, sizeof (name));
+ FS_StripExtension (cl.worldmodel->name, name, sizeof (name));
strlcat (name, ".rtlights", sizeof (name));
lightsstring = (char *)FS_LoadFile(name, tempmempool, false, NULL);
if (lightsstring)
char line[MAX_INPUTLINE];
if (!Mem_ExpandableArray_IndexRange(&r_shadow_worldlightsarray))
return;
- if (r_refdef.scene.worldmodel == NULL)
+ if (cl.worldmodel == NULL)
{
Con_Print("No map loaded.\n");
return;
}
- FS_StripExtension (r_refdef.scene.worldmodel->name, name, sizeof (name));
+ FS_StripExtension (cl.worldmodel->name, name, sizeof (name));
strlcat (name, ".rtlights", sizeof (name));
bufchars = bufmaxchars = 0;
buf = NULL;
int n, a, style;
char tempchar, *lightsstring, *s, *t, name[MAX_QPATH];
float origin[3], radius, color[3], subtract, spotdir[3], spotcone, falloff, distbias;
- if (r_refdef.scene.worldmodel == NULL)
+ if (cl.worldmodel == NULL)
{
Con_Print("No map loaded.\n");
return;
}
- FS_StripExtension (r_refdef.scene.worldmodel->name, name, sizeof (name));
+ FS_StripExtension (cl.worldmodel->name, name, sizeof (name));
strlcat (name, ".lights", sizeof (name));
lightsstring = (char *)FS_LoadFile(name, tempmempool, false, NULL);
if (lightsstring)
float origin[3], angles[3], radius, color[3], light[4], fadescale, lightscale, originhack[3], overridecolor[3], vec[4];
char key[256], value[MAX_INPUTLINE];
- if (r_refdef.scene.worldmodel == NULL)
+ if (cl.worldmodel == NULL)
{
Con_Print("No map loaded.\n");
return;
}
// try to load a .ent file first
- FS_StripExtension (r_refdef.scene.worldmodel->name, key, sizeof (key));
+ FS_StripExtension (cl.worldmodel->name, key, sizeof (key));
strlcat (key, ".ent", sizeof (key));
data = entfiledata = (char *)FS_LoadFile(key, tempmempool, true, NULL);
// and if that is not found, fall back to the bsp file entity string
if (!data)
- data = r_refdef.scene.worldmodel->brush.entities;
+ data = cl.worldmodel->brush.entities;
if (!data)
return;
for (entnum = 0;COM_ParseToken_Simple(&data, false, false) && com_token[0] == '{';entnum++)
pflags = (int)atof(value);
else if (!strcmp("effects", key))
effects = (int)atof(value);
- else if (r_refdef.scene.worldmodel->type == mod_brushq3)
+ else if (cl.worldmodel->type == mod_brushq3)
{
if (!strcmp("scale", key))
lightscale = atof(value);
void R_Shadow_EditLights_Reload_f(void)
{
- if (!r_refdef.scene.worldmodel)
+ if (!cl.worldmodel)
return;
- strlcpy(r_shadow_mapname, r_refdef.scene.worldmodel->name, sizeof(r_shadow_mapname));
+ strlcpy(r_shadow_mapname, cl.worldmodel->name, sizeof(r_shadow_mapname));
R_Shadow_ClearWorldLights();
R_Shadow_LoadWorldLights();
if (!Mem_ExpandableArray_IndexRange(&r_shadow_worldlightsarray))
void R_Shadow_EditLights_Save_f(void)
{
- if (!r_refdef.scene.worldmodel)
+ if (!cl.worldmodel)
return;
R_Shadow_SaveWorldLights();
}
if (!r_fullbright.integer && r_refdef.scene.worldmodel && r_refdef.scene.worldmodel->brush.LightPoint)
{
- ambientcolor[0] = ambientcolor[1] = ambientcolor[2] = r_ambient.value * (2.0f / 128.0f);
+ ambientcolor[0] = ambientcolor[1] = ambientcolor[2] = r_refdef.scene.ambient * (2.0f / 128.0f);
r_refdef.scene.worldmodel->brush.LightPoint(r_refdef.scene.worldmodel, p, ambientcolor, diffusecolor, diffusenormal);
}
else