- convert colormap shader to postprocess steps
This commit is contained in:
parent
83f50f5808
commit
ebf0cef283
8 changed files with 64 additions and 127 deletions
|
|
@ -1,45 +0,0 @@
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright(C) 2016 Christoph Oelckers
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this program. If not, see http://www.gnu.org/licenses/
|
||||
//
|
||||
//--------------------------------------------------------------------------
|
||||
//
|
||||
/*
|
||||
** gl_colormapshader.cpp
|
||||
** Applies a fullscreen colormap to the scene
|
||||
**
|
||||
*/
|
||||
|
||||
#include "v_video.h"
|
||||
#include "hw_colormapshader.h"
|
||||
|
||||
void FColormapShader::Bind(IRenderQueue *q)
|
||||
{
|
||||
if (!mShader)
|
||||
{
|
||||
FString prolog = Uniforms.CreateDeclaration("Uniforms", UniformBlock::Desc());
|
||||
mShader.reset(screen->CreateShaderProgram());
|
||||
mShader->Compile(IShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330);
|
||||
mShader->Compile(IShaderProgram::Fragment, "shaders/glsl/colormap.fp", prolog, 330);
|
||||
mShader->Link("shaders/glsl/colormap");
|
||||
mShader->SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms");
|
||||
Uniforms.Init();
|
||||
}
|
||||
mShader->Bind(q);
|
||||
}
|
||||
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
#ifndef __GL_COLORMAPSHADER_H
|
||||
#define __GL_COLORMAPSHADER_H
|
||||
|
||||
#include "hwrenderer/postprocessing/hw_shaderprogram.h"
|
||||
|
||||
class FColormapShader
|
||||
{
|
||||
public:
|
||||
void Bind(IRenderQueue *q);
|
||||
|
||||
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, POSTPROCESS_BINDINGPOINT> Uniforms;
|
||||
|
||||
private:
|
||||
|
||||
std::unique_ptr<IShaderProgram> mShader;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -478,3 +478,39 @@ void PPCameraExposure::UpdateSteps()
|
|||
|
||||
hw_postprocess.Effects["UpdateCameraExposure"] = steps;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void PPColormap::DeclareShaders()
|
||||
{
|
||||
hw_postprocess.Shaders["Colormap"] = { "shaders/glsl/colormap.fp", "", ColormapUniforms::Desc() };
|
||||
}
|
||||
|
||||
void PPColormap::UpdateSteps(int fixedcm)
|
||||
{
|
||||
if (fixedcm < CM_FIRSTSPECIALCOLORMAP || fixedcm >= CM_MAXCOLORMAP)
|
||||
{
|
||||
hw_postprocess.Effects["ColormapScene"] = {};
|
||||
return;
|
||||
}
|
||||
|
||||
FSpecialColormap *scm = &SpecialColormaps[fixedcm - CM_FIRSTSPECIALCOLORMAP];
|
||||
float m[] = { scm->ColorizeEnd[0] - scm->ColorizeStart[0],
|
||||
scm->ColorizeEnd[1] - scm->ColorizeStart[1], scm->ColorizeEnd[2] - scm->ColorizeStart[2], 0.f };
|
||||
|
||||
ColormapUniforms uniforms;
|
||||
uniforms.MapStart = { scm->ColorizeStart[0], scm->ColorizeStart[1], scm->ColorizeStart[2], 0.f };
|
||||
uniforms.MapRange = m;
|
||||
|
||||
PPStep step;
|
||||
step.ShaderName = "Colormap";
|
||||
step.Uniforms.Set(uniforms);
|
||||
step.Viewport = screen->mScreenViewport;
|
||||
step.SetInputCurrent(0);
|
||||
step.SetOutputNext();
|
||||
step.SetNoBlend();
|
||||
|
||||
TArray<PPStep> steps;
|
||||
steps.Push(step);
|
||||
hw_postprocess.Effects["ColormapScene"] = steps;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -387,3 +387,27 @@ private:
|
|||
TArray<PPExposureLevel> ExposureLevels;
|
||||
bool FirstExposureFrame = true;
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct ColormapUniforms
|
||||
{
|
||||
FVector4 MapStart;
|
||||
FVector4 MapRange;
|
||||
|
||||
static std::vector<UniformFieldDesc> Desc()
|
||||
{
|
||||
return
|
||||
{
|
||||
{ "uFixedColormapStart", UniformType::Vec4, offsetof(ColormapUniforms, MapStart) },
|
||||
{ "uFixedColormapRange", UniformType::Vec4, offsetof(ColormapUniforms, MapRange) },
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
class PPColormap
|
||||
{
|
||||
public:
|
||||
void DeclareShaders();
|
||||
void UpdateSteps(int fixedcm);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue