- migration of texture tinting to GZDoom's version.

- start of visibility migration - removing unused globvis variable.
This commit is contained in:
Christoph Oelckers 2020-06-05 17:02:21 +02:00
parent f3ed580b82
commit 9dfd3ddd02
9 changed files with 167 additions and 143 deletions

View file

@ -1101,7 +1101,7 @@ fix16_t qglobalang;
int32_t globalpal, cosglobalang, singlobalang;
int32_t cosviewingrangeglobalang, sinviewingrangeglobalang;
static int32_t globaluclip, globaldclip;
int32_t globvis, globalvisibility;
int32_t globalvisibility;
int32_t globalhisibility, globalpisibility, globalcisibility;
#ifdef USE_OPENGL
int32_t globvis2, globalvisibility2, globalhisibility2, globalpisibility2, globalcisibility2;
@ -3265,8 +3265,6 @@ void renderDrawMapView(int32_t dax, int32_t day, int32_t zoome, int16_t ang)
if ((tilesiz[globalpicnum].x <= 0) || (tilesiz[globalpicnum].y <= 0)) continue;
globalshade = max(min<int>(sec->floorshade, numshades - 1), 0);
globvis = globalhisibility;
if (sec->visibility != 0) globvis = mulscale4(globvis, (uint8_t)(sec->visibility+16));
if ((globalorientation&64) == 0)
{
set_globalpos(dax, day, globalposz);
@ -3384,8 +3382,6 @@ void renderDrawMapView(int32_t dax, int32_t day, int32_t zoome, int16_t ang)
else
globalshade = ((int32_t)sector[spr->sectnum].floorshade);
globalshade = max(min(globalshade+spr->shade+6,numshades-1),0);
globvis = globalhisibility;
if (sec->visibility != 0) globvis = mulscale4(globvis, (uint8_t)(sec->visibility+16));
//relative alignment stuff
ox = v2.x-v1.x; oy = v2.y-v1.y;

View file

@ -98,7 +98,7 @@ extern int32_t globalhisibility, globalpisibility, globalcisibility;
#ifdef USE_OPENGL
extern int32_t globvis2, globalvisibility2, globalhisibility2, globalpisibility2, globalcisibility2;
#endif
extern int32_t globvis, globalvisibility;
extern int32_t globalvisibility;
extern int32_t xyaspect;
extern int32_t globalshade;
extern int16_t globalpicnum;

View file

@ -38,6 +38,12 @@ CUSTOM_CVARD(Bool, hw_useindexedcolortextures, false, CVAR_ARCHIVE | CVAR_GLOBAL
}
void PrintVis(int sectvis, char type)
{
Printf("%c: g_vis = %d, gv = %d, gv2 = %d, gc = %d, gc2 = %d, gh2 = %d, globvis2 = %d, fviewingrange = %f, sectvis = %d, result = %f\n",
type, g_visibility, globalvisibility, globalvisibility2, globalcisibility, globalcisibility2, globalhisibility2, globvis2, fviewingrange, sectvis, GLInterface.renderState.VisFactor);
}
//{ "r_yshearing", "enable/disable y-shearing", (void*)&r_yshearing, CVAR_BOOL, 0, 1 }, disabled because not fully functional
// For testing - will be removed later.
@ -2084,12 +2090,10 @@ static void polymost_drawalls(int32_t const bunch)
globalshade = sec->floorshade;
globalpal = sec->floorpal;
globalorientation = sec->floorstat;
globvis = (sector[sectnum].visibility != 0) ?
mulscale4(globalcisibility, (uint8_t)(sector[sectnum].visibility + 16)) :
globalcisibility;
globvis2 = (sector[sectnum].visibility != 0) ?
mulscale4(globalcisibility2, (uint8_t)(sector[sectnum].visibility + 16)) :
globalcisibility2;
PrintVis(sector[sectnum].visibility, 'c');
GLInterface.SetVisibility(globvis2, fviewingrange);
tileUpdatePicnum(&globalpicnum, sectnum);
@ -2342,13 +2346,11 @@ static void polymost_drawalls(int32_t const bunch)
globalshade = sec->ceilingshade;
globalpal = sec->ceilingpal;
globalorientation = sec->ceilingstat;
globvis = (sector[sectnum].visibility != 0) ?
mulscale4(globalcisibility, (uint8_t)(sector[sectnum].visibility + 16)) :
globalcisibility;
globvis2 = (sector[sectnum].visibility != 0) ?
mulscale4(globalcisibility2, (uint8_t)(sector[sectnum].visibility + 16)) :
globalcisibility2;
GLInterface.SetVisibility(globvis2, fviewingrange);
PrintVis(sector[sectnum].visibility, 'c');
GLInterface.SetVisibility(globvis2, fviewingrange);
tileUpdatePicnum(&globalpicnum, sectnum);
@ -2668,11 +2670,10 @@ static void polymost_drawalls(int32_t const bunch)
if (((cy0 < ocy0) || (cy1 < ocy1)) && (!((sec->ceilingstat&sector[nextsectnum].ceilingstat)&1)))
{
globalpicnum = wal->picnum; globalshade = wal->shade; globalpal = (int32_t)((uint8_t)wal->pal);
globvis = globalvisibility;
if (sector[sectnum].visibility != 0) globvis = mulscale4(globvis, (uint8_t)(sector[sectnum].visibility+16));
globvis2 = globalvisibility2;
if (sector[sectnum].visibility != 0) globvis2 = mulscale4(globvis2, (uint8_t)(sector[sectnum].visibility+16));
GLInterface.SetVisibility(globvis2, fviewingrange);
PrintVis(sector[sectnum].visibility, 'v');
GLInterface.SetVisibility(globvis2, fviewingrange);
globalorientation = wal->cstat;
tileUpdatePicnum(&globalpicnum, wallnum+16384);
@ -2710,11 +2711,10 @@ static void polymost_drawalls(int32_t const bunch)
ytex.u += (float)(nwal->xpanning - wal->xpanning) * ytex.d;
}
globalpicnum = nwal->picnum; globalshade = nwal->shade; globalpal = (int32_t)((uint8_t)nwal->pal);
globvis = globalvisibility;
if (sector[sectnum].visibility != 0) globvis = mulscale4(globvis, (uint8_t)(sector[sectnum].visibility+16));
globvis2 = globalvisibility2;
if (sector[sectnum].visibility != 0) globvis2 = mulscale4(globvis2, (uint8_t)(sector[sectnum].visibility+16));
GLInterface.SetVisibility(globvis2, fviewingrange);
PrintVis(sector[sectnum].visibility, 'v');
GLInterface.SetVisibility(globvis2, fviewingrange);
globalorientation = nwal->cstat;
tileUpdatePicnum(&globalpicnum, wallnum+16384);
@ -2758,13 +2758,11 @@ static void polymost_drawalls(int32_t const bunch)
globalshade = wal->shade;
globalpal = wal->pal;
globvis = (sector[sectnum].visibility != 0) ?
mulscale4(globalvisibility, (uint8_t)(sector[sectnum].visibility + 16)) :
globalvisibility;
globvis2 = (sector[sectnum].visibility != 0) ?
mulscale4(globalvisibility2, (uint8_t)(sector[sectnum].visibility + 16)) :
globalvisibility2;
GLInterface.SetVisibility(globvis2, fviewingrange);
PrintVis(sector[sectnum].visibility, 'v');
GLInterface.SetVisibility(globvis2, fviewingrange);
globalorientation = wal->cstat;
tileUpdatePicnum(&globalpicnum, wallnum+16384);
@ -3356,12 +3354,10 @@ static void polymost_drawmaskwallinternal(int32_t wallIndex)
globalorientation = (int32_t)wal->cstat;
tileUpdatePicnum(&globalpicnum, (int16_t)wallIndex+16384);
globvis = globalvisibility;
globvis = (sector[sectnum].visibility != 0) ? mulscale4(globvis, (uint8_t)(sector[sectnum].visibility + 16)) : globalvisibility;
globvis2 = globalvisibility2;
globvis2 = (sector[sectnum].visibility != 0) ? mulscale4(globvis2, (uint8_t)(sector[sectnum].visibility + 16)) : globalvisibility2;
GLInterface.SetVisibility(globvis2, fviewingrange);
PrintVis(sector[sectnum].visibility, 'v');
GLInterface.SetVisibility(globvis2, fviewingrange);
globalshade = (int32_t)wal->shade;
globalpal = (int32_t)((uint8_t)wal->pal);
@ -3733,15 +3729,12 @@ void polymost_drawsprite(int32_t snum)
globalshade = tspr->shade;
globalpal = tspr->pal;
globalorientation = tspr->cstat;
globvis = globalvisibility;
if (sector[tspr->sectnum].visibility != 0)
globvis = mulscale4(globvis, (uint8_t)(sector[tspr->sectnum].visibility + 16));
globvis2 = globalvisibility2;
if (sector[tspr->sectnum].visibility != 0)
globvis2 = mulscale4(globvis2, (uint8_t)(sector[tspr->sectnum].visibility + 16));
GLInterface.SetVisibility(globvis2, fviewingrange);
PrintVis(sector[tspr->sectnum].visibility, 'v');
GLInterface.SetVisibility(globvis2, fviewingrange);
vec2_t off = { 0, 0 };
@ -4154,7 +4147,8 @@ void polymost_drawsprite(int32_t snum)
globvis2 = globalhisibility2;
if (sector[tspr->sectnum].visibility != 0)
globvis2 = mulscale4(globvis2, (uint8_t)(sector[tspr->sectnum].visibility + 16));
GLInterface.SetVisibility(globvis2, fviewingrange);
PrintVis(sector[tspr->sectnum].visibility, 'h');
GLInterface.SetVisibility(globvis2, fviewingrange);
if ((globalorientation & 64) != 0 && (globalposz > pos.z) == (!(globalorientation & 8)))
goto _drawsprite_return;

View file

@ -66,10 +66,6 @@ bool FShader::Load(const char * name, const char * vert_prog, const char * frag_
glAttachShader(hShader, hVertProg);
glAttachShader(hShader, hFragProg);
glBindAttribLocation(hShader, 0, "i_vertPos");
glBindAttribLocation(hShader, 1, "i_texCoord");
glBindAttribLocation(hShader, 2, "i_color");
glLinkProgram(hShader);
glGetShaderInfoLog(hVertProg, 10000, NULL, buffer);
@ -146,15 +142,14 @@ bool PolymostShader::Load(const char * name, const char * vert_prog, const char
NPOTEmulationXOffset.Init(hShader, "u_npotEmulationXOffset");
Brightness.Init(hShader, "u_brightness");
FogColor.Init(hShader, "u_fogColor");
AlphaThreshold.Init(hShader, "u_alphaThreshold");
FullscreenTint.Init(hShader, "u_fullscreenTint");
TintModulate.Init(hShader, "u_tintModulate");
TintOverlay.Init(hShader, "u_tintOverlay");
TintFlags.Init(hShader, "u_tintFlags");
AlphaThreshold.Init(hShader, "uAlphaThreshold");
DetailParms.Init(hShader, "uDetailParms");
ModelMatrix.Init(hShader, "ModelMatrix");
TextureMatrix.Init(hShader, "TextureMatrix");
muTextureAddColor.Init(hShader, "uTextureAddColor");
muTextureModulateColor.Init(hShader, "uTextureModulateColor");
muTextureBlendColor.Init(hShader, "uTextureBlendColor");

View file

@ -13,15 +13,6 @@ class FShader
protected:
unsigned int hShader = 0;
#if 0
FName mName;
int projectionmatrix_index;
int viewmatrix_index;
int modelmatrix_index;
int texturematrix_index;
bool currentTextureMatrixState = false;
bool currentModelMatrixState = false;
#endif
public:
FShader() = default;
@ -44,15 +35,14 @@ public:
FBufferedUniform1f Brightness;
FBufferedUniform1f AlphaThreshold;
FBufferedUniformPalEntry FogColor;
FBufferedUniformPalEntry FullscreenTint;
FBufferedUniformPalEntry TintModulate;
FBufferedUniformPalEntry TintOverlay;
FBufferedUniform1i TintFlags;
FBufferedUniform4f DetailParms;
FUniformMatrix4f ModelMatrix;
FUniformMatrix4f TextureMatrix;
FBufferedUniform4f muTextureBlendColor;
FBufferedUniform4f muTextureModulateColor;
FBufferedUniform4f muTextureAddColor;
public:

View file

@ -100,7 +100,7 @@ void GLInstance::Init(int ydim)
LoadPolymostShader();
}
FString i_data = R"(
auto i_data = R"(
#version 330
// This must match the HWViewpointUniforms struct
layout(std140) uniform ViewpointUBO {
@ -122,6 +122,13 @@ FString i_data = R"(
uniform mat4 NormalModelMatrix;
uniform mat4 TextureMatrix;
uniform vec4 uDetailParms;
uniform vec4 uTextureBlendColor;
uniform vec4 uTextureModulateColor;
uniform vec4 uTextureAddColor;
uniform float uAlphaThreshold;
)";
void GLInstance::LoadPolymostShader()
@ -523,10 +530,34 @@ void PolymostRenderState::Apply(PolymostShader* shader, GLState &oldState)
shader->AlphaThreshold.Set(AlphaTest ? AlphaThreshold : -1.f);
shader->Brightness.Set(Brightness);
shader->FogColor.Set(FogColor);
shader->TintFlags.Set(hictint_flags);
shader->TintModulate.Set(hictint);
shader->TintOverlay.Set(hictint_overlay);
shader->FullscreenTint.Set(fullscreenTint);
FVector4 addcol(0, 0, 0, 0);
FVector4 modcol(fullscreenTint.r / 255.f, fullscreenTint.g / 255.f, fullscreenTint.b / 255.f, 0);
FVector4 blendcol(0, 0, 0, 0);
int flags = 0;
if (fullscreenTint != 0xffffff) flags |= 16;
if (hictint_flags != -1)
{
flags |= 16;
if (hictint_flags & TINTF_COLORIZE)
{
modcol.X *= hictint.r / 64.f;
modcol.Y *= hictint.g / 64.f;
modcol.Z *= hictint.b / 64.f;
}
if (hictint_flags & TINTF_GRAYSCALE)
modcol.W = 1.f;
if (hictint_flags & TINTF_INVERT)
flags |= 8;
if (hictint_flags & TINTF_BLENDMASK)
flags |= ((hictint_flags & TINTF_BLENDMASK) >> 6) + 1;
addcol.W = flags;
}
shader->muTextureAddColor.Set(&addcol[0]);
shader->muTextureModulateColor.Set(&modcol[0]);
shader->muTextureBlendColor.Set(&blendcol[0]);
if (matrixIndex[Matrix_Model] != -1)
shader->ModelMatrix.Set(matrixArray[matrixIndex[Matrix_Model]].get());

View file

@ -106,6 +106,7 @@ struct GLState
class GLInstance
{
public:
TArray<PolymostRenderState> rendercommands;
int maxTextureSize;
PaletteManager palmanager;

View file

@ -8,15 +8,6 @@ const int RF_ShadeInterpolate = 64;
const int RF_FogDisabled = 128;
const int RF_MapFog = 256;
const int RF_TINT_Grayscale = 0x1;
const int RF_TINT_Invert = 0x2;
const int RF_TINT_Colorize = 0x4;
const int RF_TINT_BLEND_Screen = 64;
const int RF_TINT_BLEND_Overlay = 128;
const int RF_TINT_BLEND_Hardlight = 192;
const int RF_TINT_BLENDMASK = RF_TINT_BLEND_Screen | RF_TINT_BLEND_Overlay | RF_TINT_BLEND_Hardlight;
//s_texture points to an indexed color texture
uniform sampler2D s_texture;
//s_palswap is the palette swap texture where u is the color index and v is the shade
@ -29,22 +20,14 @@ uniform sampler2D s_glow;
uniform sampler2D s_brightmap;
uniform float u_shade;
uniform float u_numShades;
uniform float u_shadeDiv;
uniform float u_visFactor;
uniform int u_flags;
uniform float u_alphaThreshold;
uniform vec4 u_tintOverlay, u_tintModulate;
uniform int u_tintFlags;
uniform vec4 u_fullscreenTint;
uniform float u_npotEmulationFactor;
uniform float u_npotEmulationXOffset;
uniform float u_brightness;
uniform vec4 u_fogColor;
uniform vec3 u_tintcolor;
uniform vec3 u_tintmodulate;
in vec4 v_color;
in float v_distance;
@ -52,15 +35,7 @@ in vec4 v_texCoord;
in vec4 v_detailCoord;
in float v_fogCoord;
in vec4 v_eyeCoordPosition;
const float c_basepalScale = 255.0/256.0;
const float c_basepalOffset = 0.5/256.0;
const float c_zero = 0.0;
const float c_one = 1.0;
const float c_two = 2.0;
const vec4 c_vec4_one = vec4(c_one);
const float c_wrapThreshold = 0.9;
in vec4 v_worldPosition;
layout(location=0) out vec4 fragColor;
layout(location=1) out vec4 fragFog;
@ -76,67 +51,93 @@ float grayscale(vec4 color)
{
return dot(color.rgb, vec3(0.3, 0.56, 0.14));
}
//===========================================================================
//
// Hightile tinting code. (hictinting[dapalnum]) This can be done inside the shader
// to avoid costly texture duplication (but needs a more modern GLSL than 1.10.)
// Desaturate a color
//
//===========================================================================
vec4 convertColor(vec4 color)
vec4 dodesaturate(vec4 texel, float factor)
{
int effect = u_tintFlags;
if ((effect & RF_TINT_Grayscale) != 0)
if (factor != 0.0)
{
float g = grayscale(color);
color = vec4(g, g, g, color.a);
}
if ((effect & RF_TINT_Invert) != 0)
{
color = vec4(1.0 - color.r, 1.0 - color.g, 1.0 - color.b, color.a);
}
vec3 tcol = color.rgb * 255.0; // * 255.0 to make it easier to reuse the integer math.
// Much of this looks quite broken by design. Why is this effectively multplied by 4 if the flag is set...? :(
if ((effect & RF_TINT_Colorize) != 0)
{
tcol.r = min(((tcol.b) * u_tintModulate.r)* 4, 255.0);
tcol.g = min(((tcol.g) * u_tintModulate.g)* 4, 255.0);
tcol.b = min(((tcol.r) * u_tintModulate.b)* 4, 255.0);
float gray = grayscale(texel);
return mix (texel, vec4(gray,gray,gray,texel.a), factor);
}
else
{
tcol.r = min(((tcol.b) * u_tintModulate.r), 255.0);
tcol.g = min(((tcol.g) * u_tintModulate.g), 255.0);
tcol.b = min(((tcol.r) * u_tintModulate.b), 255.0);
return texel;
}
vec4 ov = u_tintOverlay * 255.0;
switch (effect & RF_TINT_BLENDMASK)
{
case RF_TINT_BLEND_Screen:
tcol.r = 255.0 - (((255.0 - tcol.r) * (255.0 - ov.r)) / 256.0);
tcol.g = 255.0 - (((255.0 - tcol.g) * (255.0 - ov.g)) / 256.0);
tcol.b = 255.0 - (((255.0 - tcol.b) * (255.0 - ov.b)) / 256.0);
break;
case RF_TINT_BLEND_Overlay:
tcol.r = tcol.b < 128.0? (tcol.r * ov.r) / 128.0 : 255.0 - (((255.0 - tcol.r) * (255.0 - ov.r)) / 128.0);
tcol.g = tcol.g < 128.0? (tcol.g * ov.g) / 128.0 : 255.0 - (((255.0 - tcol.g) * (255.0 - ov.g)) / 128.0);
tcol.b = tcol.r < 128.0? (tcol.b * ov.b) / 128.0 : 255.0 - (((255.0 - tcol.b) * (255.0 - ov.b)) / 128.0);
break;
case RF_TINT_BLEND_Hardlight:
tcol.r = ov.r < 128.0 ? (tcol.r * ov.r) / 128.0 : 255.0 - (((255.0 - tcol.r) * (255.0 - ov.r)) / 128.0);
tcol.g = ov.g < 128.0 ? (tcol.g * ov.g) / 128.0 : 255.0 - (((255.0 - tcol.g) * (255.0 - ov.g)) / 128.0);
tcol.b = ov.b < 128.0 ? (tcol.b * ov.b) / 128.0 : 255.0 - (((255.0 - tcol.b) * (255.0 - ov.b)) / 128.0);
break;
}
color.rgb = tcol / 255.0;
return color;
}
//===========================================================================
//
// Texture tinting code originally from JFDuke but with a few more options
//
//===========================================================================
const int Tex_Blend_Alpha = 1;
const int Tex_Blend_Screen = 2;
const int Tex_Blend_Overlay = 3;
const int Tex_Blend_Hardlight = 4;
vec4 ApplyTextureManipulation(vec4 texel, int blendflags)
{
// Step 1: desaturate according to the material's desaturation factor.
texel = dodesaturate(texel, uTextureModulateColor.a);
// Step 2: Invert if requested
if ((blendflags & 8) != 0)
{
texel.rgb = vec3(1.0 - texel.r, 1.0 - texel.g, 1.0 - texel.b);
}
// Step 3: Apply additive color
texel.rgb += uTextureAddColor.rgb;
// Step 4: Colorization, including gradient if set.
texel.rgb *= uTextureModulateColor.rgb;
// Before applying the blend the value needs to be clamped to [0..1] range.
texel.rgb = clamp(texel.rgb, 0.0, 1.0);
// Step 5: Apply a blend. This may just be a translucent overlay or one of the blend modes present in current Build engines.
if ((blendflags & 7) != 0)
{
vec3 tcol = texel.rgb * 255.0; // * 255.0 to make it easier to reuse the integer math.
vec4 tint = uTextureBlendColor * 255.0;
switch (blendflags & 7)
{
default:
tcol.b = tcol.b * (1.0 - uTextureBlendColor.a) + tint.b * uTextureBlendColor.a;
tcol.g = tcol.g * (1.0 - uTextureBlendColor.a) + tint.g * uTextureBlendColor.a;
tcol.r = tcol.r * (1.0 - uTextureBlendColor.a) + tint.r * uTextureBlendColor.a;
break;
// The following 3 are taken 1:1 from the Build engine
case Tex_Blend_Screen:
tcol.b = 255.0 - (((255.0 - tcol.b) * (255.0 - tint.r)) / 256.0);
tcol.g = 255.0 - (((255.0 - tcol.g) * (255.0 - tint.g)) / 256.0);
tcol.r = 255.0 - (((255.0 - tcol.r) * (255.0 - tint.b)) / 256.0);
break;
case Tex_Blend_Overlay:
tcol.b = tcol.b < 128.0? (tcol.b * tint.b) / 128.0 : 255.0 - (((255.0 - tcol.b) * (255.0 - tint.b)) / 128.0);
tcol.g = tcol.g < 128.0? (tcol.g * tint.g) / 128.0 : 255.0 - (((255.0 - tcol.g) * (255.0 - tint.g)) / 128.0);
tcol.r = tcol.r < 128.0? (tcol.r * tint.r) / 128.0 : 255.0 - (((255.0 - tcol.r) * (255.0 - tint.r)) / 128.0);
break;
case Tex_Blend_Hardlight:
tcol.b = tint.b < 128.0 ? (tcol.b * tint.b) / 128.0 : 255.0 - (((255.0 - tcol.b) * (255.0 - tint.b)) / 128.0);
tcol.g = tint.g < 128.0 ? (tcol.g * tint.g) / 128.0 : 255.0 - (((255.0 - tcol.g) * (255.0 - tint.g)) / 128.0);
tcol.r = tint.r < 128.0 ? (tcol.r * tint.r) / 128.0 : 255.0 - (((255.0 - tcol.r) * (255.0 - tint.r)) / 128.0);
break;
}
texel.rgb = tcol / 255.0;
}
return texel;
}
//===========================================================================
//
//
@ -197,7 +198,7 @@ void main()
palettedColor.rgb = mix(palettedColor.rgb, palettedColorNext.rgb, shadeFrac);
}
palettedColor.a = color.r == 0.0? 0.0 : 1.0;// c_one-floor(color.r);
palettedColor.a = color.r == 0.0? 0.0 : 1.0;// 1.0-floor(color.r);
color = palettedColor;
color.rgb *= detailColor.rgb; // with all this palettizing, this can only be applied afterward, even though it is wrong to do it this way.
color.rgb *= v_color.rgb; // Well, this is dead wrong but unavoidable. For colored fog it applies the light to the fog as well...
@ -205,7 +206,15 @@ void main()
else
{
color.rgb *= detailColor.rgb;
if (u_tintFlags != -1) color = convertColor(color);
// Apply the texture modification colors.
int blendflags = int(uTextureAddColor.a); // this alpha is unused otherwise
if (blendflags != 0)
{
// only apply the texture manipulation if it contains something.
color = ApplyTextureManipulation(color, blendflags);
}
if ((u_flags & RF_FogDisabled) == 0)
{
shade = clamp(shade * u_shadeDiv, 0.0, 1.0); // u_shadeDiv is really 1/shadeDiv.
@ -225,7 +234,7 @@ void main()
float fogfactor = 0.55 + 0.3 * exp2 (-5.0*v_fogCoord);
color.rgb = vec3(0.6*(1.0-fogfactor)) + color.rgb * fogfactor;// mix(vec3(0.6), color.rgb, fogfactor);
}
if (color.a < u_alphaThreshold) discard; // it's only here that we have the alpha value available to be able to perform the alpha test.
if (color.a < uAlphaThreshold) discard; // it's only here that we have the alpha value available to be able to perform the alpha test.
color.a *= v_color.a;
}
@ -241,8 +250,16 @@ void main()
color.rgb = mix(color.rgb, glowColor.rgb, glowColor.a);
}
/*
int ix = int (v_worldPosition.x);
int iy = int (v_worldPosition.z);
int iz = int (v_worldPosition.y);
if ((ix & 64) == 1) color.r = 0;
if ((iy & 64) == 1) color.g = 0;
if ((iz & 64) == 1) color.b = 0;
*/
color.rgb = pow(color.rgb, vec3(u_brightness));
color.rgb *= u_fullscreenTint.rgb; // must be the last thing to be done.
fragColor = color;
fragFog = vec4(0.0, 0.0, 0.0, 1.0); // Does build have colored fog?
vec3 normal = normalize(cross(dFdx(v_eyeCoordPosition.xyz), dFdy(v_eyeCoordPosition.xyz)));

View file

@ -3,12 +3,11 @@ out float v_distance;
out vec4 v_texCoord;
out float v_fogCoord;
out vec4 v_eyeCoordPosition;
out vec4 v_worldPosition;
uniform float u_usePalette;
in vec4 i_vertPos;
in vec4 i_texCoord;
in vec4 i_color;
layout(location = 0) in vec4 i_vertPos;
layout(location = 1) in vec4 i_texCoord;
layout(location = 2) in vec4 i_color;
@ -27,4 +26,5 @@ void main()
v_color = i_color;
v_distance = eyeCoordPosition.z;
v_worldPosition = vertex;
}