mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-01-18 15:42:34 +00:00
Ok, it had to be done: Removed shader support for pre GLSL 1.3/GL 3.0 hardware. The compromises needed to accomodate these are just too bad and would block any attempt at streamlining the code.
This commit is contained in:
parent
92b9814460
commit
09f4071436
23 changed files with 132 additions and 261 deletions
|
@ -356,7 +356,14 @@ void InitGLRMapinfoData()
|
|||
glset.map_notexturefill = opt->notexturefill;
|
||||
glset.skyrotatevector = opt->skyrotatevector;
|
||||
glset.skyrotatevector2 = opt->skyrotatevector2;
|
||||
if (gl.shadermodel == 2 && glset.map_lightmode ==2) glset.map_lightmode = 3;
|
||||
if (!gl.hasGLSL())
|
||||
{
|
||||
// light modes 2 and 8 require shaders
|
||||
if (glset.map_lightmode == 2 || glset.map_lightmode == 8)
|
||||
{
|
||||
glset.map_lightmode = 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -70,7 +70,17 @@ CUSTOM_CVAR (Bool, gl_lights, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOIN
|
|||
|
||||
CUSTOM_CVAR (Bool, gl_dynlight_shader, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
|
||||
{
|
||||
if (self && (gl.maxuniforms < 1024 || gl.shadermodel < 4)) self = false;
|
||||
if (self)
|
||||
{
|
||||
if (!gl.hasGLSL())
|
||||
{
|
||||
self = false;
|
||||
}
|
||||
else if (gl.maxuniforms < 1024 && !(gl.flags & RFL_SHADER_STORAGE_BUFFER))
|
||||
{
|
||||
self = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CVAR (Bool, gl_attachedlights, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG);
|
||||
|
|
|
@ -753,7 +753,7 @@ void gl_RenderModel(GLSprite * spr, int cm)
|
|||
if(smf->flags & MDL_INHERITACTORPITCH) pitch += float(static_cast<double>(spr->actor->pitch >> 16) / (1 << 13) * 45 + static_cast<double>(spr->actor->pitch & 0x0000FFFF) / (1 << 29) * 45);
|
||||
if(smf->flags & MDL_INHERITACTORROLL) roll += float(static_cast<double>(spr->actor->roll >> 16) / (1 << 13) * 45 + static_cast<double>(spr->actor->roll & 0x0000FFFF) / (1 << 29) * 45);
|
||||
|
||||
if (gl.shadermodel < 4)
|
||||
if (!gl.hasGLSL())
|
||||
{
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
|
@ -795,7 +795,7 @@ void gl_RenderModel(GLSprite * spr, int cm)
|
|||
glRotatef(smf->pitchoffset, 0, 0, 1);
|
||||
glRotatef(-smf->rolloffset, 1, 0, 0);
|
||||
|
||||
if (gl.shadermodel >= 4) glActiveTexture(GL_TEXTURE0);
|
||||
if (gl.hasGLSL()) glActiveTexture(GL_TEXTURE0);
|
||||
|
||||
#if 0
|
||||
if (gl_light_models)
|
||||
|
@ -814,7 +814,7 @@ void gl_RenderModel(GLSprite * spr, int cm)
|
|||
|
||||
gl_RenderFrameModels( smf, spr->actor->state, spr->actor->tics, RUNTIME_TYPE(spr->actor), cm, NULL, translation );
|
||||
|
||||
if (gl.shadermodel < 4)
|
||||
if (!gl.hasGLSL())
|
||||
{
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPopMatrix();
|
||||
|
|
|
@ -80,12 +80,12 @@ CVAR(Bool, gl_brightfog, false, CVAR_ARCHIVE);
|
|||
|
||||
bool gl_BrightmapsActive()
|
||||
{
|
||||
return gl.shadermodel == 4 || (gl.shadermodel == 3 && gl_brightmap_shader);
|
||||
return gl.hasGLSL();
|
||||
}
|
||||
|
||||
bool gl_GlowActive()
|
||||
{
|
||||
return gl.shadermodel == 4 || (gl.shadermodel == 3 && gl_glow_shader);
|
||||
return gl.hasGLSL();
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -125,7 +125,7 @@ CUSTOM_CVAR(Int,gl_fogmode,1,CVAR_ARCHIVE|CVAR_NOINITCALL)
|
|||
{
|
||||
if (self>2) self=2;
|
||||
if (self<0) self=0;
|
||||
if (self == 2 && gl.shadermodel < 4) self = 1;
|
||||
if (self == 2 && !gl.hasGLSL()) self = 1;
|
||||
}
|
||||
|
||||
CUSTOM_CVAR(Int, gl_lightmode, 3 ,CVAR_ARCHIVE|CVAR_NOINITCALL)
|
||||
|
@ -133,7 +133,7 @@ CUSTOM_CVAR(Int, gl_lightmode, 3 ,CVAR_ARCHIVE|CVAR_NOINITCALL)
|
|||
int newself = self;
|
||||
if (newself > 4) newself=8; // use 8 for software lighting to avoid conflicts with the bit mask
|
||||
if (newself < 0) newself=0;
|
||||
if ((newself == 2 || newself == 8) && gl.shadermodel < 4) newself = 3;
|
||||
if ((newself == 2 || newself == 8) && !gl.hasGLSL()) newself = 3;
|
||||
if (self != newself) self = newself;
|
||||
glset.lightmode = newself;
|
||||
}
|
||||
|
|
|
@ -104,28 +104,13 @@ int FRenderState::SetupShader(bool cameratexture, int &shaderindex, int &cm, flo
|
|||
}
|
||||
}
|
||||
|
||||
if (gl.shadermodel == 4)
|
||||
if (gl.hasGLSL())
|
||||
{
|
||||
usecmshader = cm > CM_DEFAULT && cm < CM_MAXCOLORMAP && mTextureMode != TM_MASK;
|
||||
}
|
||||
else if (gl.shadermodel == 3)
|
||||
{
|
||||
usecmshader = (cameratexture || gl_colormap_shader) &&
|
||||
cm > CM_DEFAULT && cm < CM_MAXCOLORMAP && mTextureMode != TM_MASK;
|
||||
|
||||
if (!gl_brightmap_shader && shaderindex == 3)
|
||||
{
|
||||
shaderindex = 0;
|
||||
}
|
||||
else if (!gl_warp_shader && shaderindex !=3)
|
||||
{
|
||||
if (shaderindex <= 2) softwarewarp = shaderindex;
|
||||
shaderindex = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
usecmshader = cameratexture;
|
||||
usecmshader = false;
|
||||
softwarewarp = shaderindex > 0 && shaderindex < 3? shaderindex : 0;
|
||||
shaderindex = 0;
|
||||
}
|
||||
|
@ -149,43 +134,22 @@ bool FRenderState::ApplyShader()
|
|||
bool useshaders = false;
|
||||
FShader *activeShader = NULL;
|
||||
|
||||
if (mSpecialEffect > 0 && gl.shadermodel > 2)
|
||||
if (mSpecialEffect > 0 && gl.hasGLSL())
|
||||
{
|
||||
activeShader = GLRenderer->mShaderManager->BindEffect(mSpecialEffect);
|
||||
}
|
||||
else
|
||||
else if (gl.hasGLSL())
|
||||
{
|
||||
switch (gl.shadermodel)
|
||||
useshaders = (!m2D || mEffectState != 0 || mColormapState); // all 3D rendering and 2D with texture effects.
|
||||
}
|
||||
|
||||
if (useshaders)
|
||||
{
|
||||
FShaderContainer *shd = GLRenderer->mShaderManager->Get(mTextureEnabled? mEffectState : 4);
|
||||
|
||||
if (shd != NULL)
|
||||
{
|
||||
case 2:
|
||||
useshaders = (mTextureEnabled && mColormapState != CM_DEFAULT);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
useshaders = (
|
||||
mEffectState != 0 || // special shaders
|
||||
(mFogEnabled && (gl_fogmode == 2 || gl_fog_shader) && gl_fogmode != 0) || // fog requires a shader
|
||||
(mTextureEnabled && (mEffectState != 0 || mColormapState)) || // colormap
|
||||
mGlowEnabled // glow requires a shader
|
||||
);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
useshaders = (!m2D || mEffectState != 0 || mColormapState); // all 3D rendering and 2D with texture effects.
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (useshaders)
|
||||
{
|
||||
FShaderContainer *shd = GLRenderer->mShaderManager->Get(mTextureEnabled? mEffectState : 4);
|
||||
|
||||
if (shd != NULL)
|
||||
{
|
||||
activeShader = shd->Bind(mColormapState, mGlowEnabled, mWarpTime, mLightEnabled);
|
||||
}
|
||||
activeShader = shd->Bind(mColormapState, mGlowEnabled, mWarpTime, mLightEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -288,7 +288,7 @@ void FGLRenderer::SetProjection(float fov, float ratio, float fovratio)
|
|||
|
||||
void FGLRenderer::SetViewMatrix(bool mirror, bool planemirror)
|
||||
{
|
||||
if (gl.shadermodel >= 4)
|
||||
if (gl.hasGLSL())
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE7);
|
||||
glMatrixMode(GL_TEXTURE);
|
||||
|
|
|
@ -218,7 +218,7 @@ void GLSprite::Draw(int pass)
|
|||
// non-black fog with subtractive style needs special treatment
|
||||
if (!gl_isBlack(Colormap.FadeColor))
|
||||
{
|
||||
if (gl.shadermodel >= 4 && !gl_nolayer)
|
||||
if (gl.hasGLSL() && !gl_nolayer)
|
||||
{
|
||||
// fog layer only works on modern hardware.
|
||||
foglayer = true;
|
||||
|
@ -795,7 +795,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector)
|
|||
RenderStyle.CheckFuzz();
|
||||
if (RenderStyle.BlendOp == STYLEOP_Fuzz)
|
||||
{
|
||||
if (gl.shadermodel >= 4 && gl_fuzztype != 0)
|
||||
if (gl.hasGLSL() && gl_fuzztype != 0)
|
||||
{
|
||||
// Todo: implement shader selection here
|
||||
RenderStyle = LegacyRenderStyles[STYLE_Translucent];
|
||||
|
|
|
@ -338,7 +338,7 @@ void GLWall::RenderFogBoundary()
|
|||
if (gl_fogmode && gl_fixedcolormap == 0)
|
||||
{
|
||||
// with shaders this can be done properly
|
||||
if (gl.shadermodel == 4 || (gl.shadermodel == 3 && gl_fog_shader))
|
||||
if (gl.hasGLSL())
|
||||
{
|
||||
int rel = rellight + getExtraLight();
|
||||
gl_SetFog(lightlevel, rel, &Colormap, false);
|
||||
|
|
|
@ -313,7 +313,7 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep)
|
|||
vis.RenderStyle.CheckFuzz();
|
||||
if (vis.RenderStyle.BlendOp == STYLEOP_Fuzz)
|
||||
{
|
||||
if (gl.shadermodel >= 4 && gl_fuzztype != 0)
|
||||
if (gl.hasGLSL() && gl_fuzztype != 0)
|
||||
{
|
||||
// Todo: implement shader selection here
|
||||
vis.RenderStyle = LegacyRenderStyles[STYLE_Translucent];
|
||||
|
|
|
@ -79,7 +79,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
|
|||
static char buffer[10000];
|
||||
FString error;
|
||||
|
||||
if (gl.shadermodel > 0)
|
||||
if (gl.hasGLSL())
|
||||
{
|
||||
int vp_lump = Wads.CheckNumForFullName(vert_prog_lump);
|
||||
if (vp_lump == -1) I_Error("Unable to load '%s'", vert_prog_lump);
|
||||
|
@ -93,10 +93,6 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
|
|||
FString vp_comb;
|
||||
FString fp_comb;
|
||||
vp_comb = defines;
|
||||
if (gl.shadermodel < 4)
|
||||
{
|
||||
vp_comb << "#define NO_SM4\n";
|
||||
}
|
||||
|
||||
fp_comb = vp_comb;
|
||||
// This uses GetChars on the strings to get rid of terminating 0 characters.
|
||||
|
@ -307,52 +303,40 @@ FShaderContainer::FShaderContainer(const char *ShaderName, const char *ShaderPat
|
|||
I_Error("Unable to load shader %s:\n%s\n", name.GetChars(), err.GetMessage());
|
||||
}
|
||||
|
||||
if (gl.shadermodel > 2)
|
||||
for(int i = 0;i < NUM_SHADERS; i++)
|
||||
{
|
||||
for(int i = 0;i < NUM_SHADERS; i++)
|
||||
FString name;
|
||||
|
||||
name << ShaderName << shaderdesc[i];
|
||||
|
||||
try
|
||||
{
|
||||
FString name;
|
||||
|
||||
name << ShaderName << shaderdesc[i];
|
||||
|
||||
try
|
||||
FString str;
|
||||
if ((i&4) != 0)
|
||||
{
|
||||
FString str;
|
||||
if ((i&4) != 0)
|
||||
if (gl.maxuniforms < 1024)
|
||||
{
|
||||
if (gl.maxuniforms < 1024 || gl.shadermodel != 4)
|
||||
{
|
||||
shader[i] = NULL;
|
||||
continue;
|
||||
}
|
||||
// this can't be in the shader code due to ATI strangeness.
|
||||
str = "#version 120\n#extension GL_EXT_gpu_shader4 : enable\n";
|
||||
if (gl.MaxLights() == 128) str += "#define MAXLIGHTS128\n";
|
||||
}
|
||||
if ((i&8) == 0)
|
||||
{
|
||||
if (gl.shadermodel != 4)
|
||||
{
|
||||
shader[i] = NULL;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
str += shaderdefines[i];
|
||||
shader[i] = new FShader;
|
||||
if (!shader[i]->Load(name, "shaders/glsl/main.vp", "shaders/glsl/main.fp", ShaderPath, str.GetChars()))
|
||||
{
|
||||
delete shader[i];
|
||||
shader[i] = NULL;
|
||||
continue;
|
||||
}
|
||||
// this can't be in the shader code due to ATI strangeness.
|
||||
str = "#version 120\n#extension GL_EXT_gpu_shader4 : enable\n";
|
||||
if (gl.MaxLights() == 128) str += "#define MAXLIGHTS128\n";
|
||||
}
|
||||
catch(CRecoverableError &err)
|
||||
str += shaderdefines[i];
|
||||
shader[i] = new FShader;
|
||||
if (!shader[i]->Load(name, "shaders/glsl/main.vp", "shaders/glsl/main.fp", ShaderPath, str.GetChars()))
|
||||
{
|
||||
delete shader[i];
|
||||
shader[i] = NULL;
|
||||
I_Error("Unable to load shader %s:\n%s\n", name.GetChars(), err.GetMessage());
|
||||
}
|
||||
}
|
||||
catch(CRecoverableError &err)
|
||||
{
|
||||
shader[i] = NULL;
|
||||
I_Error("Unable to load shader %s:\n%s\n", name.GetChars(), err.GetMessage());
|
||||
}
|
||||
}
|
||||
else memset(shader, 0, sizeof(shader));
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -502,28 +486,15 @@ FShaderManager::~FShaderManager()
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void FShaderManager::Recompile()
|
||||
{
|
||||
Clean();
|
||||
CompileShaders();
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void FShaderManager::CompileShaders()
|
||||
{
|
||||
mActiveShader = mEffectShaders[0] = mEffectShaders[1] = NULL;
|
||||
if (gl.shadermodel > 0)
|
||||
if (gl.hasGLSL())
|
||||
{
|
||||
for(int i=0;defaultshaders[i].ShaderName != NULL;i++)
|
||||
{
|
||||
FShaderContainer * shc = new FShaderContainer(defaultshaders[i].ShaderName, defaultshaders[i].gettexelfunc);
|
||||
mTextureEffects.Push(shc);
|
||||
if (gl.shadermodel <= 2) return; // SM2 will only initialize the default shader
|
||||
}
|
||||
|
||||
for(unsigned i = 0; i < usershaders.Size(); i++)
|
||||
|
@ -531,25 +502,19 @@ void FShaderManager::CompileShaders()
|
|||
FString name = ExtractFileBase(usershaders[i]);
|
||||
FName sfn = name;
|
||||
|
||||
if (gl.shadermodel > 2)
|
||||
{
|
||||
FShaderContainer * shc = new FShaderContainer(sfn, usershaders[i]);
|
||||
mTextureEffects.Push(shc);
|
||||
}
|
||||
FShaderContainer * shc = new FShaderContainer(sfn, usershaders[i]);
|
||||
mTextureEffects.Push(shc);
|
||||
}
|
||||
|
||||
if (gl.shadermodel > 2)
|
||||
for(int i=0;i<NUM_EFFECTS;i++)
|
||||
{
|
||||
for(int i=0;i<NUM_EFFECTS;i++)
|
||||
FShader *eff = new FShader();
|
||||
if (!eff->Load(effectshaders[i].ShaderName, effectshaders[i].vp, effectshaders[i].fp1,
|
||||
effectshaders[i].fp2, effectshaders[i].defines))
|
||||
{
|
||||
FShader *eff = new FShader();
|
||||
if (!eff->Load(effectshaders[i].ShaderName, effectshaders[i].vp, effectshaders[i].fp1,
|
||||
effectshaders[i].fp2, effectshaders[i].defines))
|
||||
{
|
||||
delete eff;
|
||||
}
|
||||
else mEffectShaders[i] = eff;
|
||||
delete eff;
|
||||
}
|
||||
else mEffectShaders[i] = eff;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -604,7 +569,7 @@ int FShaderManager::Find(const char * shn)
|
|||
void FShaderManager::SetActiveShader(FShader *sh)
|
||||
{
|
||||
// shadermodel needs to be tested here because without it UseProgram will be NULL.
|
||||
if (gl.shadermodel > 0 && mActiveShader != sh)
|
||||
if (gl.hasGLSL() && mActiveShader != sh)
|
||||
{
|
||||
glUseProgram(sh == NULL? 0 : sh->GetHandle());
|
||||
mActiveShader = sh;
|
||||
|
|
|
@ -153,8 +153,6 @@ public:
|
|||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void Recompile();
|
||||
};
|
||||
|
||||
#define FIRST_USER_SHADER 12
|
||||
|
|
|
@ -73,9 +73,9 @@ CVAR(Bool, gl_aalines, false, CVAR_ARCHIVE)
|
|||
|
||||
FGLRenderer *GLRenderer;
|
||||
|
||||
void gl_SetupMenu();
|
||||
void gl_LoadExtensions();
|
||||
void gl_PrintStartupLog();
|
||||
void gl_SetupMenu();
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
|
|
|
@ -133,7 +133,6 @@ void gl_LoadExtensions()
|
|||
// This loads any function pointers and flags that require a vaild render context to
|
||||
// initialize properly
|
||||
|
||||
gl.shadermodel = 0; // assume no shader support
|
||||
gl.vendorstring=(char*)glGetString(GL_VENDOR);
|
||||
|
||||
if (CheckExtension("GL_ARB_texture_compression")) gl.flags|=RFL_TEXTURE_COMPRESSION;
|
||||
|
@ -141,23 +140,11 @@ void gl_LoadExtensions()
|
|||
if (CheckExtension("GL_ARB_buffer_storage")) gl.flags |= RFL_BUFFER_STORAGE;
|
||||
|
||||
gl.version = strtod((char*)glGetString(GL_VERSION), NULL);
|
||||
gl.glslversion = strtod((char*)glGetString(GL_SHADING_LANGUAGE_VERSION), NULL);
|
||||
if (Args->CheckParm("-noshader")) gl.glslversion = 0.0f;
|
||||
|
||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE,&gl.max_texturesize);
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
|
||||
// Rules:
|
||||
// SM4 will always use shaders. No option to switch them off is needed here.
|
||||
// SM3 has shaders optional but they are off by default (they will have a performance impact
|
||||
// SM2 only uses shaders for colormaps on camera textures and has no option to use them in general.
|
||||
// On SM2 cards the shaders will be too slow and show visual bugs (at least on GF 6800.)
|
||||
if (strcmp((const char*)glGetString(GL_SHADING_LANGUAGE_VERSION), "1.3") >= 0) gl.shadermodel = 4;
|
||||
else if (CheckExtension("GL_NV_vertex_program3")) gl.shadermodel = 3;
|
||||
else if (!strstr(gl.vendorstring, "NVIDIA")) gl.shadermodel = 3;
|
||||
else gl.shadermodel = 2; // Only for older NVidia cards which had notoriously bad shader support.
|
||||
|
||||
// Command line overrides for testing and problem cases.
|
||||
if (Args->CheckParm("-sm2") && gl.shadermodel > 2) gl.shadermodel = 2;
|
||||
else if (Args->CheckParm("-sm3") && gl.shadermodel > 3) gl.shadermodel = 3;
|
||||
|
||||
if (gl.version >= 3.f)
|
||||
{
|
||||
|
@ -187,7 +174,7 @@ void gl_PrintStartupLog()
|
|||
Printf ("Max. texture units: %d\n", v);
|
||||
glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &v);
|
||||
Printf ("Max. fragment uniforms: %d\n", v);
|
||||
if (gl.shadermodel == 4) gl.maxuniforms = v;
|
||||
if (gl.hasGLSL()) gl.maxuniforms = v;
|
||||
glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS, &v);
|
||||
Printf ("Max. vertex uniforms: %d\n", v);
|
||||
glGetIntegerv(GL_MAX_VARYING_FLOATS, &v);
|
||||
|
|
|
@ -6,11 +6,12 @@
|
|||
enum RenderFlags
|
||||
{
|
||||
// [BB] Added texture compression flags.
|
||||
RFL_TEXTURE_COMPRESSION=8,
|
||||
RFL_TEXTURE_COMPRESSION_S3TC=16,
|
||||
RFL_TEXTURE_COMPRESSION=1,
|
||||
RFL_TEXTURE_COMPRESSION_S3TC=2,
|
||||
|
||||
RFL_FRAMEBUFFER = 32,
|
||||
RFL_BUFFER_STORAGE = 64,
|
||||
RFL_FRAMEBUFFER = 4,
|
||||
RFL_BUFFER_STORAGE = 8,
|
||||
RFL_SHADER_STORAGE_BUFFER = 16,
|
||||
};
|
||||
|
||||
enum TexMode
|
||||
|
@ -30,9 +31,9 @@ enum TexMode
|
|||
struct RenderContext
|
||||
{
|
||||
unsigned int flags;
|
||||
unsigned int shadermodel;
|
||||
unsigned int maxuniforms;
|
||||
float version;
|
||||
float glslversion;
|
||||
int max_texturesize;
|
||||
char * vendorstring;
|
||||
|
||||
|
@ -40,6 +41,11 @@ struct RenderContext
|
|||
{
|
||||
return maxuniforms>=2048? 128:64;
|
||||
}
|
||||
|
||||
bool hasGLSL() const
|
||||
{
|
||||
return glslversion >= 1.3f;
|
||||
}
|
||||
};
|
||||
|
||||
extern RenderContext gl;
|
||||
|
|
|
@ -59,7 +59,7 @@ CUSTOM_CVAR (Float, vid_contrast, 1.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
|||
// when they are actually valid.
|
||||
void gl_SetupMenu()
|
||||
{
|
||||
if (gl.shadermodel < 4)
|
||||
if (!gl.hasGLSL())
|
||||
{
|
||||
// Radial fog and Doom lighting are not available in SM < 4 cards
|
||||
// The way they are implemented does not work well on older hardware.
|
||||
|
@ -95,28 +95,4 @@ void gl_SetupMenu()
|
|||
if (gl_fogmode == 2) gl_fogmode = 1;
|
||||
if (gl_dynlight_shader) gl_dynlight_shader = false;
|
||||
}
|
||||
|
||||
if (gl.shadermodel != 3)
|
||||
{
|
||||
// The shader menu will only be visible on SM3.
|
||||
// SM2 won't use shaders unless unavoidable (and then it's automatic) and SM4 will always use shaders.
|
||||
// Find the OpenGLOptions menu and remove the item named GLShaderOptions.
|
||||
|
||||
FMenuDescriptor **desc = MenuDescriptors.CheckKey("OpenGLOptions");
|
||||
if (desc != NULL && (*desc)->mType == MDESC_OptionsMenu)
|
||||
{
|
||||
FOptionMenuDescriptor *opt = (FOptionMenuDescriptor *)*desc;
|
||||
|
||||
FName shader = "GLShaderOptions";
|
||||
for(unsigned i=0;i<opt->mItems.Size();i++)
|
||||
{
|
||||
FName nm = opt->mItems[i]->GetAction(NULL);
|
||||
if (nm == shader)
|
||||
{
|
||||
delete opt->mItems[i];
|
||||
opt->mItems.Delete(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -225,7 +225,7 @@ unsigned char *gl_CreateUpsampledTextureBuffer ( const FTexture *inputTexture, u
|
|||
return inputBuffer;
|
||||
|
||||
// [BB] Don't upsample non-shader handled warped textures. Needs too much memory and time
|
||||
if (gl.shadermodel == 2 || (gl.shadermodel == 3 && inputTexture->bWarped))
|
||||
if (inputTexture->bWarped && !gl.hasGLSL())
|
||||
return inputBuffer;
|
||||
|
||||
switch (inputTexture->UseType)
|
||||
|
|
|
@ -624,7 +624,7 @@ FMaterial::FMaterial(FTexture * tx, bool forceexpand)
|
|||
{
|
||||
expanded = false;
|
||||
}
|
||||
else if (gl.shadermodel > 2)
|
||||
else if (gl.hasGLSL())
|
||||
{
|
||||
if (tx->gl_info.shaderindex >= FIRST_USER_SHADER)
|
||||
{
|
||||
|
@ -670,7 +670,7 @@ FMaterial::FMaterial(FTexture * tx, bool forceexpand)
|
|||
tex = tx;
|
||||
|
||||
tx->gl_info.mExpanded = expanded;
|
||||
FTexture *basetex = tx->GetRedirect(gl.shadermodel < 4);
|
||||
FTexture *basetex = tx->GetRedirect(!gl.hasGLSL());
|
||||
if (!expanded && !basetex->gl_info.mExpanded && basetex->UseType != FTexture::TEX_Sprite)
|
||||
{
|
||||
// check if the texture is just a simple redirect to a patch
|
||||
|
|
|
@ -14,13 +14,6 @@ OptionValue "EnhancedStealth"
|
|||
3, "Any fixed colormap"
|
||||
}
|
||||
|
||||
OptionValue "VBOModes"
|
||||
{
|
||||
0, "Off"
|
||||
1, "Static"
|
||||
2, "Dynamic"
|
||||
}
|
||||
|
||||
OptionValue "FilterModes"
|
||||
{
|
||||
0, "None"
|
||||
|
@ -186,17 +179,7 @@ OptionMenu "GLPrefOptions"
|
|||
Option "Particle style", gl_particles_style, "Particles"
|
||||
Slider "Ambient light level", gl_light_ambient, 1.0, 255.0, 5.0
|
||||
Option "Rendering quality", gl_render_precise, "Precision"
|
||||
Option "Use vertex buffer", gl_usevbo, "VBOModes"
|
||||
}
|
||||
|
||||
OptionMenu "GLShaderOptions"
|
||||
{
|
||||
Title "SHADER OPTIONS"
|
||||
Option "Enable brightness maps", gl_brightmap_shader, "OnOff"
|
||||
Option "Shaders for texture warp", gl_warp_shader, "OnOff"
|
||||
Option "Shaders for fog", gl_fog_shader, "OnOff"
|
||||
Option "Shaders for colormaps", gl_colormap_shader, "OnOff"
|
||||
Option "Shaders for glowing textures", gl_glow_shader, "OnOff"
|
||||
Option "Use vertex buffer", gl_usevbo, "OnOff"
|
||||
}
|
||||
|
||||
OptionMenu "OpenGLOptions"
|
||||
|
@ -204,7 +187,6 @@ OptionMenu "OpenGLOptions"
|
|||
Title "OPENGL OPTIONS"
|
||||
Submenu "Dynamic Light Options", "GLLightOptions"
|
||||
Submenu "Texture Options", "GLTextureGLOptions"
|
||||
Submenu "Shader Options", "GLShaderOptions"
|
||||
Submenu "Preferences", "GLPrefOptions"
|
||||
}
|
||||
|
||||
|
|
|
@ -18,18 +18,14 @@ void main()
|
|||
//
|
||||
// calculate fog factor
|
||||
//
|
||||
#ifndef NO_SM4
|
||||
if (fogenabled == -1)
|
||||
{
|
||||
fogdist = pixelpos.w;
|
||||
}
|
||||
else
|
||||
{
|
||||
fogdist = max(16.0, distance(pixelpos.xyz, camerapos));
|
||||
}
|
||||
#else
|
||||
if (fogenabled == -1)
|
||||
{
|
||||
fogdist = pixelpos.w;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
fogdist = max(16.0, distance(pixelpos.xyz, camerapos));
|
||||
}
|
||||
fogfactor = exp2 (fogparm.z * fogdist);
|
||||
gl_FragColor = vec4(fogcolor.rgb, 1.0 - fogfactor);
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ vec4 getLightColor(float fogdist, float fogfactor)
|
|||
//
|
||||
if (fogenabled > 0)
|
||||
{
|
||||
#if (!defined(NO_SM4) || defined(DOOMLIGHT)) && !defined SOFTLIGHT
|
||||
#if (defined(DOOMLIGHT)) && !defined SOFTLIGHT
|
||||
// special lighting mode 'Doom' not available on older cards for performance reasons.
|
||||
if (fogdist < fogparm.y)
|
||||
{
|
||||
|
@ -197,20 +197,14 @@ void main()
|
|||
//
|
||||
if (fogenabled != 0)
|
||||
{
|
||||
#ifndef NO_SM4
|
||||
if (fogenabled == 1 || fogenabled == -1)
|
||||
{
|
||||
fogdist = pixelpos.w;
|
||||
}
|
||||
else
|
||||
{
|
||||
fogdist = max(16.0, distance(pixelpos.xyz, camerapos));
|
||||
}
|
||||
#elif !defined(FOG_RADIAL)
|
||||
if (fogenabled == 1 || fogenabled == -1)
|
||||
{
|
||||
fogdist = pixelpos.w;
|
||||
#else
|
||||
}
|
||||
else
|
||||
{
|
||||
fogdist = max(16.0, distance(pixelpos.xyz, camerapos));
|
||||
#endif
|
||||
}
|
||||
fogfactor = exp2 (fogparm.z * fogdist);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -19,12 +19,8 @@ void main()
|
|||
lightlevel = lightlevel_in;
|
||||
#endif
|
||||
|
||||
#ifndef NO_SM4
|
||||
// Yes, I know... But using a texture matrix here saves me from the hassle of tracking its state across shaders. ;)
|
||||
vec4 worldcoord = gl_TextureMatrix[7] * gl_Vertex;
|
||||
#else
|
||||
vec4 worldcoord = gl_Vertex;
|
||||
#endif
|
||||
// We use texture matrix 7 as the model matrix and the modelview matrix as the view matrix.
|
||||
vec4 worldcoord = gl_TextureMatrix[7] * gl_Vertex;
|
||||
vec4 eyeCoordPos = gl_ModelViewMatrix * worldcoord;
|
||||
|
||||
gl_FrontColor = gl_Color;
|
||||
|
@ -55,11 +51,7 @@ void main()
|
|||
gl_TexCoord[0].xy = sst;
|
||||
#endif
|
||||
|
||||
#ifndef NO_SM4
|
||||
gl_Position = gl_ModelViewProjectionMatrix * worldcoord;
|
||||
#else
|
||||
gl_Position = ftransform();
|
||||
#endif
|
||||
gl_Position = gl_ModelViewProjectionMatrix * worldcoord;
|
||||
#ifdef __GLSL_CG_DATA_TYPES
|
||||
gl_ClipVertex = eyeCoordPos;
|
||||
#endif
|
||||
|
|
|
@ -16,19 +16,17 @@ vec4 getTexel(vec2 st)
|
|||
{
|
||||
vec4 texel = texture2D(tex, st);
|
||||
|
||||
#ifndef NO_TEXTUREMODE
|
||||
//
|
||||
// Apply texture modes
|
||||
//
|
||||
if (texturemode == 2)
|
||||
{
|
||||
texel.a = 1.0;
|
||||
}
|
||||
else if (texturemode == 1)
|
||||
{
|
||||
texel.rgb = vec3(1.0,1.0,1.0);
|
||||
}
|
||||
#endif
|
||||
//
|
||||
// Apply texture modes
|
||||
//
|
||||
if (texturemode == 2)
|
||||
{
|
||||
texel.a = 1.0;
|
||||
}
|
||||
else if (texturemode == 1)
|
||||
{
|
||||
texel.rgb = vec3(1.0,1.0,1.0);
|
||||
}
|
||||
|
||||
return texel;
|
||||
}
|
||||
|
|
|
@ -39,18 +39,14 @@ void main()
|
|||
//
|
||||
// calculate fog factor
|
||||
//
|
||||
#ifndef NO_SM4
|
||||
if (fogenabled == -1)
|
||||
{
|
||||
fogdist = pixelpos.w;
|
||||
}
|
||||
else
|
||||
{
|
||||
fogdist = max(16.0, distance(pixelpos.xyz, camerapos));
|
||||
}
|
||||
#else
|
||||
if (fogenabled == -1)
|
||||
{
|
||||
fogdist = pixelpos.w;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
fogdist = max(16.0, distance(pixelpos.xyz, camerapos));
|
||||
}
|
||||
fogfactor = exp2 (fogparm.z * fogdist);
|
||||
|
||||
vec4 frag = Process(vec4(1.0,1.0,1.0,1.0));
|
||||
|
|
Loading…
Reference in a new issue