mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2024-11-24 04:41:53 +00:00
- replaced deprecated alpha testing with shader code.
This commit is contained in:
parent
84a49e37ee
commit
ed8a21fd86
19 changed files with 42 additions and 96 deletions
|
@ -383,7 +383,7 @@ void FGLRenderer::DrawTexture(FTexture *img, DCanvas::DrawParms &parms)
|
||||||
glScissor(parms.lclip, btm - parms.dclip + space, parms.rclip - parms.lclip, parms.dclip - parms.uclip);
|
glScissor(parms.lclip, btm - parms.dclip + space, parms.rclip - parms.lclip, parms.dclip - parms.uclip);
|
||||||
|
|
||||||
gl_RenderState.SetColor(color);
|
gl_RenderState.SetColor(color);
|
||||||
gl_RenderState.EnableAlphaTest(false);
|
gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f);
|
||||||
gl_RenderState.Apply();
|
gl_RenderState.Apply();
|
||||||
|
|
||||||
FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer();
|
FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer();
|
||||||
|
@ -409,8 +409,6 @@ void FGLRenderer::DrawTexture(FTexture *img, DCanvas::DrawParms &parms)
|
||||||
GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP);
|
GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP);
|
||||||
}
|
}
|
||||||
|
|
||||||
gl_RenderState.EnableAlphaTest(true);
|
|
||||||
|
|
||||||
glScissor(0, 0, screen->GetWidth(), screen->GetHeight());
|
glScissor(0, 0, screen->GetWidth(), screen->GetHeight());
|
||||||
glDisable(GL_SCISSOR_TEST);
|
glDisable(GL_SCISSOR_TEST);
|
||||||
gl_RenderState.SetTextureMode(TM_MODULATE);
|
gl_RenderState.SetTextureMode(TM_MODULATE);
|
||||||
|
|
|
@ -75,8 +75,6 @@ void FRenderState::Reset()
|
||||||
mSrcBlend = GL_SRC_ALPHA;
|
mSrcBlend = GL_SRC_ALPHA;
|
||||||
mDstBlend = GL_ONE_MINUS_SRC_ALPHA;
|
mDstBlend = GL_ONE_MINUS_SRC_ALPHA;
|
||||||
glSrcBlend = glDstBlend = -1;
|
glSrcBlend = glDstBlend = -1;
|
||||||
glAlphaFunc = -1;
|
|
||||||
mAlphaFunc = GL_GEQUAL;
|
|
||||||
mAlphaThreshold = 0.5f;
|
mAlphaThreshold = 0.5f;
|
||||||
mBlendEquation = GL_FUNC_ADD;
|
mBlendEquation = GL_FUNC_ADD;
|
||||||
mObjectColor = 0xffffffff;
|
mObjectColor = 0xffffffff;
|
||||||
|
@ -151,6 +149,7 @@ bool FRenderState::ApplyShader()
|
||||||
activeShader->muInterpolationFactor.Set(mInterpolationFactor);
|
activeShader->muInterpolationFactor.Set(mInterpolationFactor);
|
||||||
activeShader->muClipHeightTop.Set(mClipHeightTop);
|
activeShader->muClipHeightTop.Set(mClipHeightTop);
|
||||||
activeShader->muClipHeightBottom.Set(mClipHeightBottom);
|
activeShader->muClipHeightBottom.Set(mClipHeightBottom);
|
||||||
|
activeShader->muAlphaThreshold.Set(mAlphaThreshold);
|
||||||
|
|
||||||
if (mGlowEnabled)
|
if (mGlowEnabled)
|
||||||
{
|
{
|
||||||
|
@ -269,18 +268,6 @@ void FRenderState::Apply()
|
||||||
glDstBlend = mDstBlend;
|
glDstBlend = mDstBlend;
|
||||||
glBlendFunc(mSrcBlend, mDstBlend);
|
glBlendFunc(mSrcBlend, mDstBlend);
|
||||||
}
|
}
|
||||||
if (mAlphaFunc != glAlphaFunc || mAlphaThreshold != glAlphaThreshold)
|
|
||||||
{
|
|
||||||
glAlphaFunc = mAlphaFunc;
|
|
||||||
glAlphaThreshold = mAlphaThreshold;
|
|
||||||
::glAlphaFunc(mAlphaFunc, mAlphaThreshold);
|
|
||||||
}
|
|
||||||
if (mAlphaTest != glAlphaTest)
|
|
||||||
{
|
|
||||||
glAlphaTest = mAlphaTest;
|
|
||||||
if (mAlphaTest) glEnable(GL_ALPHA_TEST);
|
|
||||||
else glDisable(GL_ALPHA_TEST);
|
|
||||||
}
|
|
||||||
if (mBlendEquation != glBlendEquation)
|
if (mBlendEquation != glBlendEquation)
|
||||||
{
|
{
|
||||||
glBlendEquation = mBlendEquation;
|
glBlendEquation = mBlendEquation;
|
||||||
|
|
|
@ -53,7 +53,6 @@ class FRenderState
|
||||||
int mNumLights[4];
|
int mNumLights[4];
|
||||||
float *mLightData;
|
float *mLightData;
|
||||||
int mSrcBlend, mDstBlend;
|
int mSrcBlend, mDstBlend;
|
||||||
int mAlphaFunc;
|
|
||||||
float mAlphaThreshold;
|
float mAlphaThreshold;
|
||||||
bool mAlphaTest;
|
bool mAlphaTest;
|
||||||
int mBlendEquation;
|
int mBlendEquation;
|
||||||
|
@ -76,7 +75,6 @@ class FRenderState
|
||||||
int mColormapState;
|
int mColormapState;
|
||||||
|
|
||||||
int glSrcBlend, glDstBlend;
|
int glSrcBlend, glDstBlend;
|
||||||
int glAlphaFunc;
|
|
||||||
float glAlphaThreshold;
|
float glAlphaThreshold;
|
||||||
bool glAlphaTest;
|
bool glAlphaTest;
|
||||||
int glBlendEquation;
|
int glBlendEquation;
|
||||||
|
@ -281,28 +279,8 @@ public:
|
||||||
|
|
||||||
void AlphaFunc(int func, float thresh)
|
void AlphaFunc(int func, float thresh)
|
||||||
{
|
{
|
||||||
if (!gl_direct_state_change)
|
if (func == GL_GREATER) mAlphaThreshold = thresh;
|
||||||
{
|
else mAlphaThreshold = thresh - 0.001f;
|
||||||
mAlphaFunc = func;
|
|
||||||
mAlphaThreshold = thresh;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
::glAlphaFunc(func, thresh);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void EnableAlphaTest(bool on)
|
|
||||||
{
|
|
||||||
if (!gl_direct_state_change)
|
|
||||||
{
|
|
||||||
mAlphaTest = on;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (on) glEnable(GL_ALPHA_TEST);
|
|
||||||
else glDisable(GL_ALPHA_TEST);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlendEquation(int eq)
|
void BlendEquation(int eq)
|
||||||
|
|
|
@ -333,7 +333,7 @@ void GLWall::DrawDecal(DBaseDecal *decal)
|
||||||
|
|
||||||
|
|
||||||
// If srcalpha is one it looks better with a higher alpha threshold
|
// If srcalpha is one it looks better with a higher alpha threshold
|
||||||
if (decal->RenderStyle.SrcAlpha == STYLEALPHA_One) gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold);
|
if (decal->RenderStyle.SrcAlpha == STYLEALPHA_One) gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_sprite_threshold);
|
||||||
else gl_RenderState.AlphaFunc(GL_GREATER, 0.f);
|
else gl_RenderState.AlphaFunc(GL_GREATER, 0.f);
|
||||||
|
|
||||||
gl_RenderState.Apply();
|
gl_RenderState.Apply();
|
||||||
|
|
|
@ -424,7 +424,7 @@ void GLFlat::Draw(int pass)
|
||||||
if (renderstyle==STYLE_Add) gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE);
|
if (renderstyle==STYLE_Add) gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||||
gl_SetColor(lightlevel, rel, Colormap, alpha);
|
gl_SetColor(lightlevel, rel, Colormap, alpha);
|
||||||
gl_SetFog(lightlevel, rel, &Colormap, false);
|
gl_SetFog(lightlevel, rel, &Colormap, false);
|
||||||
gl_RenderState.AlphaFunc(GL_GEQUAL,gl_mask_threshold*(alpha));
|
gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold);
|
||||||
if (!gltexture)
|
if (!gltexture)
|
||||||
{
|
{
|
||||||
gl_RenderState.EnableTexture(false);
|
gl_RenderState.EnableTexture(false);
|
||||||
|
|
|
@ -998,7 +998,7 @@ void GLHorizonPortal::DrawContents()
|
||||||
gltexture->Bind();
|
gltexture->Bind();
|
||||||
|
|
||||||
gl_SetPlaneTextureRotation(sp, gltexture);
|
gl_SetPlaneTextureRotation(sp, gltexture);
|
||||||
gl_RenderState.EnableAlphaTest(false);
|
gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f);
|
||||||
gl_RenderState.BlendFunc(GL_ONE,GL_ZERO);
|
gl_RenderState.BlendFunc(GL_ONE,GL_ZERO);
|
||||||
gl_RenderState.Apply();
|
gl_RenderState.Apply();
|
||||||
|
|
||||||
|
|
|
@ -345,7 +345,7 @@ void FGLRenderer::RenderScene(int recursion)
|
||||||
glDepthFunc(GL_LESS);
|
glDepthFunc(GL_LESS);
|
||||||
|
|
||||||
|
|
||||||
gl_RenderState.EnableAlphaTest(false);
|
gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f);
|
||||||
|
|
||||||
glDisable(GL_POLYGON_OFFSET_FILL); // just in case
|
glDisable(GL_POLYGON_OFFSET_FILL); // just in case
|
||||||
|
|
||||||
|
@ -374,8 +374,6 @@ void FGLRenderer::RenderScene(int recursion)
|
||||||
gl_drawinfo->drawlists[GLDL_LIGHTFOG].Draw(pass);
|
gl_drawinfo->drawlists[GLDL_LIGHTFOG].Draw(pass);
|
||||||
|
|
||||||
|
|
||||||
gl_RenderState.EnableAlphaTest(true);
|
|
||||||
|
|
||||||
// Part 2: masked geometry. This is set up so that only pixels with alpha>0.5 will show
|
// Part 2: masked geometry. This is set up so that only pixels with alpha>0.5 will show
|
||||||
if (!gl_texture)
|
if (!gl_texture)
|
||||||
{
|
{
|
||||||
|
@ -440,10 +438,10 @@ void FGLRenderer::RenderScene(int recursion)
|
||||||
glDepthFunc(GL_LEQUAL);
|
glDepthFunc(GL_LEQUAL);
|
||||||
if (gl_texture)
|
if (gl_texture)
|
||||||
{
|
{
|
||||||
gl_RenderState.EnableAlphaTest(false);
|
gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f);
|
||||||
gl_drawinfo->drawlists[GLDL_LIGHT].Sort();
|
gl_drawinfo->drawlists[GLDL_LIGHT].Sort();
|
||||||
gl_drawinfo->drawlists[GLDL_LIGHT].Draw(GLPASS_TEXTURE);
|
gl_drawinfo->drawlists[GLDL_LIGHT].Draw(GLPASS_TEXTURE);
|
||||||
gl_RenderState.EnableAlphaTest(true);
|
gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold);
|
||||||
gl_drawinfo->drawlists[GLDL_LIGHTBRIGHT].Sort();
|
gl_drawinfo->drawlists[GLDL_LIGHTBRIGHT].Sort();
|
||||||
gl_drawinfo->drawlists[GLDL_LIGHTBRIGHT].Draw(GLPASS_TEXTURE);
|
gl_drawinfo->drawlists[GLDL_LIGHTBRIGHT].Draw(GLPASS_TEXTURE);
|
||||||
gl_drawinfo->drawlists[GLDL_LIGHTMASKED].Sort();
|
gl_drawinfo->drawlists[GLDL_LIGHTMASKED].Sort();
|
||||||
|
@ -495,10 +493,9 @@ void FGLRenderer::RenderScene(int recursion)
|
||||||
|
|
||||||
glDepthMask(false); // don't write to Z-buffer!
|
glDepthMask(false); // don't write to Z-buffer!
|
||||||
gl_RenderState.EnableFog(true);
|
gl_RenderState.EnableFog(true);
|
||||||
gl_RenderState.EnableAlphaTest(false);
|
gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f);
|
||||||
gl_RenderState.BlendFunc(GL_ONE,GL_ZERO);
|
gl_RenderState.BlendFunc(GL_ONE,GL_ZERO);
|
||||||
gl_drawinfo->DrawUnhandledMissingTextures();
|
gl_drawinfo->DrawUnhandledMissingTextures();
|
||||||
gl_RenderState.EnableAlphaTest(true);
|
|
||||||
glDepthMask(true);
|
glDepthMask(true);
|
||||||
|
|
||||||
glPolygonOffset(0.0f, 0.0f);
|
glPolygonOffset(0.0f, 0.0f);
|
||||||
|
@ -523,7 +520,6 @@ void FGLRenderer::RenderTranslucent()
|
||||||
gl_RenderState.SetCameraPos(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy), FIXED2FLOAT(viewz));
|
gl_RenderState.SetCameraPos(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy), FIXED2FLOAT(viewz));
|
||||||
|
|
||||||
// final pass: translucent stuff
|
// final pass: translucent stuff
|
||||||
gl_RenderState.EnableAlphaTest(true);
|
|
||||||
gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_sprite_threshold);
|
gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_sprite_threshold);
|
||||||
gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
|
@ -577,7 +573,7 @@ void FGLRenderer::DrawScene(bool toscreen)
|
||||||
|
|
||||||
static void FillScreen()
|
static void FillScreen()
|
||||||
{
|
{
|
||||||
gl_RenderState.EnableAlphaTest(false);
|
gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f);
|
||||||
gl_RenderState.EnableTexture(false);
|
gl_RenderState.EnableTexture(false);
|
||||||
gl_RenderState.Apply();
|
gl_RenderState.Apply();
|
||||||
FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer();
|
FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer();
|
||||||
|
@ -756,7 +752,6 @@ void FGLRenderer::EndDrawScene(sector_t * viewsector)
|
||||||
gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
gl_RenderState.ResetColor();
|
gl_RenderState.ResetColor();
|
||||||
gl_RenderState.EnableTexture(true);
|
gl_RenderState.EnableTexture(true);
|
||||||
gl_RenderState.EnableAlphaTest(true);
|
|
||||||
glDisable(GL_SCISSOR_TEST);
|
glDisable(GL_SCISSOR_TEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -472,7 +472,7 @@ void GLSkyPortal::DrawContents()
|
||||||
|
|
||||||
gl_RenderState.ResetColor();
|
gl_RenderState.ResetColor();
|
||||||
gl_RenderState.EnableFog(false);
|
gl_RenderState.EnableFog(false);
|
||||||
gl_RenderState.EnableAlphaTest(false);
|
gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f);
|
||||||
gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
gl_MatrixStack.Push(gl_RenderState.mViewMatrix);
|
gl_MatrixStack.Push(gl_RenderState.mViewMatrix);
|
||||||
|
@ -481,7 +481,6 @@ void GLSkyPortal::DrawContents()
|
||||||
if (origin->texture[0] && origin->texture[0]->tex->gl_info.bSkybox)
|
if (origin->texture[0] && origin->texture[0]->tex->gl_info.bSkybox)
|
||||||
{
|
{
|
||||||
RenderBox(origin->skytexno1, origin->texture[0], origin->x_offset[0], origin->sky2);
|
RenderBox(origin->skytexno1, origin->texture[0], origin->x_offset[0], origin->sky2);
|
||||||
gl_RenderState.EnableAlphaTest(true);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -495,7 +494,6 @@ void GLSkyPortal::DrawContents()
|
||||||
gl_RenderState.SetTextureMode(TM_MODULATE);
|
gl_RenderState.SetTextureMode(TM_MODULATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
gl_RenderState.EnableAlphaTest(true);
|
|
||||||
gl_RenderState.AlphaFunc(GL_GEQUAL, 0.05f);
|
gl_RenderState.AlphaFunc(GL_GEQUAL, 0.05f);
|
||||||
|
|
||||||
if (origin->doublesky && origin->texture[1])
|
if (origin->doublesky && origin->texture[1])
|
||||||
|
|
|
@ -137,11 +137,11 @@ void GLSprite::Draw(int pass)
|
||||||
|
|
||||||
if (hw_styleflags == STYLEHW_NoAlphaTest)
|
if (hw_styleflags == STYLEHW_NoAlphaTest)
|
||||||
{
|
{
|
||||||
gl_RenderState.EnableAlphaTest(false);
|
gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gl_RenderState.AlphaFunc(GL_GEQUAL,trans*gl_mask_sprite_threshold);
|
gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_sprite_threshold);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RenderStyle.BlendOp == STYLEOP_Shadow)
|
if (RenderStyle.BlendOp == STYLEOP_Shadow)
|
||||||
|
@ -165,7 +165,7 @@ void GLSprite::Draw(int pass)
|
||||||
minalpha*=factor;
|
minalpha*=factor;
|
||||||
}
|
}
|
||||||
|
|
||||||
gl_RenderState.AlphaFunc(GL_GEQUAL,minalpha*gl_mask_sprite_threshold);
|
gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_sprite_threshold);
|
||||||
gl_RenderState.SetColor(0.2f,0.2f,0.2f,fuzzalpha, Colormap.desaturation);
|
gl_RenderState.SetColor(0.2f,0.2f,0.2f,fuzzalpha, Colormap.desaturation);
|
||||||
additivefog = true;
|
additivefog = true;
|
||||||
}
|
}
|
||||||
|
@ -294,16 +294,6 @@ void GLSprite::Draw(int pass)
|
||||||
gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
gl_RenderState.BlendEquation(GL_FUNC_ADD);
|
gl_RenderState.BlendEquation(GL_FUNC_ADD);
|
||||||
gl_RenderState.SetTextureMode(TM_MODULATE);
|
gl_RenderState.SetTextureMode(TM_MODULATE);
|
||||||
|
|
||||||
// [BB] Restore the alpha test after drawing a smooth particle.
|
|
||||||
if (hw_styleflags == STYLEHW_NoAlphaTest)
|
|
||||||
{
|
|
||||||
gl_RenderState.EnableAlphaTest(true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gl_RenderState.AlphaFunc(GL_GEQUAL,gl_mask_sprite_threshold);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gl_RenderState.SetObjectColor(0xffffffff);
|
gl_RenderState.SetObjectColor(0xffffffff);
|
||||||
|
|
|
@ -301,9 +301,8 @@ void GLWall::RenderFogBoundary()
|
||||||
int rel = rellight + getExtraLight();
|
int rel = rellight + getExtraLight();
|
||||||
gl_SetFog(lightlevel, rel, &Colormap, false);
|
gl_SetFog(lightlevel, rel, &Colormap, false);
|
||||||
gl_RenderState.SetEffect(EFF_FOGBOUNDARY);
|
gl_RenderState.SetEffect(EFF_FOGBOUNDARY);
|
||||||
gl_RenderState.EnableAlphaTest(false);
|
gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f);
|
||||||
RenderWall(RWF_BLANK);
|
RenderWall(RWF_BLANK);
|
||||||
gl_RenderState.EnableAlphaTest(true);
|
|
||||||
gl_RenderState.SetEffect(EFF_NONE);
|
gl_RenderState.SetEffect(EFF_NONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -349,7 +348,7 @@ void GLWall::RenderMirrorSurface()
|
||||||
|
|
||||||
// Restore the defaults for the translucent pass
|
// Restore the defaults for the translucent pass
|
||||||
gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
gl_RenderState.AlphaFunc(GL_GEQUAL,0.5f*gl_mask_sprite_threshold);
|
gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_sprite_threshold);
|
||||||
glDepthFunc(GL_LESS);
|
glDepthFunc(GL_LESS);
|
||||||
|
|
||||||
// This is drawn in the translucent pass which is done after the decal pass
|
// This is drawn in the translucent pass which is done after the decal pass
|
||||||
|
@ -383,8 +382,8 @@ void GLWall::RenderTranslucentWall()
|
||||||
// and until that changes I won't fix this code for the new blending modes!
|
// and until that changes I won't fix this code for the new blending modes!
|
||||||
bool isadditive = RenderStyle == STYLE_Add;
|
bool isadditive = RenderStyle == STYLE_Add;
|
||||||
|
|
||||||
if (!transparent) gl_RenderState.AlphaFunc(GL_GEQUAL,gl_mask_threshold*fabs(alpha));
|
if (!transparent) gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold);
|
||||||
else gl_RenderState.EnableAlphaTest(false);
|
else gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f);
|
||||||
if (isadditive) gl_RenderState.BlendFunc(GL_SRC_ALPHA,GL_ONE);
|
if (isadditive) gl_RenderState.BlendFunc(GL_SRC_ALPHA,GL_ONE);
|
||||||
|
|
||||||
int extra;
|
int extra;
|
||||||
|
@ -408,7 +407,6 @@ void GLWall::RenderTranslucentWall()
|
||||||
|
|
||||||
// restore default settings
|
// restore default settings
|
||||||
if (isadditive) gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
if (isadditive) gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
if (transparent) gl_RenderState.EnableAlphaTest(true);
|
|
||||||
|
|
||||||
if (!gltexture)
|
if (!gltexture)
|
||||||
{
|
{
|
||||||
|
|
|
@ -151,7 +151,7 @@ void FGLRenderer::DrawPSprite (player_t * player,pspdef_t *psp,fixed_t sx, fixed
|
||||||
|
|
||||||
if (tex->GetTransparent() || OverrideShader != 0)
|
if (tex->GetTransparent() || OverrideShader != 0)
|
||||||
{
|
{
|
||||||
gl_RenderState.EnableAlphaTest(false);
|
gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f);
|
||||||
}
|
}
|
||||||
gl_RenderState.Apply();
|
gl_RenderState.Apply();
|
||||||
FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer();
|
FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer();
|
||||||
|
@ -164,10 +164,7 @@ void FGLRenderer::DrawPSprite (player_t * player,pspdef_t *psp,fixed_t sx, fixed
|
||||||
ptr->Set(x2, y2, 0, fU2, fV2);
|
ptr->Set(x2, y2, 0, fU2, fV2);
|
||||||
ptr++;
|
ptr++;
|
||||||
GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP);
|
GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP);
|
||||||
if (tex->GetTransparent() || OverrideShader != 0)
|
gl_RenderState.AlphaFunc(GL_GEQUAL, 0.5f);
|
||||||
{
|
|
||||||
gl_RenderState.EnableAlphaTest(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
|
@ -203,6 +203,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
|
||||||
muInterpolationFactor.Init(hShader, "uInterpolationFactor");
|
muInterpolationFactor.Init(hShader, "uInterpolationFactor");
|
||||||
muClipHeightTop.Init(hShader, "uClipHeightTop");
|
muClipHeightTop.Init(hShader, "uClipHeightTop");
|
||||||
muClipHeightBottom.Init(hShader, "uClipHeightBottom");
|
muClipHeightBottom.Init(hShader, "uClipHeightBottom");
|
||||||
|
muAlphaThreshold.Init(hShader, "uAlphaThreshold");
|
||||||
|
|
||||||
timer_index = glGetUniformLocation(hShader, "timer");
|
timer_index = glGetUniformLocation(hShader, "timer");
|
||||||
lights_index = glGetUniformLocation(hShader, "lights");
|
lights_index = glGetUniformLocation(hShader, "lights");
|
||||||
|
|
|
@ -195,6 +195,7 @@ class FShader
|
||||||
FBufferedUniform1f muInterpolationFactor;
|
FBufferedUniform1f muInterpolationFactor;
|
||||||
FBufferedUniform1f muClipHeightTop;
|
FBufferedUniform1f muClipHeightTop;
|
||||||
FBufferedUniform1f muClipHeightBottom;
|
FBufferedUniform1f muClipHeightBottom;
|
||||||
|
FBufferedUniform1f muAlphaThreshold;
|
||||||
|
|
||||||
int timer_index;
|
int timer_index;
|
||||||
int lights_index;
|
int lights_index;
|
||||||
|
|
|
@ -150,7 +150,6 @@ void OpenGLFrameBuffer::InitializeState()
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
glDisable(GL_LINE_SMOOTH);
|
glDisable(GL_LINE_SMOOTH);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
glAlphaFunc(GL_GEQUAL,0.5f);
|
|
||||||
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
|
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
|
||||||
glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
|
glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
|
||||||
|
|
||||||
|
|
|
@ -68,15 +68,13 @@
|
||||||
|
|
||||||
//GL headers
|
//GL headers
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
|
//#include "gl_load.h"
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
#include <OpenGL/OpenGL.h>
|
#include <OpenGL/OpenGL.h>
|
||||||
#elif defined(__unix__)
|
#elif defined(__unix__)
|
||||||
//#include <GL/glxew.h>
|
//#include <GL/glxew.h>
|
||||||
#else // !__APPLE__ && !__unix__
|
#else // !__APPLE__ && !__unix__
|
||||||
#define DWORD WINDOWS_DWORD // I don't want to depend on this throughout the GL code!
|
|
||||||
#include <GL/wglew.h>
|
|
||||||
#undef DWORD
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
|
@ -280,7 +280,7 @@ bool OpenGLFrameBuffer::Wiper_Crossfade::Run(int ticks, OpenGLFrameBuffer *fb)
|
||||||
float vb = fb->GetHeight() / FHardwareTexture::GetTexDimension(fb->GetHeight());
|
float vb = fb->GetHeight() / FHardwareTexture::GetTexDimension(fb->GetHeight());
|
||||||
|
|
||||||
gl_RenderState.SetTextureMode(TM_OPAQUE);
|
gl_RenderState.SetTextureMode(TM_OPAQUE);
|
||||||
gl_RenderState.EnableAlphaTest(false);
|
gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f);
|
||||||
gl_RenderState.ResetColor();
|
gl_RenderState.ResetColor();
|
||||||
gl_RenderState.Apply();
|
gl_RenderState.Apply();
|
||||||
fb->wipestartscreen->Bind(0);
|
fb->wipestartscreen->Bind(0);
|
||||||
|
@ -302,7 +302,7 @@ bool OpenGLFrameBuffer::Wiper_Crossfade::Run(int ticks, OpenGLFrameBuffer *fb)
|
||||||
gl_RenderState.SetColorAlpha(0xffffff, clamp(Clock/32.f, 0.f, 1.f));
|
gl_RenderState.SetColorAlpha(0xffffff, clamp(Clock/32.f, 0.f, 1.f));
|
||||||
gl_RenderState.Apply();
|
gl_RenderState.Apply();
|
||||||
GLRenderer->mVBO->RenderArray(GL_TRIANGLE_STRIP, offset, count);
|
GLRenderer->mVBO->RenderArray(GL_TRIANGLE_STRIP, offset, count);
|
||||||
gl_RenderState.EnableAlphaTest(true);
|
gl_RenderState.AlphaFunc(GL_GEQUAL, 0.5f);
|
||||||
gl_RenderState.SetTextureMode(TM_MODULATE);
|
gl_RenderState.SetTextureMode(TM_MODULATE);
|
||||||
|
|
||||||
return Clock >= 32;
|
return Clock >= 32;
|
||||||
|
@ -490,7 +490,7 @@ bool OpenGLFrameBuffer::Wiper_Burn::Run(int ticks, OpenGLFrameBuffer *fb)
|
||||||
|
|
||||||
// Put the initial screen back to the buffer.
|
// Put the initial screen back to the buffer.
|
||||||
gl_RenderState.SetTextureMode(TM_OPAQUE);
|
gl_RenderState.SetTextureMode(TM_OPAQUE);
|
||||||
gl_RenderState.EnableAlphaTest(false);
|
gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f);
|
||||||
gl_RenderState.ResetColor();
|
gl_RenderState.ResetColor();
|
||||||
gl_RenderState.Apply();
|
gl_RenderState.Apply();
|
||||||
fb->wipestartscreen->Bind(0);
|
fb->wipestartscreen->Bind(0);
|
||||||
|
|
|
@ -224,6 +224,12 @@ void main()
|
||||||
|
|
||||||
vec4 frag = ProcessTexel();
|
vec4 frag = ProcessTexel();
|
||||||
|
|
||||||
|
#ifndef NO_DISCARD
|
||||||
|
// alpha testing
|
||||||
|
if (frag.a <= uAlphaThreshold) discard;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
switch (uFixedColormap)
|
switch (uFixedColormap)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
|
|
|
@ -52,8 +52,8 @@ void main()
|
||||||
|
|
||||||
#ifdef SPHEREMAP
|
#ifdef SPHEREMAP
|
||||||
vec3 u = normalize(eyeCoordPos.xyz);
|
vec3 u = normalize(eyeCoordPos.xyz);
|
||||||
vec3 n = normalize(TextureMatrix * vec4(tc.x, 0.0, tc.y, 0.0); // use texture matrix and coordinates for our normal. Since this is only used on walls, the normal's y coordinate is always 0.
|
vec4 n = normalize(TextureMatrix * vec4(tc.x, 0.0, tc.y, 0.0)); // use texture matrix and coordinates for our normal. Since this is only used on walls, the normal's y coordinate is always 0.
|
||||||
vec3 r = reflect(u, n);
|
vec3 r = reflect(u, n.xyz);
|
||||||
float m = 2.0 * sqrt( r.x*r.x + r.y*r.y + (r.z+1.0)*(r.z+1.0) );
|
float m = 2.0 * sqrt( r.x*r.x + r.y*r.y + (r.z+1.0)*(r.z+1.0) );
|
||||||
vec2 sst = vec2(r.x/m + 0.5, r.y/m + 0.5);
|
vec2 sst = vec2(r.x/m + 0.5, r.y/m + 0.5);
|
||||||
gl_TexCoord[0].xy = sst;
|
gl_TexCoord[0].xy = sst;
|
||||||
|
|
|
@ -4,6 +4,7 @@ uniform vec4 uCameraPos;
|
||||||
uniform float uClipHeightTop, uClipHeightBottom;
|
uniform float uClipHeightTop, uClipHeightBottom;
|
||||||
|
|
||||||
uniform int uTextureMode;
|
uniform int uTextureMode;
|
||||||
|
uniform float uAlphaThreshold;
|
||||||
|
|
||||||
// colors
|
// colors
|
||||||
uniform vec4 uObjectColor;
|
uniform vec4 uObjectColor;
|
||||||
|
@ -34,8 +35,7 @@ uniform int uFogEnabled;
|
||||||
// dynamic lights
|
// dynamic lights
|
||||||
uniform ivec4 uLightRange;
|
uniform ivec4 uLightRange;
|
||||||
|
|
||||||
|
// matrices
|
||||||
// redefine the matrix names to what they actually represent.
|
|
||||||
uniform mat4 ProjectionMatrix;
|
uniform mat4 ProjectionMatrix;
|
||||||
uniform mat4 ViewMatrix;
|
uniform mat4 ViewMatrix;
|
||||||
uniform mat4 ModelMatrix;
|
uniform mat4 ModelMatrix;
|
||||||
|
|
Loading…
Reference in a new issue