- added option to disable alpha testing for user shaders.

This commit is contained in:
Christoph Oelckers 2018-10-31 15:56:20 +01:00
parent 40da1dbfbc
commit 91df3f8c73
5 changed files with 23 additions and 12 deletions

View file

@ -43,8 +43,6 @@
#include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_renderer.h"
#include "gl/shaders/gl_shader.h" #include "gl/shaders/gl_shader.h"
extern TArray<UserShaderDesc> usershaders;
namespace OpenGLRenderer namespace OpenGLRenderer
{ {

View file

@ -104,10 +104,8 @@ void GLSprite::DrawSprite(HWDrawInfo *di, FRenderState &state, bool translucent)
{ {
state.AlphaFunc(Alpha_GEqual, 0.f); state.AlphaFunc(Alpha_GEqual, 0.f);
} }
else else if (!gltexture->tex->GetTranslucency()) state.AlphaFunc(Alpha_GEqual, gl_mask_sprite_threshold);
{ else state.AlphaFunc(Alpha_Greater, 0.f);
state.AlphaFunc(Alpha_GEqual, gl_mask_sprite_threshold);
}
if (RenderStyle.BlendOp == STYLEOP_Shadow) if (RenderStyle.BlendOp == STYLEOP_Shadow)
{ {

View file

@ -31,8 +31,6 @@
EXTERN_CVAR(Bool, gl_texture_usehires) EXTERN_CVAR(Bool, gl_texture_usehires)
extern TArray<UserShaderDesc> usershaders;
//=========================================================================== //===========================================================================
// //
// Quick'n dirty image rescaling. // Quick'n dirty image rescaling.

View file

@ -1154,6 +1154,15 @@ class GLDefsParser
tex->bDisableFullbright = disable_fullbright; tex->bDisableFullbright = disable_fullbright;
} }
void SetShaderIndex(FTexture *tex, unsigned index)
{
auto desc = usershaders[index - FIRST_USER_SHADER];
if (desc.disablealphatest)
{
tex->bTranslucent = true;
}
tex->shaderindex = index;
}
//========================================================================== //==========================================================================
// //
@ -1370,11 +1379,11 @@ class GLDefsParser
usershaders[i].shaderType == usershader.shaderType && usershaders[i].shaderType == usershader.shaderType &&
!usershaders[i].defines.Compare(usershader.defines)) !usershaders[i].defines.Compare(usershader.defines))
{ {
tex->shaderindex = i + FIRST_USER_SHADER; SetShaderIndex(tex, i + FIRST_USER_SHADER);
return; return;
} }
} }
tex->shaderindex = usershaders.Push(usershader) + FIRST_USER_SHADER; SetShaderIndex(tex, usershaders.Push(usershader) + FIRST_USER_SHADER);
} }
} }
@ -1570,6 +1579,10 @@ class GLDefsParser
} }
desc.defines.AppendFormat("#define %s %s\n", defineName.GetChars(), defineValue.GetChars()); desc.defines.AppendFormat("#define %s %s\n", defineName.GetChars(), defineValue.GetChars());
} }
else if (sc.Compare("disablealphatest"))
{
desc.disablealphatest = true;
}
} }
if (!tex) if (!tex)
{ {
@ -1607,11 +1620,11 @@ class GLDefsParser
usershaders[i].shaderType == desc.shaderType && usershaders[i].shaderType == desc.shaderType &&
!usershaders[i].defines.Compare(desc.defines)) !usershaders[i].defines.Compare(desc.defines))
{ {
tex->shaderindex = i + FIRST_USER_SHADER; SetShaderIndex(tex, i + FIRST_USER_SHADER);
return; return;
} }
} }
tex->shaderindex = usershaders.Push(desc) + FIRST_USER_SHADER; SetShaderIndex(tex, usershaders.Push(desc) + FIRST_USER_SHADER);
} }
} }
} }

View file

@ -77,8 +77,12 @@ struct UserShaderDesc
FString shader; FString shader;
MaterialShaderIndex shaderType; MaterialShaderIndex shaderType;
FString defines; FString defines;
bool disablealphatest = false;
}; };
extern TArray<UserShaderDesc> usershaders;
struct FloatRect struct FloatRect
{ {
float left,top; float left,top;