- move shadowmap uniforms out of FShadowMapShader

This commit is contained in:
Magnus Norddahl 2019-03-08 17:45:07 +01:00
parent 965acde9c0
commit ca570f1e78
3 changed files with 20 additions and 19 deletions

View file

@ -639,3 +639,20 @@ public:
void UpdateTextures() override;
void UpdateSteps() override;
};
struct ShadowMapUniforms
{
float ShadowmapQuality;
float Padding0, Padding1, Padding2;
static std::vector<UniformFieldDesc> Desc()
{
return
{
{ "ShadowmapQuality", UniformType::Float, offsetof(ShadowMapUniforms, ShadowmapQuality) },
{ "Padding0", UniformType::Float, offsetof(ShadowMapUniforms, Padding0) },
{ "Padding1", UniformType::Float, offsetof(ShadowMapUniforms, Padding1) },
{ "Padding2", UniformType::Float, offsetof(ShadowMapUniforms, Padding2) },
};
}
};

View file

@ -27,7 +27,7 @@ void FShadowMapShader::Bind(IRenderQueue *q)
{
if (!mShader)
{
FString prolog = Uniforms.CreateDeclaration("Uniforms", UniformBlock::Desc());
FString prolog = Uniforms.CreateDeclaration("Uniforms", ShadowMapUniforms::Desc());
mShader.reset(screen->CreateShaderProgram());
mShader->Compile(IShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 430);

View file

@ -2,30 +2,14 @@
#define __GL_SHADOWMAPSHADER_H
#include "hwrenderer/postprocessing/hw_shaderprogram.h"
#include "hwrenderer/postprocessing/hw_postprocess.h"
class FShadowMapShader
{
public:
void Bind(IRenderQueue *q);
struct UniformBlock
{
float ShadowmapQuality;
float Padding0, Padding1, Padding2;
static std::vector<UniformFieldDesc> Desc()
{
return
{
{ "ShadowmapQuality", UniformType::Float, offsetof(UniformBlock, ShadowmapQuality) },
{ "Padding0", UniformType::Float, offsetof(UniformBlock, Padding0) },
{ "Padding1", UniformType::Float, offsetof(UniformBlock, Padding1) },
{ "Padding2", UniformType::Float, offsetof(UniformBlock, Padding2) },
};
}
};
ShaderUniforms<UniformBlock, POSTPROCESS_BINDINGPOINT> Uniforms;
ShaderUniforms<ShadowMapUniforms, POSTPROCESS_BINDINGPOINT> Uniforms;
private:
std::unique_ptr<IShaderProgram> mShader;