From 9bb9470f7c1b16085494610699c09293be252aeb Mon Sep 17 00:00:00 2001 From: divverent Date: Tue, 30 Aug 2011 12:10:35 +0000 Subject: [PATCH] offsetbias: changed range to 0..1 to match what the shader does (agreed to with LordHavoc) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11312 d7cf8633-e32d-0410-b094-e92efae38249 --- gl_rmain.c | 6 +++--- model_brush.c | 2 ++ model_shared.c | 7 ++++--- model_shared.h | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/gl_rmain.c b/gl_rmain.c index 7ff3f1ad..edc1adca 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -2632,7 +2632,7 @@ void R_SetupShader_Surface(const vec3_t lightcolorbase, qboolean modellighting, max(1, r_glsl_offsetmapping_reliefmapping_refinesteps.integer) ); hlslPSSetParameter1f(D3DPSREGISTER_OffsetMapping_LodDistance, r_glsl_offsetmapping_lod_distance.integer) - hlslPSSetParameter1f(D3DPSREGISTER_OffsetMapping_Bias, rsurface.texture->offsetbias / 255.0f) + hlslPSSetParameter1f(D3DPSREGISTER_OffsetMapping_Bias, rsurface.texture->offsetbias) hlslPSSetParameter2f(D3DPSREGISTER_ScreenToDepth, r_refdef.view.viewport.screentodepth[0], r_refdef.view.viewport.screentodepth[1]); hlslPSSetParameter2f(D3DPSREGISTER_PixelToScreenTexCoord, 1.0f/vid.width, 1.0/vid.height); @@ -2794,7 +2794,7 @@ void R_SetupShader_Surface(const vec3_t lightcolorbase, qboolean modellighting, max(1, r_glsl_offsetmapping_reliefmapping_refinesteps.integer) ); if (r_glsl_permutation->loc_OffsetMapping_LodDistance >= 0) qglUniform1f(r_glsl_permutation->loc_OffsetMapping_LodDistance, r_glsl_offsetmapping_lod_distance.integer); - if (r_glsl_permutation->loc_OffsetMapping_Bias >= 0) qglUniform1f(r_glsl_permutation->loc_OffsetMapping_Bias, rsurface.texture->offsetbias / 255.0f); + if (r_glsl_permutation->loc_OffsetMapping_Bias >= 0) qglUniform1f(r_glsl_permutation->loc_OffsetMapping_Bias, rsurface.texture->offsetbias); if (r_glsl_permutation->loc_ScreenToDepth >= 0) qglUniform2f(r_glsl_permutation->loc_ScreenToDepth, r_refdef.view.viewport.screentodepth[0], r_refdef.view.viewport.screentodepth[1]); if (r_glsl_permutation->loc_PixelToScreenTexCoord >= 0) qglUniform2f(r_glsl_permutation->loc_PixelToScreenTexCoord, 1.0f/vid.width, 1.0f/vid.height); if (r_glsl_permutation->loc_BounceGridMatrix >= 0) {Matrix4x4_Concat(&tempmatrix, &r_shadow_bouncegridmatrix, &rsurface.matrix);Matrix4x4_ToArrayFloatGL(&tempmatrix, m16f);qglUniformMatrix4fv(r_glsl_permutation->loc_BounceGridMatrix, 1, false, m16f);} @@ -2941,7 +2941,7 @@ void R_SetupShader_Surface(const vec3_t lightcolorbase, qboolean modellighting, max(1, r_glsl_offsetmapping_reliefmapping_refinesteps.integer) ); DPSOFTRAST_Uniform1f(DPSOFTRAST_UNIFORM_OffsetMapping_LodDistance, r_glsl_offsetmapping_lod_distance.integer); - DPSOFTRAST_Uniform1f(DPSOFTRAST_UNIFORM_OffsetMapping_Bias, rsurface.texture->offsetbias / 255.0f); + DPSOFTRAST_Uniform1f(DPSOFTRAST_UNIFORM_OffsetMapping_Bias, rsurface.texture->offsetbias); DPSOFTRAST_Uniform2f(DPSOFTRAST_UNIFORM_ScreenToDepth, r_refdef.view.viewport.screentodepth[0], r_refdef.view.viewport.screentodepth[1]); DPSOFTRAST_Uniform2f(DPSOFTRAST_UNIFORM_PixelToScreenTexCoord, 1.0f/vid.width, 1.0f/vid.height); diff --git a/model_brush.c b/model_brush.c index d2819eb2..cb830aaf 100644 --- a/model_brush.c +++ b/model_brush.c @@ -49,6 +49,7 @@ cvar_t mod_q3bsp_lightmapmergepower = {CVAR_SAVE, "mod_q3bsp_lightmapmergepower" 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 that are using q3 shader files"}; +cvar_t mod_q3shader_default_offsetmapping_scale = {CVAR_SAVE, "mod_q3shader_default_offsetmapping_scale", "1", "default scale used for offsetmapping"}; cvar_t mod_q3shader_default_offsetmapping_bias = {CVAR_SAVE, "mod_q3shader_default_offsetmapping_bias", "0", "default bias used for offsetmapping"}; cvar_t mod_q3shader_default_polygonfactor = {0, "mod_q3shader_default_polygonfactor", "0", "biases depth values of 'polygonoffset' shaders to prevent z-fighting artifacts"}; cvar_t mod_q3shader_default_polygonoffset = {0, "mod_q3shader_default_polygonoffset", "-2", "biases depth values of 'polygonoffset' shaders to prevent z-fighting artifacts"}; @@ -87,6 +88,7 @@ void Mod_BrushInit(void) Cvar_RegisterVariable(&mod_q3bsp_nolightmaps); Cvar_RegisterVariable(&mod_q3bsp_tracelineofsight_brushes); Cvar_RegisterVariable(&mod_q3shader_default_offsetmapping); + Cvar_RegisterVariable(&mod_q3shader_default_offsetmapping_scale); Cvar_RegisterVariable(&mod_q3shader_default_offsetmapping_bias); Cvar_RegisterVariable(&mod_q3shader_default_polygonfactor); Cvar_RegisterVariable(&mod_q3shader_default_polygonoffset); diff --git a/model_shared.c b/model_shared.c index 81a669e3..523461cd 100644 --- a/model_shared.c +++ b/model_shared.c @@ -1623,6 +1623,7 @@ static void Q3Shader_AddToHash (q3shaderinfo_t* shader) extern cvar_t mod_noshader_default_offsetmapping; extern cvar_t mod_q3shader_default_offsetmapping; +extern cvar_t mod_q3shader_default_offsetmapping_scale; extern cvar_t mod_q3shader_default_offsetmapping_bias; extern cvar_t mod_q3shader_default_polygonoffset; extern cvar_t mod_q3shader_default_polygonfactor; @@ -1714,8 +1715,8 @@ void Mod_LoadQ3Shaders(void) 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.offsetbias = bound(0, mod_q3shader_default_offsetmapping_bias.integer, 255); + shader.offsetscale = mod_q3shader_default_offsetmapping_scale.value; + shader.offsetbias = mod_q3shader_default_offsetmapping_bias.value; shader.specularscalemod = 1; shader.specularpowermod = 1; shader.biaspolygonoffset = mod_q3shader_default_polygonoffset.value; @@ -2259,7 +2260,7 @@ void Mod_LoadQ3Shaders(void) if (numparameters >= 3) shader.offsetscale = atof(parameter[2]); if (numparameters >= 4) - shader.offsetbias = bound(0, atoi(parameter[3]), 255); + shader.offsetbias = atof(parameter[3]); } else if (!strcasecmp(parameter[0], "deformvertexes") && numparameters >= 2) { diff --git a/model_shared.h b/model_shared.h index 63960857..755751b9 100644 --- a/model_shared.h +++ b/model_shared.h @@ -471,7 +471,7 @@ typedef struct q3shaderinfo_s // offsetmapping dpoffsetmapping_technique_t offsetmapping; float offsetscale; - unsigned char offsetbias; + float offsetbias; // 0 is normal, 1 leads to alpha 0 being neutral and alpha 1 pushing "out" // polygonoffset (only used if Q3TEXTUREFLAG_POLYGONOFFSET) float biaspolygonoffset, biaspolygonfactor; -- 2.39.2