{
if (r_glsl_offsetmapping.integer)
{
- permutation |= SHADERPERMUTATION_OFFSETMAPPING;
- if (r_glsl_offsetmapping_reliefmapping.integer)
- permutation |= SHADERPERMUTATION_OFFSETMAPPING_RELIEFMAPPING;
+ if (rsurface.texture->offsetmapping == OFFSETMAPPING_LINEAR)
+ permutation |= SHADERPERMUTATION_OFFSETMAPPING;
+ else if (rsurface.texture->offsetmapping == OFFSETMAPPING_RELIEF)
+ permutation |= SHADERPERMUTATION_OFFSETMAPPING | SHADERPERMUTATION_OFFSETMAPPING_RELIEFMAPPING;
+ else if (rsurface.texture->offsetmapping != OFFSETMAPPING_OFF)
+ {
+ permutation |= SHADERPERMUTATION_OFFSETMAPPING;
+ if (r_glsl_offsetmapping_reliefmapping.integer)
+ permutation |= SHADERPERMUTATION_OFFSETMAPPING_RELIEFMAPPING;
+ }
}
if (rsurface.texture->currentmaterialflags & MATERIALFLAG_VERTEXTEXTUREBLEND)
permutation |= SHADERPERMUTATION_VERTEXTEXTUREBLEND;
{
if (r_glsl_offsetmapping.integer)
{
- permutation |= SHADERPERMUTATION_OFFSETMAPPING;
- if (r_glsl_offsetmapping_reliefmapping.integer)
- permutation |= SHADERPERMUTATION_OFFSETMAPPING_RELIEFMAPPING;
+ if (rsurface.texture->offsetmapping == OFFSETMAPPING_LINEAR)
+ permutation |= SHADERPERMUTATION_OFFSETMAPPING;
+ else if (rsurface.texture->offsetmapping == OFFSETMAPPING_RELIEF)
+ permutation |= SHADERPERMUTATION_OFFSETMAPPING | SHADERPERMUTATION_OFFSETMAPPING_RELIEFMAPPING;
+ else if (rsurface.texture->offsetmapping != OFFSETMAPPING_OFF)
+ {
+ permutation |= SHADERPERMUTATION_OFFSETMAPPING;
+ if (r_glsl_offsetmapping_reliefmapping.integer)
+ permutation |= SHADERPERMUTATION_OFFSETMAPPING_RELIEFMAPPING;
+ }
}
if (rsurface.texture->currentmaterialflags & MATERIALFLAG_VERTEXTEXTUREBLEND)
permutation |= SHADERPERMUTATION_VERTEXTEXTUREBLEND;
{
if (r_glsl_offsetmapping.integer)
{
- permutation |= SHADERPERMUTATION_OFFSETMAPPING;
- if (r_glsl_offsetmapping_reliefmapping.integer)
- permutation |= SHADERPERMUTATION_OFFSETMAPPING_RELIEFMAPPING;
+ if (rsurface.texture->offsetmapping == OFFSETMAPPING_LINEAR)
+ permutation |= SHADERPERMUTATION_OFFSETMAPPING;
+ else if (rsurface.texture->offsetmapping == OFFSETMAPPING_RELIEF)
+ permutation |= SHADERPERMUTATION_OFFSETMAPPING | SHADERPERMUTATION_OFFSETMAPPING_RELIEFMAPPING;
+ else if (rsurface.texture->offsetmapping != OFFSETMAPPING_OFF)
+ {
+ permutation |= SHADERPERMUTATION_OFFSETMAPPING;
+ if (r_glsl_offsetmapping_reliefmapping.integer)
+ permutation |= SHADERPERMUTATION_OFFSETMAPPING_RELIEFMAPPING;
+ }
}
if (rsurface.texture->currentmaterialflags & MATERIALFLAG_VERTEXTEXTUREBLEND)
permutation |= SHADERPERMUTATION_VERTEXTEXTUREBLEND;
{
if (r_glsl_offsetmapping.integer)
{
- permutation |= SHADERPERMUTATION_OFFSETMAPPING;
- if (r_glsl_offsetmapping_reliefmapping.integer)
- permutation |= SHADERPERMUTATION_OFFSETMAPPING_RELIEFMAPPING;
+ if (rsurface.texture->offsetmapping == OFFSETMAPPING_LINEAR)
+ permutation |= SHADERPERMUTATION_OFFSETMAPPING;
+ else if (rsurface.texture->offsetmapping == OFFSETMAPPING_RELIEF)
+ permutation |= SHADERPERMUTATION_OFFSETMAPPING | SHADERPERMUTATION_OFFSETMAPPING_RELIEFMAPPING;
+ else if (rsurface.texture->offsetmapping != OFFSETMAPPING_OFF)
+ {
+ permutation |= SHADERPERMUTATION_OFFSETMAPPING;
+ if (r_glsl_offsetmapping_reliefmapping.integer)
+ permutation |= SHADERPERMUTATION_OFFSETMAPPING_RELIEFMAPPING;
+ }
}
if (rsurface.texture->currentmaterialflags & MATERIALFLAG_VERTEXTEXTUREBLEND)
permutation |= SHADERPERMUTATION_VERTEXTEXTUREBLEND;
{
if (r_glsl_offsetmapping.integer)
{
- permutation |= SHADERPERMUTATION_OFFSETMAPPING;
- if (r_glsl_offsetmapping_reliefmapping.integer)
- permutation |= SHADERPERMUTATION_OFFSETMAPPING_RELIEFMAPPING;
+ if (rsurface.texture->offsetmapping == OFFSETMAPPING_LINEAR)
+ permutation |= SHADERPERMUTATION_OFFSETMAPPING;
+ else if (rsurface.texture->offsetmapping == OFFSETMAPPING_RELIEF)
+ permutation |= SHADERPERMUTATION_OFFSETMAPPING | SHADERPERMUTATION_OFFSETMAPPING_RELIEFMAPPING;
+ else if (rsurface.texture->offsetmapping != OFFSETMAPPING_OFF)
+ {
+ permutation |= SHADERPERMUTATION_OFFSETMAPPING;
+ if (r_glsl_offsetmapping_reliefmapping.integer)
+ permutation |= SHADERPERMUTATION_OFFSETMAPPING_RELIEFMAPPING;
+ }
}
if (rsurface.texture->currentmaterialflags & MATERIALFLAG_VERTEXTEXTUREBLEND)
permutation |= SHADERPERMUTATION_VERTEXTEXTUREBLEND;
{
if (r_glsl_offsetmapping.integer)
{
- permutation |= SHADERPERMUTATION_OFFSETMAPPING;
- if (r_glsl_offsetmapping_reliefmapping.integer)
- permutation |= SHADERPERMUTATION_OFFSETMAPPING_RELIEFMAPPING;
+ if (rsurface.texture->offsetmapping == OFFSETMAPPING_LINEAR)
+ permutation |= SHADERPERMUTATION_OFFSETMAPPING;
+ else if (rsurface.texture->offsetmapping == OFFSETMAPPING_RELIEF)
+ permutation |= SHADERPERMUTATION_OFFSETMAPPING | SHADERPERMUTATION_OFFSETMAPPING_RELIEFMAPPING;
+ else if (rsurface.texture->offsetmapping != OFFSETMAPPING_OFF)
+ {
+ permutation |= SHADERPERMUTATION_OFFSETMAPPING;
+ if (r_glsl_offsetmapping_reliefmapping.integer)
+ permutation |= SHADERPERMUTATION_OFFSETMAPPING_RELIEFMAPPING;
+ }
}
if (rsurface.texture->currentmaterialflags & MATERIALFLAG_VERTEXTEXTUREBLEND)
permutation |= SHADERPERMUTATION_VERTEXTEXTUREBLEND;
if (r_glsl_permutation->loc_FogPlaneViewDist >= 0) qglUniform1fARB(r_glsl_permutation->loc_FogPlaneViewDist, rsurface.fogplaneviewdist);
if (r_glsl_permutation->loc_FogRangeRecip >= 0) qglUniform1fARB(r_glsl_permutation->loc_FogRangeRecip, rsurface.fograngerecip);
if (r_glsl_permutation->loc_FogHeightFade >= 0) qglUniform1fARB(r_glsl_permutation->loc_FogHeightFade, rsurface.fogheightfade);
- if (r_glsl_permutation->loc_OffsetMapping_Scale >= 0) qglUniform1fARB(r_glsl_permutation->loc_OffsetMapping_Scale, r_glsl_offsetmapping_scale.value);
+ if (r_glsl_permutation->loc_OffsetMapping_Scale >= 0) qglUniform1fARB(r_glsl_permutation->loc_OffsetMapping_Scale, r_glsl_offsetmapping_scale.value*rsurface.texture->offsetscale);
if (r_glsl_permutation->loc_ScreenToDepth >= 0) qglUniform2fARB(r_glsl_permutation->loc_ScreenToDepth, r_refdef.view.viewport.screentodepth[0], r_refdef.view.viewport.screentodepth[1]);
if (r_glsl_permutation->loc_PixelToScreenTexCoord >= 0) qglUniform2fARB(r_glsl_permutation->loc_PixelToScreenTexCoord, 1.0f/vid.width, 1.0f/vid.height);
texture.basematerialflags = materialflags | MATERIALFLAG_CUSTOMSURFACE | MATERIALFLAG_WALL;
texture.currentskinframe = skinframe;
texture.currenttexmatrix = *texmatrix; // requires MATERIALFLAG_CUSTOMSURFACE
+ texture.offsetmapping = OFFSETMAPPING_OFF;
+ texture.offsetscale = 1;
texture.specularscalemod = 1;
texture.specularpowermod = 1;
if (texture->currentskinframe->hasalpha)
texture->basematerialflags |= MATERIALFLAG_ALPHA | MATERIALFLAG_BLENDED | MATERIALFLAG_NOSHADOW;
texture->currentmaterialflags = texture->basematerialflags;
+ texture->offsetmapping = OFFSETMAPPING_OFF;
+ texture->offsetscale = 1;
texture->specularscalemod = 1;
texture->specularpowermod = 1;
texture->surfaceflags = 0;
cvar_t mod_q3bsp_lightmapmergepower = {CVAR_SAVE, "mod_q3bsp_lightmapmergepower", "4", "merges the quake3 128x128 lightmap textures into larger lightmap group textures to speed up rendering, 1 = 256x256, 2 = 512x512, 3 = 1024x1024, 4 = 2048x2048, 5 = 4096x4096, ..."};
cvar_t mod_q3bsp_nolightmaps = {CVAR_SAVE, "mod_q3bsp_nolightmaps", "0", "do not load lightmaps in Q3BSP maps (to save video RAM, but be warned: it looks ugly)"};
cvar_t mod_q3bsp_tracelineofsight_brushes = {0, "mod_q3bsp_tracelineofsight_brushes", "0", "enables culling of entities behind detail brushes, curves, etc"};
+cvar_t mod_q3shader_default_offsetmapping = {CVAR_SAVE, "mod_q3shader_default_offsetmapping", "1", "use offsetmapping by default on all surfaces"};
+
cvar_t mod_q1bsp_polygoncollisions = {0, "mod_q1bsp_polygoncollisions", "0", "disables use of precomputed cliphulls and instead collides with polygons (uses Bounding Interval Hierarchy optimizations)"};
cvar_t mod_collision_bih = {0, "mod_collision_bih", "1", "enables use of generated Bounding Interval Hierarchy tree instead of compiled bsp tree in collision code"};
cvar_t mod_recalculatenodeboxes = {0, "mod_recalculatenodeboxes", "1", "enables use of generated node bounding boxes based on BSP tree portal reconstruction, rather than the node boxes supplied by the map compiler"};
Cvar_RegisterVariable(&mod_q3bsp_lightmapmergepower);
Cvar_RegisterVariable(&mod_q3bsp_nolightmaps);
Cvar_RegisterVariable(&mod_q3bsp_tracelineofsight_brushes);
+ Cvar_RegisterVariable(&mod_q3shader_default_offsetmapping);
Cvar_RegisterVariable(&mod_q1bsp_polygoncollisions);
Cvar_RegisterVariable(&mod_collision_bih);
Cvar_RegisterVariable(&mod_recalculatenodeboxes);
tx->reflectfactor = 1;
Vector4Set(tx->reflectcolor4f, 1, 1, 1, 1);
tx->r_water_wateralpha = 1;
+ tx->offsetmapping = OFFSETMAPPING_OFF;
+ tx->offsetscale = 1;
tx->specularscalemod = 1;
tx->specularpowermod = 1;
}
}
extern cvar_t r_picmipworld;
+extern cvar_t mod_q3shader_default_offsetmapping;
void Mod_LoadQ3Shaders(void)
{
int j;
shader.reflectfactor = 1;
Vector4Set(shader.reflectcolor4f, 1, 1, 1, 1);
shader.r_water_wateralpha = 1;
+ shader.offsetmapping = (mod_q3shader_default_offsetmapping.value) ? OFFSETMAPPING_DEFAULT : OFFSETMAPPING_OFF;
+ shader.offsetscale = 1;
shader.specularscalemod = 1;
shader.specularpowermod = 1;
{
shader.specularpowermod = atof(parameter[1]);
}
+ else if (!strcasecmp(parameter[0], "dpoffsetmapping") && numparameters >= 3)
+ {
+ if (!strcasecmp(parameter[1], "disable") || !strcasecmp(parameter[1], "none") || !strcasecmp(parameter[1], "off"))
+ shader.offsetmapping = OFFSETMAPPING_OFF;
+ else if (!strcasecmp(parameter[1], "default"))
+ shader.offsetmapping = OFFSETMAPPING_DEFAULT;
+ else if (!strcasecmp(parameter[1], "linear"))
+ shader.offsetmapping = OFFSETMAPPING_LINEAR;
+ else if (!strcasecmp(parameter[1], "relief"))
+ shader.offsetmapping = OFFSETMAPPING_RELIEF;
+ shader.offsetscale = atof(parameter[2]);
+ }
else if (!strcasecmp(parameter[0], "deformvertexes") && numparameters >= 2)
{
int i, deformindex;
texflagsmask &= ~TEXF_PICMIP;
if(!(defaulttexflags & TEXF_COMPRESS))
texflagsmask &= ~TEXF_COMPRESS;
- texture->specularscalemod = 1; // unless later loaded from the shader
- texture->specularpowermod = 1; // unless later loaded from the shader
+ // unless later loaded from the shader
+ texture->offsetmapping = (mod_q3shader_default_offsetmapping.value) ? OFFSETMAPPING_DEFAULT : OFFSETMAPPING_OFF;
+ texture->offsetscale = 1;
+ texture->specularscalemod = 1;
+ texture->specularpowermod = 1;
// WHEN ADDING DEFAULTS HERE, REMEMBER TO SYNC TO SHADER LOADING ABOVE
// HERE, AND Q1BSP LOADING
// JUST GREP FOR "specularscalemod = 1".
texture->reflectfactor = shader->reflectfactor;
Vector4Copy(shader->reflectcolor4f, texture->reflectcolor4f);
texture->r_water_wateralpha = shader->r_water_wateralpha;
+ texture->offsetmapping = shader->offsetmapping;
+ texture->offsetscale = shader->offsetscale;
texture->specularscalemod = shader->specularscalemod;
texture->specularpowermod = shader->specularpowermod;
if (shader->dpreflectcube[0])
}
q3shaderinfo_deform_t;
+typedef enum dpoffsetmapping_technique_s
+{
+ OFFSETMAPPING_OFF, // none
+ OFFSETMAPPING_DEFAULT, // cvar-set
+ OFFSETMAPPING_LINEAR, // linear
+ OFFSETMAPPING_RELIEF // relief
+}dpoffsetmapping_technique_t;
+
+
typedef struct q3shaderinfo_s
{
char name[Q3PATHLENGTH];
vec4_t reflectcolor4f; // color tint of reflection (including alpha factor)
float r_water_wateralpha; // additional wateralpha to apply when r_water is active
+ // offsetmapping
+ dpoffsetmapping_technique_t offsetmapping;
+ float offsetscale;
+
// gloss
float specularscalemod;
float specularpowermod;
vec4_t reflectcolor4f; // color tint of reflection (including alpha factor)
float r_water_wateralpha; // additional wateralpha to apply when r_water is active
+ // offsetmapping
+ dpoffsetmapping_technique_t offsetmapping;
+ float offsetscale;
+
// gloss
float specularscalemod;
float specularpowermod;
}
-texture_t;
+ texture_t;
typedef struct mtexinfo_s
{
{
if (!skinframe)
skinframe = R_SkinFrame_LoadMissing();
+ texture->offsetmapping = OFFSETMAPPING_OFF;
+ texture->offsetscale = 1;
texture->specularscalemod = 1;
texture->specularpowermod = 1;
texture->basematerialflags = MATERIALFLAG_WALL;