mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-26 22:01:45 +00:00
- convert texturefactor to uniform
This commit is contained in:
parent
3968206199
commit
0542bd25ec
8 changed files with 65 additions and 51 deletions
|
@ -172,11 +172,6 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
RenderDevice_SetMultisampleAntialias(Handle, value);
|
||||
}
|
||||
|
||||
public void SetTextureFactor(int factor)
|
||||
{
|
||||
// To do: is this even applied to fragment shaders? if not, delete - if it is, convert to uniform
|
||||
}
|
||||
|
||||
public void SetZEnable(bool value)
|
||||
{
|
||||
RenderDevice_SetZEnable(Handle, value);
|
||||
|
@ -351,7 +346,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
SetFogEnable(false);
|
||||
SetMultisampleAntialias((General.Settings.AntiAliasingSamples > 0));
|
||||
SetSourceBlend(Blend.SourceAlpha);
|
||||
SetTextureFactor(-1);
|
||||
SetUniform(UniformName.texturefactor, new Color4(1f, 1f, 1f, 1f));
|
||||
SetZEnable(false);
|
||||
SetZWriteEnable(false);
|
||||
|
||||
|
@ -577,7 +572,8 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
lightColor,
|
||||
ignoreNormals,
|
||||
spotLight,
|
||||
campos
|
||||
campos,
|
||||
texturefactor
|
||||
}
|
||||
|
||||
public enum VertexFormat : int { Flat, World }
|
||||
|
|
|
@ -202,21 +202,21 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
case BlendingMode.None:
|
||||
graphics.SetAlphaBlendEnable(false);
|
||||
graphics.SetAlphaTestEnable(false);
|
||||
graphics.SetTextureFactor(-1);
|
||||
break;
|
||||
graphics.SetUniform(UniformName.texturefactor, new Color4(1f, 1f, 1f, 1f));
|
||||
break;
|
||||
|
||||
case BlendingMode.Mask:
|
||||
graphics.SetAlphaBlendEnable(false);
|
||||
graphics.SetAlphaTestEnable(true);
|
||||
graphics.SetTextureFactor(-1);
|
||||
break;
|
||||
graphics.SetUniform(UniformName.texturefactor, new Color4(1f, 1f, 1f, 1f));
|
||||
break;
|
||||
|
||||
case BlendingMode.Alpha:
|
||||
graphics.SetAlphaBlendEnable(true);
|
||||
graphics.SetAlphaTestEnable(false);
|
||||
graphics.SetSourceBlend(Blend.SourceAlpha);
|
||||
graphics.SetDestinationBlend(Blend.InverseSourceAlpha);
|
||||
graphics.SetTextureFactor((new Color4(1f, 1f, 1f, layer.alpha)).ToArgb());
|
||||
graphics.SetUniform(UniformName.texturefactor, new Color4(1f, 1f, 1f, layer.alpha));
|
||||
break;
|
||||
|
||||
case BlendingMode.Additive:
|
||||
|
@ -224,7 +224,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
graphics.SetAlphaTestEnable(false);
|
||||
graphics.SetSourceBlend(Blend.SourceAlpha);
|
||||
graphics.SetDestinationBlend(Blend.One);
|
||||
graphics.SetTextureFactor((new Color4(1f, 1f, 1f, layer.alpha)).ToArgb());
|
||||
graphics.SetUniform(UniformName.texturefactor, new Color4(1f, 1f, 1f, layer.alpha));
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1229,7 +1229,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
graphics.SetDestinationBlend(Blend.InverseSourceAlpha);
|
||||
graphics.SetAlphaTestEnable(false);
|
||||
graphics.SetFogEnable(false);
|
||||
graphics.SetTextureFactor(alphacolor.ToArgb());
|
||||
graphics.SetUniform(UniformName.texturefactor, alphacolor);
|
||||
graphics.SetVertexBuffer(thingsvertices);
|
||||
|
||||
// Set things texture
|
||||
|
@ -1487,7 +1487,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
{
|
||||
// Set renderstates for rendering
|
||||
graphics.SetAlphaBlendEnable(false);
|
||||
graphics.SetTextureFactor(-1);
|
||||
graphics.SetUniform(UniformName.texturefactor, new Color4(1f, 1f, 1f, 1f));
|
||||
graphics.SetFillMode(FillMode.Wireframe);
|
||||
|
||||
graphics.SetShader(ShaderName.things2d_fill);
|
||||
|
@ -1583,8 +1583,8 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
graphics.SetZEnable(false);
|
||||
graphics.SetAlphaBlendEnable(false);
|
||||
graphics.SetAlphaTestEnable(false);
|
||||
graphics.SetTextureFactor(-1);
|
||||
graphics.SetFogEnable(false);
|
||||
graphics.SetUniform(UniformName.texturefactor, new Color4(1f, 1f, 1f, 1f));
|
||||
graphics.SetFogEnable(false);
|
||||
SetWorldTransformation(true);
|
||||
SetDisplay2DSettings(1f, 1f, 0f, 1f, General.Settings.ClassicBilinear);
|
||||
|
||||
|
@ -1641,8 +1641,8 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
graphics.SetZEnable(false);
|
||||
graphics.SetAlphaBlendEnable(false);
|
||||
graphics.SetAlphaTestEnable(false);
|
||||
graphics.SetTextureFactor(-1);
|
||||
graphics.SetFogEnable(false);
|
||||
graphics.SetUniform(UniformName.texturefactor, new Color4(1f, 1f, 1f, 1f));
|
||||
graphics.SetFogEnable(false);
|
||||
graphics.SetShader(ShaderName.display2d_normal);
|
||||
graphics.SetTexture(0, t);
|
||||
SetWorldTransformation(transformcoords);
|
||||
|
@ -1663,8 +1663,8 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
graphics.SetZEnable(false);
|
||||
graphics.SetAlphaBlendEnable(false);
|
||||
graphics.SetAlphaTestEnable(false);
|
||||
graphics.SetTextureFactor(-1);
|
||||
graphics.SetFogEnable(false);
|
||||
graphics.SetUniform(UniformName.texturefactor, new Color4(1f, 1f, 1f, 1f));
|
||||
graphics.SetFogEnable(false);
|
||||
|
||||
SetWorldTransformation(true);
|
||||
graphics.SetUniform(UniformName.FillColor, new Color4(color));
|
||||
|
@ -1691,8 +1691,8 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
graphics.SetZEnable(false);
|
||||
graphics.SetAlphaBlendEnable(true);
|
||||
graphics.SetAlphaTestEnable(false);
|
||||
graphics.SetTextureFactor(-1);
|
||||
graphics.SetFogEnable(false);
|
||||
graphics.SetUniform(UniformName.texturefactor, new Color4(1f, 1f, 1f, 1f));
|
||||
graphics.SetFogEnable(false);
|
||||
graphics.SetShader(ShaderName.display2d_normal);
|
||||
graphics.SetTexture(0, label.Texture);
|
||||
SetWorldTransformation(false);
|
||||
|
@ -1722,8 +1722,8 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
graphics.SetZEnable(false);
|
||||
graphics.SetAlphaBlendEnable(true);
|
||||
graphics.SetAlphaTestEnable(false);
|
||||
graphics.SetTextureFactor(-1);
|
||||
graphics.SetFogEnable(false);
|
||||
graphics.SetUniform(UniformName.texturefactor, new Color4(1f, 1f, 1f, 1f));
|
||||
graphics.SetFogEnable(false);
|
||||
SetWorldTransformation(false);
|
||||
graphics.SetShader(ShaderName.display2d_normal);
|
||||
SetDisplay2DSettings(1f, 1f, 0f, 1f, false);
|
||||
|
@ -1789,8 +1789,8 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
graphics.SetZEnable(false);
|
||||
graphics.SetAlphaBlendEnable(false);
|
||||
graphics.SetAlphaTestEnable(false);
|
||||
graphics.SetTextureFactor(-1);
|
||||
graphics.SetFogEnable(false);
|
||||
graphics.SetUniform(UniformName.texturefactor, new Color4(1f, 1f, 1f, 1f));
|
||||
graphics.SetFogEnable(false);
|
||||
SetWorldTransformation(false);
|
||||
graphics.SetShader(ShaderName.display2d_normal);
|
||||
graphics.SetTexture(0, General.Map.Data.WhiteTexture.Texture);
|
||||
|
@ -1824,8 +1824,8 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
graphics.SetZEnable(false);
|
||||
graphics.SetAlphaBlendEnable(false);
|
||||
graphics.SetAlphaTestEnable(false);
|
||||
graphics.SetTextureFactor(-1);
|
||||
graphics.SetFogEnable(false);
|
||||
graphics.SetUniform(UniformName.texturefactor, new Color4(1f, 1f, 1f, 1f));
|
||||
graphics.SetFogEnable(false);
|
||||
SetWorldTransformation(false);
|
||||
graphics.SetShader(ShaderName.display2d_normal);
|
||||
graphics.SetTexture(0, General.Map.Data.WhiteTexture.Texture);
|
||||
|
@ -1856,8 +1856,8 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
graphics.SetZEnable(false);
|
||||
graphics.SetAlphaBlendEnable(false);
|
||||
graphics.SetAlphaTestEnable(false);
|
||||
graphics.SetTextureFactor(-1);
|
||||
graphics.SetFogEnable(false);
|
||||
graphics.SetUniform(UniformName.texturefactor, new Color4(1f, 1f, 1f, 1f));
|
||||
graphics.SetFogEnable(false);
|
||||
SetWorldTransformation(false);
|
||||
graphics.SetShader(ShaderName.display2d_normal);
|
||||
graphics.SetTexture(0, texture.Texture);
|
||||
|
@ -1955,8 +1955,8 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
graphics.SetZEnable(false);
|
||||
graphics.SetAlphaBlendEnable(false);
|
||||
graphics.SetAlphaTestEnable(false);
|
||||
graphics.SetTextureFactor(-1);
|
||||
graphics.SetFogEnable(false);
|
||||
graphics.SetUniform(UniformName.texturefactor, new Color4(1f, 1f, 1f, 1f));
|
||||
graphics.SetFogEnable(false);
|
||||
SetWorldTransformation(false);
|
||||
graphics.SetShader(ShaderName.display2d_normal);
|
||||
graphics.SetTexture(0, General.Map.Data.WhiteTexture.Texture);
|
||||
|
@ -2007,8 +2007,8 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
graphics.SetZEnable(false);
|
||||
graphics.SetAlphaBlendEnable(false);
|
||||
graphics.SetAlphaTestEnable(false);
|
||||
graphics.SetTextureFactor(-1);
|
||||
graphics.SetFogEnable(false);
|
||||
graphics.SetUniform(UniformName.texturefactor, new Color4(1f, 1f, 1f, 1f));
|
||||
graphics.SetFogEnable(false);
|
||||
SetWorldTransformation(false);
|
||||
graphics.SetShader(ShaderName.display2d_normal);
|
||||
graphics.SetTexture(0, General.Map.Data.WhiteTexture.Texture);
|
||||
|
|
|
@ -316,8 +316,8 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
graphics.SetFogColor(General.Colors.Background.ToInt());
|
||||
graphics.SetFogStart(General.Settings.ViewDistance * FOG_RANGE);
|
||||
graphics.SetFogEnd(General.Settings.ViewDistance);
|
||||
graphics.SetTextureFactor(-1);
|
||||
graphics.SetUniform(UniformName.highlightcolor, new Color4()); //mxd
|
||||
graphics.SetUniform(UniformName.texturefactor, new Color4(1f, 1f, 1f, 1f));
|
||||
graphics.SetUniform(UniformName.highlightcolor, new Color4()); //mxd
|
||||
|
||||
// Texture addressing
|
||||
graphics.SetSamplerState(0, TextureAddress.Wrap);
|
||||
|
@ -384,10 +384,10 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
graphics.SetZWriteEnable(true);
|
||||
graphics.SetAlphaBlendEnable(false);
|
||||
graphics.SetAlphaTestEnable(false);
|
||||
graphics.SetTextureFactor(-1);
|
||||
graphics.SetUniform(UniformName.texturefactor, new Color4(1f, 1f, 1f, 1f));
|
||||
|
||||
//mxd. SKY PASS
|
||||
if(skygeo.Count > 0)
|
||||
//mxd. SKY PASS
|
||||
if (skygeo.Count > 0)
|
||||
{
|
||||
world = Matrix.Identity;
|
||||
ApplyMatrices3D();
|
||||
|
@ -611,8 +611,8 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
}
|
||||
|
||||
// Done
|
||||
graphics.SetTextureFactor(-1);
|
||||
}
|
||||
graphics.SetUniform(UniformName.texturefactor, new Color4(1f, 1f, 1f, 1f));
|
||||
}
|
||||
|
||||
//mxd
|
||||
private void RenderVertices()
|
||||
|
@ -651,8 +651,8 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
}
|
||||
|
||||
// Done
|
||||
graphics.SetTextureFactor(-1);
|
||||
}
|
||||
graphics.SetUniform(UniformName.texturefactor, new Color4(1f, 1f, 1f, 1f));
|
||||
}
|
||||
|
||||
//mxd
|
||||
private void RenderArrows(ICollection<Line3D> lines)
|
||||
|
@ -729,8 +729,8 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
graphics.Draw(PrimitiveType.LineList, 0, pointscount / 2);
|
||||
|
||||
// Done
|
||||
graphics.SetTextureFactor(-1);
|
||||
vb.Dispose();
|
||||
graphics.SetUniform(UniformName.texturefactor, new Color4(1f, 1f, 1f, 1f));
|
||||
vb.Dispose();
|
||||
}
|
||||
|
||||
// This performs a single render pass
|
||||
|
@ -2013,8 +2013,8 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
graphics.SetAlphaTestEnable(false);
|
||||
graphics.SetSourceBlend(Blend.SourceAlpha);
|
||||
graphics.SetDestinationBlend(Blend.InverseSourceAlpha);
|
||||
graphics.SetTextureFactor(-1);
|
||||
worldmatrix = Matrix.Identity;
|
||||
graphics.SetUniform(UniformName.texturefactor, new Color4(1f, 1f, 1f, 1f));
|
||||
worldmatrix = Matrix.Identity;
|
||||
ApplyMatrices2D();
|
||||
|
||||
graphics.SetShader(ShaderName.display2d_normal);
|
||||
|
|
|
@ -469,7 +469,8 @@ static const int uniformLocations[(int)UniformName::NumUniforms] = {
|
|||
104, // lightColor
|
||||
109, // ignoreNormals
|
||||
110, // spotLight
|
||||
76, // campos
|
||||
76, // campos,
|
||||
112, // texturefactor
|
||||
};
|
||||
|
||||
void RenderDevice::SetUniform(UniformName name, const void* values, int count)
|
||||
|
@ -504,6 +505,8 @@ void RenderDevice::ApplyUniforms()
|
|||
glUniform1fv(locations[(int)UniformName::ignoreNormals], 1, &mUniforms[109].valuef);
|
||||
glUniform1fv(locations[(int)UniformName::spotLight], 1, &mUniforms[110].valuef);
|
||||
|
||||
glUniform4fv(locations[(int)UniformName::texturefactor], 1, &mUniforms[112].valuef);
|
||||
|
||||
for (int i = 0; i < Shader::MaxSamplers; i++)
|
||||
glUniform1i(shader->SamplerLocations[i], i);
|
||||
}
|
||||
|
|
|
@ -67,6 +67,7 @@ enum class UniformName : int
|
|||
ignoreNormals,
|
||||
spotLight,
|
||||
campos,
|
||||
texturefactor,
|
||||
NumUniforms
|
||||
};
|
||||
|
||||
|
@ -158,7 +159,7 @@ public:
|
|||
int32_t valuei;
|
||||
};
|
||||
|
||||
UniformEntry mUniforms[4 * 16 + 12 * 4];
|
||||
UniformEntry mUniforms[4 * 16 + 13 * 4];
|
||||
|
||||
GLuint mStreamVertexBuffer = 0;
|
||||
GLuint mStreamVAO = 0;
|
||||
|
|
|
@ -84,7 +84,8 @@ bool Shader::Compile(const std::string& vertexShader, const std::string& fragmen
|
|||
"lightColor",
|
||||
"ignoreNormals",
|
||||
"spotLight",
|
||||
"campos"
|
||||
"campos",
|
||||
"texturefactor"
|
||||
};
|
||||
|
||||
for (int i = 0; i < (int)UniformName::NumUniforms; i++)
|
||||
|
|
|
@ -33,6 +33,7 @@ static const char* display2D_ps_fsaa = R"(
|
|||
uniform float desaturation;
|
||||
|
||||
uniform sampler2D texture1;
|
||||
uniform vec4 texturefactor;
|
||||
|
||||
// This blends the max of 2 pixels
|
||||
vec4 addcolor(vec4 c1, vec4 c2)
|
||||
|
@ -71,6 +72,8 @@ static const char* display2D_ps_fsaa = R"(
|
|||
FragColor = vec4(desaturate(c.rgb), c.a * rendersettings.w) * Color;
|
||||
}
|
||||
|
||||
FragColor *= texturefactor;
|
||||
|
||||
#if defined(ALPHA_TEST)
|
||||
if (FragColor.a < 0.5) discard;
|
||||
#endif
|
||||
|
@ -92,6 +95,7 @@ const char* display2D_ps_normal = R"(
|
|||
uniform float desaturation;
|
||||
|
||||
uniform sampler2D texture1;
|
||||
uniform vec4 texturefactor;
|
||||
|
||||
vec3 desaturate(vec3 texel)
|
||||
{
|
||||
|
@ -103,6 +107,7 @@ const char* display2D_ps_normal = R"(
|
|||
{
|
||||
vec4 c = texture(texture1, UV);
|
||||
FragColor = vec4(desaturate(c.rgb), c.a * rendersettings.w) * Color;
|
||||
FragColor *= texturefactor;
|
||||
|
||||
#if defined(ALPHA_TEST)
|
||||
if (FragColor.a < 0.5) discard;
|
||||
|
@ -124,11 +129,13 @@ const char* display2D_ps_fullbright = R"(
|
|||
uniform vec4 rendersettings;
|
||||
|
||||
uniform sampler2D texture1;
|
||||
uniform vec4 texturefactor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 c = texture(texture1, UV);
|
||||
FragColor = vec4(c.rgb, c.a * rendersettings.w);
|
||||
FragColor *= texturefactor;
|
||||
|
||||
#if defined(ALPHA_TEST)
|
||||
if (FragColor.a < 0.5) discard;
|
||||
|
|
|
@ -30,6 +30,7 @@ static const char* things2D_ps_sprite = R"(
|
|||
uniform float desaturation;
|
||||
|
||||
uniform sampler2D texture1;
|
||||
uniform vec4 texturefactor;
|
||||
|
||||
vec3 desaturate(vec3 texel)
|
||||
{
|
||||
|
@ -54,6 +55,8 @@ static const char* things2D_ps_sprite = R"(
|
|||
FragColor = vec4(desaturate(c.rgb), c.a * rendersettings.w);
|
||||
}
|
||||
|
||||
FragColor *= texturefactor;
|
||||
|
||||
#if defined(ALPHA_TEST)
|
||||
if (FragColor.a < 0.5) discard;
|
||||
#endif
|
||||
|
@ -72,6 +75,7 @@ static const char* things2D_ps_thing = R"(
|
|||
uniform float desaturation;
|
||||
|
||||
uniform sampler2D texture1;
|
||||
uniform vec4 texturefactor;
|
||||
|
||||
vec3 desaturate(vec3 texel)
|
||||
{
|
||||
|
@ -84,6 +88,8 @@ static const char* things2D_ps_thing = R"(
|
|||
vec4 c = texture(texture1, UV);
|
||||
FragColor = vec4(desaturate(c.rgb), c.a * rendersettings.w) * Color;
|
||||
|
||||
FragColor *= texturefactor;
|
||||
|
||||
#if defined(ALPHA_TEST)
|
||||
if (FragColor.a < 0.5) discard;
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue