mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-27 14:22:13 +00:00
- convert colormap shader to postprocess steps
This commit is contained in:
parent
83f50f5808
commit
ebf0cef283
8 changed files with 64 additions and 127 deletions
|
@ -1068,7 +1068,6 @@ set (PCH_SOURCES
|
|||
hwrenderer/postprocessing/hw_presentshader.cpp
|
||||
hwrenderer/postprocessing/hw_present3dRowshader.cpp
|
||||
hwrenderer/postprocessing/hw_ambientshader.cpp
|
||||
hwrenderer/postprocessing/hw_colormapshader.cpp
|
||||
hwrenderer/postprocessing/hw_tonemapshader.cpp
|
||||
hwrenderer/textures/hw_material.cpp
|
||||
hwrenderer/textures/hw_precache.cpp
|
||||
|
|
|
@ -41,7 +41,6 @@
|
|||
#include "gl/data/gl_vertexbuffer.h"
|
||||
#include "hwrenderer/postprocessing/hw_ambientshader.h"
|
||||
#include "hwrenderer/postprocessing/hw_tonemapshader.h"
|
||||
#include "hwrenderer/postprocessing/hw_colormapshader.h"
|
||||
#include "hwrenderer/postprocessing/hw_presentshader.h"
|
||||
#include "hwrenderer/postprocessing/hw_postprocess.h"
|
||||
#include "hwrenderer/postprocessing/hw_postprocess_cvars.h"
|
||||
|
@ -451,45 +450,14 @@ void FGLRenderer::ClearTonemapPalette()
|
|||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Colormap scene texture and place the result in the HUD/2D texture
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void FGLRenderer::ColormapScene(int fixedcm)
|
||||
{
|
||||
if (fixedcm < CM_FIRSTSPECIALCOLORMAP || fixedcm >= CM_MAXCOLORMAP)
|
||||
return;
|
||||
|
||||
FGLDebug::PushGroup("ColormapScene");
|
||||
|
||||
FGLPostProcessState savedState;
|
||||
|
||||
mBuffers->BindNextFB();
|
||||
mBuffers->BindCurrentTexture(0);
|
||||
mColormapShader->Bind(NOQUEUE);
|
||||
|
||||
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 };
|
||||
|
||||
mColormapShader->Uniforms->MapStart = { scm->ColorizeStart[0], scm->ColorizeStart[1], scm->ColorizeStart[2], 0.f };
|
||||
mColormapShader->Uniforms->MapRange = m;
|
||||
mColormapShader->Uniforms.Set();
|
||||
|
||||
RenderScreenQuad();
|
||||
mBuffers->NextTexture();
|
||||
|
||||
FGLDebug::PopGroup();
|
||||
PPColormap colormap;
|
||||
colormap.DeclareShaders();
|
||||
colormap.UpdateSteps(fixedcm);
|
||||
mBuffers->RenderEffect("ColormapScene");
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Apply lens distortion and place the result in the HUD/2D texture
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void FGLRenderer::LensDistortScene()
|
||||
{
|
||||
PPLensDistort lens;
|
||||
|
@ -498,12 +466,6 @@ void FGLRenderer::LensDistortScene()
|
|||
mBuffers->RenderEffect("LensDistortScene");
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Apply FXAA and place the result in the HUD/2D texture
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void FGLRenderer::ApplyFXAA()
|
||||
{
|
||||
PPFXAA fxaa;
|
||||
|
|
|
@ -52,7 +52,6 @@
|
|||
#include "gl/scene/gl_scenedrawer.h"
|
||||
#include "hwrenderer/postprocessing/hw_ambientshader.h"
|
||||
#include "hwrenderer/postprocessing/hw_tonemapshader.h"
|
||||
#include "hwrenderer/postprocessing/hw_colormapshader.h"
|
||||
#include "hwrenderer/postprocessing/hw_presentshader.h"
|
||||
#include "hwrenderer/postprocessing/hw_present3dRowshader.h"
|
||||
#include "hwrenderer/postprocessing/hw_shadowmapshader.h"
|
||||
|
@ -101,7 +100,6 @@ FGLRenderer::FGLRenderer(OpenGLFrameBuffer *fb)
|
|||
mPresent3dRowShader = nullptr;
|
||||
mTonemapShader = nullptr;
|
||||
mTonemapPalette = nullptr;
|
||||
mColormapShader = nullptr;
|
||||
mLinearDepthShader = nullptr;
|
||||
mDepthBlurShader = nullptr;
|
||||
mSSAOShader = nullptr;
|
||||
|
@ -120,7 +118,6 @@ void FGLRenderer::Initialize(int width, int height)
|
|||
mSSAOShader = new FSSAOShader();
|
||||
mSSAOCombineShader = new FSSAOCombineShader();
|
||||
mTonemapShader = new FTonemapShader();
|
||||
mColormapShader = new FColormapShader();
|
||||
mTonemapPalette = nullptr;
|
||||
mPresentShader = new FPresentShader();
|
||||
mPresent3dCheckerShader = new FPresent3DCheckerShader();
|
||||
|
@ -178,7 +175,6 @@ FGLRenderer::~FGLRenderer()
|
|||
if (mPresent3dRowShader) delete mPresent3dRowShader;
|
||||
if (mTonemapShader) delete mTonemapShader;
|
||||
if (mTonemapPalette) delete mTonemapPalette;
|
||||
if (mColormapShader) delete mColormapShader;
|
||||
if (mShadowMapShader) delete mShadowMapShader;
|
||||
delete mCustomPostProcessShaders;
|
||||
}
|
||||
|
|
|
@ -30,7 +30,6 @@ class FDepthBlurShader;
|
|||
class FSSAOShader;
|
||||
class FSSAOCombineShader;
|
||||
class FTonemapShader;
|
||||
class FColormapShader;
|
||||
class FPresentShader;
|
||||
class FPresent3DCheckerShader;
|
||||
class FPresent3DColumnShader;
|
||||
|
@ -76,7 +75,6 @@ public:
|
|||
FDepthBlurShader *mDepthBlurShader;
|
||||
FSSAOCombineShader *mSSAOCombineShader;
|
||||
FTonemapShader *mTonemapShader;
|
||||
FColormapShader *mColormapShader;
|
||||
FHardwareTexture *mTonemapPalette;
|
||||
FPresentShader *mPresentShader;
|
||||
FPresent3DCheckerShader *mPresent3dCheckerShader;
|
||||
|
|
|
@ -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…
Reference in a new issue