Add FBufferedUniformSampler because sampler uniforms may default bind to other locations than zero

This commit is contained in:
Magnus Norddahl 2016-08-26 01:46:39 +02:00
parent b68bbaf617
commit 5f09d3b7ef
5 changed files with 28 additions and 6 deletions

View file

@ -8,7 +8,7 @@ class FBloomExtractShader
public:
void Bind();
FBufferedUniform1i SceneTexture;
FBufferedUniformSampler SceneTexture;
FBufferedUniform1f Exposure;
FBufferedUniform2f Scale;
FBufferedUniform2f Offset;
@ -22,7 +22,7 @@ class FBloomCombineShader
public:
void Bind();
FBufferedUniform1i BloomTexture;
FBufferedUniformSampler BloomTexture;
private:
FShaderProgram mShader;

View file

@ -8,7 +8,7 @@ class FLensShader
public:
void Bind();
FBufferedUniform1i InputTexture;
FBufferedUniformSampler InputTexture;
FBufferedUniform1f AspectRatio;
FBufferedUniform1f Scale;
FBufferedUniform4f LensDistortionCoefficient;

View file

@ -8,7 +8,7 @@ class FPresentShader
public:
void Bind();
FBufferedUniform1i InputTexture;
FBufferedUniformSampler InputTexture;
FBufferedUniform1f InvGamma;
FBufferedUniform1f Contrast;
FBufferedUniform1f Brightness;

View file

@ -201,6 +201,28 @@ public:
}
};
class FBufferedUniformSampler
{
int mBuffer;
int mIndex;
public:
void Init(GLuint hShader, const GLchar *name)
{
mIndex = glGetUniformLocation(hShader, name);
mBuffer = -1;
}
void Set(int newvalue)
{
if (newvalue != mBuffer)
{
mBuffer = newvalue;
glUniform1i(mIndex, newvalue);
}
}
};
class FShader
{

View file

@ -8,9 +8,9 @@ class FTonemapShader
public:
void Bind();
FBufferedUniform1i SceneTexture;
FBufferedUniformSampler SceneTexture;
FBufferedUniform1f Exposure;
FBufferedUniform1i PaletteLUT;
FBufferedUniformSampler PaletteLUT;
static bool IsPaletteMode();