mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-22 12:11:25 +00:00
- Uniform buffer for colormap shader
This commit is contained in:
parent
d22fb24e28
commit
2bde741a7e
4 changed files with 24 additions and 9 deletions
|
@ -529,8 +529,9 @@ void FGLRenderer::ColormapScene(int fixedcm)
|
|||
float m[] = { scm->ColorizeEnd[0] - scm->ColorizeStart[0],
|
||||
scm->ColorizeEnd[1] - scm->ColorizeStart[1], scm->ColorizeEnd[2] - scm->ColorizeStart[2], 0.f };
|
||||
|
||||
mColormapShader->MapStart.Set(scm->ColorizeStart[0], scm->ColorizeStart[1], scm->ColorizeStart[2], 0.f);
|
||||
mColormapShader->MapRange.Set(m);
|
||||
mColormapShader->Uniforms->MapStart = { scm->ColorizeStart[0], scm->ColorizeStart[1], scm->ColorizeStart[2], 0.f };
|
||||
mColormapShader->Uniforms->MapRange = m;
|
||||
mColormapShader->Uniforms.Set();
|
||||
|
||||
RenderScreenQuad();
|
||||
mBuffers->NextTexture();
|
||||
|
|
|
@ -34,13 +34,14 @@ void FColormapShader::Bind()
|
|||
auto &shader = mShader;
|
||||
if (!shader)
|
||||
{
|
||||
FString prolog = Uniforms.CreateDeclaration("Uniforms", UniformBlock::Desc());
|
||||
|
||||
shader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330);
|
||||
shader.Compile(FShaderProgram::Fragment, "shaders/glsl/colormap.fp", "", 330);
|
||||
shader.Compile(FShaderProgram::Fragment, "shaders/glsl/colormap.fp", prolog, 330);
|
||||
shader.SetFragDataLocation(0, "FragColor");
|
||||
shader.Link("shaders/glsl/colormap");
|
||||
shader.SetAttribLocation(0, "PositionInProjection");
|
||||
MapStart.Init(shader, "uFixedColormapStart");
|
||||
MapRange.Init(shader, "uFixedColormapRange");
|
||||
Uniforms.Init(shader);
|
||||
}
|
||||
shader.Bind();
|
||||
}
|
||||
|
|
|
@ -9,8 +9,23 @@ public:
|
|||
void Bind();
|
||||
|
||||
FBufferedUniformSampler SceneTexture;
|
||||
FUniform4f MapStart;
|
||||
FUniform4f MapRange;
|
||||
|
||||
struct UniformBlock
|
||||
{
|
||||
FVector4 MapStart;
|
||||
FVector4 MapRange;
|
||||
|
||||
static std::vector<UniformFieldDesc> Desc()
|
||||
{
|
||||
return
|
||||
{
|
||||
{ "uFixedColormapStart", UniformType::Vec4, offsetof(UniformBlock, MapStart) },
|
||||
{ "uFixedColormapRange", UniformType::Vec4, offsetof(UniformBlock, MapRange) },
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
ShaderUniforms<UniformBlock> Uniforms;
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -3,8 +3,6 @@ in vec2 TexCoord;
|
|||
out vec4 FragColor;
|
||||
|
||||
uniform sampler2D tex;
|
||||
uniform vec4 uFixedColormapStart;
|
||||
uniform vec4 uFixedColormapRange;
|
||||
|
||||
void main()
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue