- first adjustments to decal code.

- moved texture mode constants to a global header and consolidated with the variants of the 2D drawer.
This commit is contained in:
Christoph Oelckers 2018-10-21 08:14:48 +02:00
parent 3b7a5da83e
commit 1768508c80
16 changed files with 73 additions and 73 deletions

View file

@ -55,15 +55,15 @@ void gl_GetRenderStyle(FRenderStyle style, bool drawopaque, bool allowcolorblend
int srcblend = blendstyles[style.SrcAlpha%STYLEALPHA_MAX]; int srcblend = blendstyles[style.SrcAlpha%STYLEALPHA_MAX];
int dstblend = blendstyles[style.DestAlpha%STYLEALPHA_MAX]; int dstblend = blendstyles[style.DestAlpha%STYLEALPHA_MAX];
int blendequation = renderops[style.BlendOp&15]; int blendequation = renderops[style.BlendOp&15];
int texturemode = drawopaque? TM_OPAQUE : TM_MODULATE; int texturemode = drawopaque? TM_OPAQUE : TM_NORMAL;
if (style.Flags & STYLEF_RedIsAlpha) if (style.Flags & STYLEF_RedIsAlpha)
{ {
texturemode = TM_REDTOALPHA; texturemode = TM_ALPHATEXTURE;
} }
else if (style.Flags & STYLEF_ColorIsFixed) else if (style.Flags & STYLEF_ColorIsFixed)
{ {
texturemode = TM_MASK; texturemode = TM_STENCIL;
} }
else if (style.Flags & STYLEF_InvertSource) else if (style.Flags & STYLEF_InvertSource)
{ {

View file

@ -468,12 +468,6 @@ void FGLRenderer::Draw2D(F2DDrawer *drawer)
gl_RenderState.EnableFog(2); // Special 2D mode 'fog'. gl_RenderState.EnableFog(2); // Special 2D mode 'fog'.
// Rather than adding remapping code, let's enforce that the constants here are equal. // Rather than adding remapping code, let's enforce that the constants here are equal.
static_assert(int(F2DDrawer::DTM_Normal) == int(TM_MODULATE), "DTM_Normal != TM_MODULATE");
static_assert(int(F2DDrawer::DTM_Opaque) == int(TM_OPAQUE), "DTM_Opaque != TM_OPAQUE");
static_assert(int(F2DDrawer::DTM_Invert) == int(TM_INVERSE), "DTM_Invert != TM_INVERSE");
static_assert(int(F2DDrawer::DTM_InvertOpaque) == int(TM_INVERTOPAQUE), "DTM_InvertOpaque != TM_INVERTOPAQUE");
static_assert(int(F2DDrawer::DTM_Stencil) == int(TM_MASK), "DTM_Stencil != TM_MASK");
static_assert(int(F2DDrawer::DTM_AlphaTexture) == int(TM_REDTOALPHA), "DTM_AlphaTexture != TM_REDTOALPHA");
gl_RenderState.SetTextureMode(cmd.mDrawMode); gl_RenderState.SetTextureMode(cmd.mDrawMode);
if (cmd.mFlags & F2DDrawer::DTF_Scissor) if (cmd.mFlags & F2DDrawer::DTF_Scissor)
{ {
@ -555,7 +549,7 @@ void FGLRenderer::Draw2D(F2DDrawer *drawer)
gl_RenderState.SetVertexBuffer(mVBO); gl_RenderState.SetVertexBuffer(mVBO);
gl_RenderState.EnableTexture(true); gl_RenderState.EnableTexture(true);
gl_RenderState.EnableBrightmap(true); gl_RenderState.EnableBrightmap(true);
gl_RenderState.SetTextureMode(TM_MODULATE); gl_RenderState.SetTextureMode(TM_NORMAL);
gl_RenderState.EnableFog(false); gl_RenderState.EnableFog(false);
gl_RenderState.ResetColor(); gl_RenderState.ResetColor();
gl_RenderState.Apply(); gl_RenderState.Apply();

View file

@ -128,7 +128,7 @@ bool FGLRenderState::ApplyShader()
activeShader->muDesaturation.Set(mDesaturation / 255.f); activeShader->muDesaturation.Set(mDesaturation / 255.f);
activeShader->muFogEnabled.Set(fogset); activeShader->muFogEnabled.Set(fogset);
activeShader->muTextureMode.Set(mTextureMode == TM_MODULATE && mTempTM == TM_OPAQUE ? TM_OPAQUE : mTextureMode); activeShader->muTextureMode.Set(mTextureMode == TM_NORMAL && mTempTM == TM_OPAQUE ? TM_OPAQUE : mTextureMode);
activeShader->muLightParms.Set(mLightParms); activeShader->muLightParms.Set(mLightParms);
activeShader->muFogColor.Set(mFogColor); activeShader->muFogColor.Set(mFogColor);
activeShader->muObjectColor.Set(mObjectColor); activeShader->muObjectColor.Set(mObjectColor);
@ -288,7 +288,7 @@ void FGLRenderState::ApplyMaterial(FMaterial *mat, int clampmode, int translatio
} }
else else
{ {
mTempTM = TM_MODULATE; mTempTM = TM_NORMAL;
} }
mEffectState = overrideshader >= 0 ? overrideshader : mat->GetShaderIndex(); mEffectState = overrideshader >= 0 ? overrideshader : mat->GetShaderIndex();
mShaderTimer = mat->tex->shaderspeed; mShaderTimer = mat->tex->shaderspeed;

View file

@ -63,7 +63,7 @@ class FGLRenderState : public FRenderState
float mClipSplit[2]; float mClipSplit[2];
int mEffectState; int mEffectState;
int mTempTM = TM_MODULATE; int mTempTM = TM_NORMAL;
FRenderStyle stRenderStyle; FRenderStyle stRenderStyle;
int stSrcBlend, stDstBlend; int stSrcBlend, stDstBlend;

View file

@ -57,9 +57,9 @@ struct FDrawInfo : public HWDrawInfo
void Draw(EDrawType dt, FRenderState &state, int index, int count, bool apply = true); void Draw(EDrawType dt, FRenderState &state, int index, int count, bool apply = true);
void DrawIndexed(EDrawType dt, FRenderState &state, int index, int count, bool apply = true); void DrawIndexed(EDrawType dt, FRenderState &state, int index, int count, bool apply = true);
void DrawDecal(GLDecal *gldecal); void DrawDecal(GLDecal *gldecal, FRenderState &state);
void DrawDecals(); void DrawDecals(FRenderState &state);
void DrawDecalsForMirror(GLWall *wall); void DrawDecalsForMirror(GLWall *wall, FRenderState &state);
void StartScene(); void StartScene();
void SetupFloodStencil(int vindex); void SetupFloodStencil(int vindex);

View file

@ -181,7 +181,7 @@ void FDrawInfo::RenderScene(int recursion)
if (!gl_texture) if (!gl_texture)
{ {
gl_RenderState.EnableTexture(true); gl_RenderState.EnableTexture(true);
gl_RenderState.SetTextureMode(TM_MASK); gl_RenderState.SetTextureMode(TM_STENCIL);
} }
gl_RenderState.AlphaFunc(Alpha_GEqual, gl_mask_threshold); gl_RenderState.AlphaFunc(Alpha_GEqual, gl_mask_threshold);
drawlists[GLDL_MASKEDWALLS].DrawWalls(this, pass); drawlists[GLDL_MASKEDWALLS].DrawWalls(this, pass);
@ -206,9 +206,9 @@ void FDrawInfo::RenderScene(int recursion)
glEnable(GL_POLYGON_OFFSET_FILL); glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(-1.0f, -128.0f); glPolygonOffset(-1.0f, -128.0f);
glDepthMask(false); glDepthMask(false);
DrawDecals(); DrawDecals(gl_RenderState);
gl_RenderState.SetTextureMode(TM_MODULATE); gl_RenderState.SetTextureMode(TM_NORMAL);
glPolygonOffset(0.0f, 0.0f); glPolygonOffset(0.0f, 0.0f);
glDisable(GL_POLYGON_OFFSET_FILL); glDisable(GL_POLYGON_OFFSET_FILL);
glDepthMask(true); glDepthMask(true);

View file

@ -245,7 +245,7 @@ void GLSkyPortal::DrawContents(HWDrawInfo *di)
{ {
gl_RenderState.SetTextureMode(TM_OPAQUE); gl_RenderState.SetTextureMode(TM_OPAQUE);
RenderDome(origin->texture[0], origin->x_offset[0], origin->y_offset, origin->mirrored, FSkyVertexBuffer::SKYMODE_MAINLAYER); RenderDome(origin->texture[0], origin->x_offset[0], origin->y_offset, origin->mirrored, FSkyVertexBuffer::SKYMODE_MAINLAYER);
gl_RenderState.SetTextureMode(TM_MODULATE); gl_RenderState.SetTextureMode(TM_NORMAL);
} }
gl_RenderState.AlphaFunc(Alpha_Greater, 0.f); gl_RenderState.AlphaFunc(Alpha_Greater, 0.f);

View file

@ -269,7 +269,7 @@ void FDrawInfo::DrawSprite(GLSprite *sprite, 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.Apply(); gl_RenderState.Apply();
glDrawArrays(GL_TRIANGLE_STRIP, sprite->vertexindex, 4); glDrawArrays(GL_TRIANGLE_STRIP, sprite->vertexindex, 4);
gl_RenderState.SetTextureMode(TM_MODULATE); gl_RenderState.SetTextureMode(TM_NORMAL);
} }
} }
else else
@ -289,7 +289,7 @@ void FDrawInfo::DrawSprite(GLSprite *sprite, int pass)
gl_RenderState.EnableBrightmap(true); gl_RenderState.EnableBrightmap(true);
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_NORMAL);
if (sprite->actor != nullptr && (sprite->actor->renderflags & RF_SPRITETYPEMASK) == RF_FLATSPRITE) if (sprite->actor != nullptr && (sprite->actor->renderflags & RF_SPRITETYPEMASK) == RF_FLATSPRITE)
{ {
glPolygonOffset(0.0f, 0.0f); glPolygonOffset(0.0f, 0.0f);

View file

@ -125,11 +125,11 @@ void FDrawInfo::RenderMirrorSurface(GLWall *wall)
glEnable(GL_POLYGON_OFFSET_FILL); glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(-1.0f, -128.0f); glPolygonOffset(-1.0f, -128.0f);
glDepthMask(false); glDepthMask(false);
DrawDecalsForMirror(wall); DrawDecalsForMirror(wall, gl_RenderState);
glDepthMask(true); glDepthMask(true);
glPolygonOffset(0.0f, 0.0f); glPolygonOffset(0.0f, 0.0f);
glDisable(GL_POLYGON_OFFSET_FILL); glDisable(GL_POLYGON_OFFSET_FILL);
gl_RenderState.SetTextureMode(TM_MODULATE); gl_RenderState.SetTextureMode(TM_NORMAL);
gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
} }
} }
@ -157,7 +157,7 @@ void FDrawInfo::RenderTexturedWall(GLWall *wall, int rflags)
{ {
if (wall->flags & GLWall::GLWF_CLAMPY) if (wall->flags & GLWall::GLWF_CLAMPY)
{ {
if (tmode == TM_MODULATE) gl_RenderState.SetTextureMode(TM_CLAMPY); if (tmode == TM_NORMAL) gl_RenderState.SetTextureMode(TM_CLAMPY);
} }
SetFog(255, 0, nullptr, false); SetFog(255, 0, nullptr, false);
} }
@ -445,7 +445,7 @@ void FDrawInfo::AddPortal(GLWall *wall, int ptype)
// //
// //
//========================================================================== //==========================================================================
void FDrawInfo::DrawDecal(GLDecal *gldecal) void FDrawInfo::DrawDecal(GLDecal *gldecal, FRenderState &state)
{ {
auto decal = gldecal->decal; auto decal = gldecal->decal;
auto tex = gldecal->gltexture; auto tex = gldecal->gltexture;
@ -462,13 +462,14 @@ void FDrawInfo::DrawDecal(GLDecal *gldecal)
} }
// alpha color only has an effect when using an alpha texture. // alpha color only has an effect when using an alpha texture.
if (decal->RenderStyle.Flags & STYLEF_RedIsAlpha) if (decal->RenderStyle.Flags & (STYLEF_RedIsAlpha | STYLEF_ColorIsFixed))
{ {
gl_RenderState.SetObjectColor(decal->AlphaColor | 0xff000000); gl_RenderState.SetObjectColor(decal->AlphaColor | 0xff000000);
} }
gl_SetRenderStyle(decal->RenderStyle, false, false); gl_RenderState.SetTextureMode(decal->RenderStyle);
gl_RenderState.ApplyMaterial(tex, CLAMP_XY, decal->Translation, -1); gl_RenderState.SetRenderStyle(decal->RenderStyle);
gl_RenderState.SetMaterial(tex, CLAMP_XY, decal->Translation, -1);
// If srcalpha is one it looks better with a higher alpha threshold // If srcalpha is one it looks better with a higher alpha threshold
@ -488,8 +489,7 @@ void FDrawInfo::DrawDecal(GLDecal *gldecal)
if (gldecal->lightlist == nullptr) if (gldecal->lightlist == nullptr)
{ {
gl_RenderState.Apply(); Draw(DT_TriangleFan, gl_RenderState, gldecal->vertindex, 4);
GLRenderer->mVBO->RenderArray(GL_TRIANGLE_FAN, gldecal->vertindex, 4);
} }
else else
{ {
@ -505,7 +505,7 @@ void FDrawInfo::DrawDecal(GLDecal *gldecal)
if (low1 < dv[1].z || low2 < dv[2].z) if (low1 < dv[1].z || low2 < dv[2].z)
{ {
int thisll = lightlist[k].caster != NULL ? hw_ClampLight(*lightlist[k].p_lightlevel) : gldecal->lightlevel; int thisll = lightlist[k].caster != nullptr ? hw_ClampLight(*lightlist[k].p_lightlevel) : gldecal->lightlevel;
FColormap thiscm; FColormap thiscm;
thiscm.FadeColor = gldecal->Colormap.FadeColor; thiscm.FadeColor = gldecal->Colormap.FadeColor;
thiscm.CopyFrom3DLight(&lightlist[k]); thiscm.CopyFrom3DLight(&lightlist[k]);
@ -514,15 +514,14 @@ void FDrawInfo::DrawDecal(GLDecal *gldecal)
SetFog(thisll, gldecal->rellight, &thiscm, false); SetFog(thisll, gldecal->rellight, &thiscm, false);
gl_RenderState.SetSplitPlanes(lightlist[k].plane, lowplane); gl_RenderState.SetSplitPlanes(lightlist[k].plane, lowplane);
gl_RenderState.Apply(); Draw(DT_TriangleFan, gl_RenderState, gldecal->vertindex, 4);
GLRenderer->mVBO->RenderArray(GL_TRIANGLE_FAN, gldecal->vertindex, 4);
} }
if (low1 <= dv[0].z && low2 <= dv[3].z) break; if (low1 <= dv[0].z && low2 <= dv[3].z) break;
} }
} }
rendered_decals++; rendered_decals++;
gl_RenderState.SetTextureMode(TM_MODULATE); gl_RenderState.SetTextureMode(TM_NORMAL);
gl_RenderState.SetObjectColor(0xffffffff); gl_RenderState.SetObjectColor(0xffffffff);
gl_RenderState.SetFog(fc, -1); gl_RenderState.SetFog(fc, -1);
gl_RenderState.SetDynLight(0, 0, 0); gl_RenderState.SetDynLight(0, 0, 0);
@ -533,7 +532,7 @@ void FDrawInfo::DrawDecal(GLDecal *gldecal)
// //
// //
//========================================================================== //==========================================================================
void FDrawInfo::DrawDecals() void FDrawInfo::DrawDecals(FRenderState &state)
{ {
side_t *wall = nullptr; side_t *wall = nullptr;
bool splitting = false; bool splitting = false;
@ -554,7 +553,7 @@ void FDrawInfo::DrawDecals()
SetFog(gldecal->lightlevel, gldecal->rellight, &gldecal->Colormap, false); SetFog(gldecal->lightlevel, gldecal->rellight, &gldecal->Colormap, false);
} }
} }
DrawDecal(gldecal); DrawDecal(gldecal, state);
} }
if (splitting) gl_RenderState.EnableSplit(false); if (splitting) gl_RenderState.EnableSplit(false);
} }
@ -564,14 +563,14 @@ void FDrawInfo::DrawDecals()
// This list will never get long, so this code should be ok. // This list will never get long, so this code should be ok.
// //
//========================================================================== //==========================================================================
void FDrawInfo::DrawDecalsForMirror(GLWall *wall) void FDrawInfo::DrawDecalsForMirror(GLWall *wall, FRenderState &state)
{ {
SetFog(wall->lightlevel, wall->rellight + getExtraLight(), &wall->Colormap, false); SetFog(wall->lightlevel, wall->rellight + getExtraLight(), &wall->Colormap, false);
for (auto gldecal : decals[1]) for (auto gldecal : decals[1])
{ {
if (gldecal->decal->Side == wall->seg->sidedef) if (gldecal->decal->Side == wall->seg->sidedef)
{ {
DrawDecal(gldecal); DrawDecal(gldecal, state);
} }
} }
} }

View file

@ -3,19 +3,6 @@
#include "basictypes.h" #include "basictypes.h"
enum TexMode
{
TM_MODULATE = 0, // (r, g, b, a)
TM_MASK, // (1, 1, 1, a)
TM_OPAQUE, // (r, g, b, 1)
TM_INVERSE, // (1-r, 1-g, 1-b, a)
TM_REDTOALPHA, // (1, 1, 1, r)
TM_CLAMPY, // (r, g, b, (t >= 0.0 && t <= 1.0)? a:0)
TM_INVERTOPAQUE, // (1-r, 1-g, 1-b, 1)
TM_FOGLAYER, // (renders a fog layer in the shape of the active texture)
TM_FIXEDCOLORMAP = TM_FOGLAYER, // repurposes the objectcolor uniforms to render a fixed colormap range. (Same constant because they cannot be used in the same context.
};
struct RenderContext struct RenderContext
{ {
unsigned int flags; unsigned int flags;

View file

@ -218,6 +218,22 @@ public:
mTextureMode = mode; mTextureMode = mode;
} }
void SetTextureMode(FRenderStyle style)
{
if (style.Flags & STYLEF_RedIsAlpha)
{
mTextureMode = TM_ALPHATEXTURE;
}
else if (style.Flags & STYLEF_ColorIsFixed)
{
mTextureMode = TM_STENCIL;
}
else if (style.Flags & STYLEF_InvertSource)
{
mTextureMode = TM_INVERSE;
}
}
int GetTextureMode() int GetTextureMode()
{ {
return mTextureMode; return mTextureMode;

View file

@ -44,6 +44,19 @@ enum
OPAQUE = 65536, OPAQUE = 65536,
}; };
enum ETexMode
{
TM_NORMAL = 0, // (r, g, b, a)
TM_STENCIL, // (1, 1, 1, a)
TM_OPAQUE, // (r, g, b, 1)
TM_INVERSE, // (1-r, 1-g, 1-b, a)
TM_ALPHATEXTURE, // (1, 1, 1, r)
TM_CLAMPY, // (r, g, b, (t >= 0.0 && t <= 1.0)? a:0)
TM_INVERTOPAQUE, // (1-r, 1-g, 1-b, 1)
TM_FOGLAYER, // (renders a fog layer in the shape of the active texture)
TM_FIXEDCOLORMAP = TM_FOGLAYER, // repurposes the objectcolor uniforms to render a fixed colormap range. (Same constant because they cannot be used in the same context.
};
// Legacy render styles // Legacy render styles
enum ERenderStyle enum ERenderStyle
{ {

View file

@ -203,22 +203,22 @@ bool F2DDrawer::SetStyle(FTexture *tex, DrawParms &parms, PalEntry &vertexcolor,
if (style.Flags & STYLEF_RedIsAlpha) if (style.Flags & STYLEF_RedIsAlpha)
{ {
quad.mDrawMode = DTM_AlphaTexture; quad.mDrawMode = TM_ALPHATEXTURE;
} }
else else
{ {
quad.mDrawMode = DTM_Stencil; quad.mDrawMode = TM_STENCIL;
} }
} }
else else
{ {
if (style.Flags & STYLEF_RedIsAlpha) if (style.Flags & STYLEF_RedIsAlpha)
{ {
quad.mDrawMode = DTM_AlphaTexture; quad.mDrawMode = TM_ALPHATEXTURE;
} }
else if (style.Flags & STYLEF_InvertSource) else if (style.Flags & STYLEF_InvertSource)
{ {
quad.mDrawMode = DTM_Invert; quad.mDrawMode = TM_INVERSE;
} }
if (parms.specialcolormap != nullptr) if (parms.specialcolormap != nullptr)
@ -237,9 +237,9 @@ bool F2DDrawer::SetStyle(FTexture *tex, DrawParms &parms, PalEntry &vertexcolor,
if (!parms.masked) if (!parms.masked)
{ {
// For DTM_AlphaTexture and DTM_Stencil the mask cannot be turned off because it would not yield a usable result. // For TM_ALPHATEXTURE and TM_STENCIL the mask cannot be turned off because it would not yield a usable result.
if (quad.mDrawMode == DTM_Normal) quad.mDrawMode = DTM_Opaque; if (quad.mDrawMode == TM_NORMAL) quad.mDrawMode = TM_OPAQUE;
else if (quad.mDrawMode == DTM_Invert) quad.mDrawMode = DTM_InvertOpaque; else if (quad.mDrawMode == TM_INVERSE) quad.mDrawMode = TM_INVERTOPAQUE;
} }
quad.mRenderStyle = parms.style; // this contains the blend mode and blend equation settings. quad.mRenderStyle = parms.style; // this contains the blend mode and blend equation settings.
if (parms.burn) quad.mFlags |= DTF_Burn; if (parms.burn) quad.mFlags |= DTF_Burn;

View file

@ -39,16 +39,6 @@ public:
DrawTypePoints, DrawTypePoints,
}; };
enum ETextureDrawMode : uint8_t
{
DTM_Normal = 0,
DTM_Stencil = 1,
DTM_Opaque = 2,
DTM_Invert = 3,
DTM_AlphaTexture = 4,
DTM_InvertOpaque = 6,
};
enum ETextureFlags : uint8_t enum ETextureFlags : uint8_t
{ {
DTF_Wrap = 1, DTF_Wrap = 1,
@ -101,7 +91,7 @@ public:
int mDesaturate; int mDesaturate;
FRenderStyle mRenderStyle; FRenderStyle mRenderStyle;
PalEntry mColor1; // Overlay color PalEntry mColor1; // Overlay color
ETextureDrawMode mDrawMode; ETexMode mDrawMode;
uint8_t mFlags; uint8_t mFlags;
RenderCommand() RenderCommand()

View file

@ -34,6 +34,7 @@
#ifndef __V_VIDEO_H__ #ifndef __V_VIDEO_H__
#define __V_VIDEO_H__ #define __V_VIDEO_H__
#include <functional>
#include "doomtype.h" #include "doomtype.h"
#include "vectors.h" #include "vectors.h"
@ -43,7 +44,6 @@
#include "c_cvars.h" #include "c_cvars.h"
#include "v_colortables.h" #include "v_colortables.h"
#include "v_2ddrawer.h" #include "v_2ddrawer.h"
#include <functional>
struct sector_t; struct sector_t;
class IShaderProgram; class IShaderProgram;
@ -64,6 +64,7 @@ enum EHWCaps
RFL_DEBUG = 128, RFL_DEBUG = 128,
}; };
struct IntRect struct IntRect
{ {
int left, top; int left, top;

View file

@ -76,7 +76,7 @@ vec4 getTexel(vec2 st)
// //
switch (uTextureMode) switch (uTextureMode)
{ {
case 1: // TM_MASK case 1: // TM_STENCIL
texel.rgb = vec3(1.0,1.0,1.0); texel.rgb = vec3(1.0,1.0,1.0);
break; break;
@ -88,7 +88,7 @@ vec4 getTexel(vec2 st)
texel = vec4(1.0-texel.r, 1.0-texel.b, 1.0-texel.g, texel.a); texel = vec4(1.0-texel.r, 1.0-texel.b, 1.0-texel.g, texel.a);
break; break;
case 4: // TM_REDTOALPHA case 4: // TM_ALPHATEXTURE
{ {
float gray = grayscale(texel); float gray = grayscale(texel);
texel = vec4(1.0, 1.0, 1.0, gray*texel.a); texel = vec4(1.0, 1.0, 1.0, gray*texel.a);