mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-22 12:11:25 +00:00
- added a flash component to the colormap shader.
Its main purpose is for RR's lightning flash in Raze but this looks very useful for manipulating fullscreen colormaps. Currently not exposed, though.
This commit is contained in:
parent
764605eaab
commit
b06af634e2
17 changed files with 46 additions and 38 deletions
|
@ -515,10 +515,10 @@ void OpenGLFrameBuffer::Draw2D()
|
|||
}
|
||||
}
|
||||
|
||||
void OpenGLFrameBuffer::PostProcessScene(bool swscene, int fixedcm, const std::function<void()> &afterBloomDrawEndScene2D)
|
||||
void OpenGLFrameBuffer::PostProcessScene(bool swscene, int fixedcm, float flash, const std::function<void()> &afterBloomDrawEndScene2D)
|
||||
{
|
||||
if (!swscene) GLRenderer->mBuffers->BlitSceneToTexture(); // Copy the resulting scene to the current post process texture
|
||||
GLRenderer->PostProcessScene(fixedcm, afterBloomDrawEndScene2D);
|
||||
GLRenderer->PostProcessScene(fixedcm, flash, afterBloomDrawEndScene2D);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
@ -61,7 +61,7 @@ public:
|
|||
void SetVSync(bool vsync);
|
||||
|
||||
void Draw2D() override;
|
||||
void PostProcessScene(bool swscene, int fixedcm, const std::function<void()> &afterBloomDrawEndScene2D) override;
|
||||
void PostProcessScene(bool swscene, int fixedcm, float flash, const std::function<void()> &afterBloomDrawEndScene2D) override;
|
||||
|
||||
bool HWGammaActive = false; // Are we using hardware or software gamma?
|
||||
std::shared_ptr<FGLDebug> mDebug; // Debug API
|
||||
|
|
|
@ -52,7 +52,7 @@ void FGLRenderer::RenderScreenQuad()
|
|||
glDrawArrays(GL_TRIANGLE_STRIP, FFlatVertexBuffer::PRESENT_INDEX, 4);
|
||||
}
|
||||
|
||||
void FGLRenderer::PostProcessScene(int fixedcm, const std::function<void()> &afterBloomDrawEndScene2D)
|
||||
void FGLRenderer::PostProcessScene(int fixedcm, float flash, const std::function<void()> &afterBloomDrawEndScene2D)
|
||||
{
|
||||
int sceneWidth = mBuffers->GetSceneWidth();
|
||||
int sceneHeight = mBuffers->GetSceneHeight();
|
||||
|
@ -62,7 +62,7 @@ void FGLRenderer::PostProcessScene(int fixedcm, const std::function<void()> &aft
|
|||
hw_postprocess.Pass1(&renderstate, fixedcm, sceneWidth, sceneHeight);
|
||||
mBuffers->BindCurrentFB();
|
||||
if (afterBloomDrawEndScene2D) afterBloomDrawEndScene2D();
|
||||
hw_postprocess.Pass2(&renderstate, fixedcm, sceneWidth, sceneHeight);
|
||||
hw_postprocess.Pass2(&renderstate, fixedcm, flash, sceneWidth, sceneHeight);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
|
@ -72,7 +72,7 @@ public:
|
|||
|
||||
void PresentStereo();
|
||||
void RenderScreenQuad();
|
||||
void PostProcessScene(int fixedcm, const std::function<void()> &afterBloomDrawEndScene2D);
|
||||
void PostProcessScene(int fixedcm, float flash, const std::function<void()> &afterBloomDrawEndScene2D);
|
||||
void AmbientOccludeScene(float m5);
|
||||
void ClearTonemapPalette();
|
||||
void BlurScene(float gameinfobluramount);
|
||||
|
|
|
@ -532,20 +532,26 @@ void PPCameraExposure::UpdateTextures(int width, int height)
|
|||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void PPColormap::Render(PPRenderState *renderstate, int fixedcm)
|
||||
void PPColormap::Render(PPRenderState *renderstate, int fixedcm, float flash)
|
||||
{
|
||||
ColormapUniforms uniforms;
|
||||
|
||||
if (fixedcm < CM_FIRSTSPECIALCOLORMAP || fixedcm >= CM_MAXCOLORMAP)
|
||||
{
|
||||
if (flash == 1.f)
|
||||
return;
|
||||
|
||||
uniforms.MapStart = { 0,0,0, flash };
|
||||
uniforms.MapRange = { 0,0,0, 1.f };
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
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;
|
||||
uniforms.MapStart = { scm->ColorizeStart[0], scm->ColorizeStart[1], scm->ColorizeStart[2], flash };
|
||||
uniforms.MapRange = { scm->ColorizeEnd[0] - scm->ColorizeStart[0],
|
||||
scm->ColorizeEnd[1] - scm->ColorizeStart[1], scm->ColorizeEnd[2] - scm->ColorizeStart[2], 0.f };
|
||||
}
|
||||
|
||||
renderstate->PushGroup("colormap");
|
||||
|
||||
|
@ -1117,10 +1123,10 @@ void Postprocess::Pass1(PPRenderState* state, int fixedcm, int sceneWidth, int s
|
|||
bloom.RenderBloom(state, sceneWidth, sceneHeight, fixedcm);
|
||||
}
|
||||
|
||||
void Postprocess::Pass2(PPRenderState* state, int fixedcm, int sceneWidth, int sceneHeight)
|
||||
void Postprocess::Pass2(PPRenderState* state, int fixedcm, float flash, int sceneWidth, int sceneHeight)
|
||||
{
|
||||
tonemap.Render(state);
|
||||
colormap.Render(state, fixedcm);
|
||||
colormap.Render(state, fixedcm, flash);
|
||||
lens.Render(state);
|
||||
fxaa.Render(state);
|
||||
customShaders.Run(state, "scene");
|
||||
|
|
|
@ -530,7 +530,7 @@ struct ColormapUniforms
|
|||
class PPColormap
|
||||
{
|
||||
public:
|
||||
void Render(PPRenderState *renderstate, int fixedcm);
|
||||
void Render(PPRenderState *renderstate, int fixedcm, float flash);
|
||||
|
||||
private:
|
||||
PPShader Colormap = { "shaders/pp/colormap.fp", "", ColormapUniforms::Desc() };
|
||||
|
@ -841,7 +841,7 @@ public:
|
|||
|
||||
|
||||
void Pass1(PPRenderState *state, int fixedcm, int sceneWidth, int sceneHeight);
|
||||
void Pass2(PPRenderState* state, int fixedcm, int sceneWidth, int sceneHeight);
|
||||
void Pass2(PPRenderState* state, int fixedcm, float flash, int sceneWidth, int sceneHeight);
|
||||
};
|
||||
|
||||
extern Postprocess hw_postprocess;
|
||||
|
|
|
@ -232,7 +232,7 @@ static uint8_t ToIntColorComponent(float v)
|
|||
return clamp((int)(v * 255.0f + 0.5f), 0, 255);
|
||||
}
|
||||
|
||||
void PolyFrameBuffer::PostProcessScene(bool swscene, int fixedcm, const std::function<void()> &afterBloomDrawEndScene2D)
|
||||
void PolyFrameBuffer::PostProcessScene(bool swscene, int fixedcm, float flash, const std::function<void()> &afterBloomDrawEndScene2D)
|
||||
{
|
||||
afterBloomDrawEndScene2D();
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ public:
|
|||
void SetTextureFilterMode() override;
|
||||
void BeginFrame() override;
|
||||
void BlurScene(float amount) override;
|
||||
void PostProcessScene(bool swscene, int fixedcm, const std::function<void()> &afterBloomDrawEndScene2D) override;
|
||||
void PostProcessScene(bool swscene, int fixedcm, float flash, const std::function<void()> &afterBloomDrawEndScene2D) override;
|
||||
void AmbientOccludeScene(float m5) override;
|
||||
//void SetSceneRenderTarget(bool useSSAO) override;
|
||||
|
||||
|
|
|
@ -242,7 +242,7 @@ public:
|
|||
virtual FTexture *WipeStartScreen();
|
||||
virtual FTexture *WipeEndScreen();
|
||||
|
||||
virtual void PostProcessScene(bool swscene, int fixedcm, const std::function<void()> &afterBloomDrawEndScene2D) { if (afterBloomDrawEndScene2D) afterBloomDrawEndScene2D(); }
|
||||
virtual void PostProcessScene(bool swscene, int fixedcm, float flash, const std::function<void()> &afterBloomDrawEndScene2D) { if (afterBloomDrawEndScene2D) afterBloomDrawEndScene2D(); }
|
||||
|
||||
void ScaleCoordsFromWindow(int16_t &x, int16_t &y);
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ void VkPostprocess::SetActiveRenderTarget()
|
|||
fb->GetRenderState()->SetRenderTarget(&buffers->PipelineImage[mCurrentPipelineImage], nullptr, buffers->GetWidth(), buffers->GetHeight(), VK_FORMAT_R16G16B16A16_SFLOAT, VK_SAMPLE_COUNT_1_BIT);
|
||||
}
|
||||
|
||||
void VkPostprocess::PostProcessScene(int fixedcm, const std::function<void()> &afterBloomDrawEndScene2D)
|
||||
void VkPostprocess::PostProcessScene(int fixedcm, float flash, const std::function<void()> &afterBloomDrawEndScene2D)
|
||||
{
|
||||
auto fb = GetVulkanFrameBuffer();
|
||||
int sceneWidth = fb->GetBuffers()->GetSceneWidth();
|
||||
|
@ -71,7 +71,7 @@ void VkPostprocess::PostProcessScene(int fixedcm, const std::function<void()> &a
|
|||
hw_postprocess.Pass1(&renderstate, fixedcm, sceneWidth, sceneHeight);
|
||||
SetActiveRenderTarget();
|
||||
afterBloomDrawEndScene2D();
|
||||
hw_postprocess.Pass2(&renderstate, fixedcm, sceneWidth, sceneHeight);
|
||||
hw_postprocess.Pass2(&renderstate, fixedcm, flash, sceneWidth, sceneHeight);
|
||||
}
|
||||
|
||||
void VkPostprocess::BlitSceneToPostprocess()
|
||||
|
|
|
@ -44,7 +44,7 @@ public:
|
|||
void RenderBuffersReset();
|
||||
|
||||
void SetActiveRenderTarget();
|
||||
void PostProcessScene(int fixedcm, const std::function<void()> &afterBloomDrawEndScene2D);
|
||||
void PostProcessScene(int fixedcm, float flash, const std::function<void()> &afterBloomDrawEndScene2D);
|
||||
|
||||
void AmbientOccludeScene(float m5);
|
||||
void BlurScene(float gameinfobluramount);
|
||||
|
|
|
@ -343,10 +343,10 @@ void VulkanFrameBuffer::RenderTextureView(FCanvasTexture* tex, std::function<voi
|
|||
tex->SetUpdated(true);
|
||||
}
|
||||
|
||||
void VulkanFrameBuffer::PostProcessScene(bool swscene, int fixedcm, const std::function<void()> &afterBloomDrawEndScene2D)
|
||||
void VulkanFrameBuffer::PostProcessScene(bool swscene, int fixedcm, float flash, const std::function<void()> &afterBloomDrawEndScene2D)
|
||||
{
|
||||
if (!swscene) mPostprocess->BlitSceneToPostprocess(); // Copy the resulting scene to the current post process texture
|
||||
mPostprocess->PostProcessScene(fixedcm, afterBloomDrawEndScene2D);
|
||||
mPostprocess->PostProcessScene(fixedcm, flash, afterBloomDrawEndScene2D);
|
||||
}
|
||||
|
||||
const char* VulkanFrameBuffer::DeviceName() const
|
||||
|
|
|
@ -80,7 +80,7 @@ public:
|
|||
void StartPrecaching() override;
|
||||
void BeginFrame() override;
|
||||
void BlurScene(float amount) override;
|
||||
void PostProcessScene(bool swscene, int fixedcm, const std::function<void()> &afterBloomDrawEndScene2D) override;
|
||||
void PostProcessScene(bool swscene, int fixedcm, float flash, const std::function<void()> &afterBloomDrawEndScene2D) override;
|
||||
void AmbientOccludeScene(float m5) override;
|
||||
void SetSceneRenderTarget(bool useSSAO) override;
|
||||
void UpdateShadowMap() override;
|
||||
|
|
|
@ -45,15 +45,11 @@ inline uint32_t MakeSpecialColormap(int index)
|
|||
|
||||
enum EColorManipulation
|
||||
{
|
||||
CM_PLAIN2D = -2, // regular 2D drawing.
|
||||
CM_INVALID = -1,
|
||||
CM_DEFAULT = 0, // untranslated
|
||||
CM_FIRSTSPECIALCOLORMAP, // first special fixed colormap
|
||||
CM_FIRSTSPECIALCOLORMAPFORCED = 0x08000000, // first special fixed colormap, application forced (for 2D overlays)
|
||||
};
|
||||
|
||||
#define CM_MAXCOLORMAP int(CM_FIRSTSPECIALCOLORMAP + SpecialColormaps.Size())
|
||||
#define CM_MAXCOLORMAPFORCED int(CM_FIRSTSPECIALCOLORMAPFORCED + SpecialColormaps.Size())
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -144,6 +144,7 @@ sector_t* RenderViewpoint(FRenderViewpoint& mainvp, AActor* camera, IntRect* bou
|
|||
di->Set3DViewport(RenderState);
|
||||
di->SetViewArea();
|
||||
auto cm = di->SetFullbrightFlags(mainview ? vp.camera->player : nullptr);
|
||||
float flash = 1.f;
|
||||
di->Viewpoint.FieldOfView = fov; // Set the real FOV for the current scene (it's not necessarily the same as the global setting in r_viewpoint)
|
||||
|
||||
// Stereo mode specific perspective projection
|
||||
|
@ -165,7 +166,7 @@ sector_t* RenderViewpoint(FRenderViewpoint& mainvp, AActor* camera, IntRect* bou
|
|||
RenderState.EnableDrawBuffers(1);
|
||||
}
|
||||
|
||||
screen->PostProcessScene(false, cm, [&]() { di->DrawEndScene2D(mainvp.sector, RenderState); });
|
||||
screen->PostProcessScene(false, cm, flash, [&]() { di->DrawEndScene2D(mainvp.sector, RenderState); });
|
||||
PostProcess.Unclock();
|
||||
}
|
||||
di->EndDrawInfo();
|
||||
|
|
|
@ -124,7 +124,7 @@ sector_t *SWSceneDrawer::RenderView(player_t *player)
|
|||
DrawTexture(twod, fbtex.get(), 0, 0, DTA_SpecialColormap, map, TAG_DONE);
|
||||
screen->Draw2D();
|
||||
twod->Clear();
|
||||
screen->PostProcessScene(true, CM_DEFAULT, [&]() {
|
||||
screen->PostProcessScene(true, CM_DEFAULT, 1.f, [&]() {
|
||||
SWRenderer->DrawRemainingPlayerSprites();
|
||||
screen->Draw2D();
|
||||
twod->Clear();
|
||||
|
@ -140,7 +140,7 @@ sector_t *SWSceneDrawer::RenderView(player_t *player)
|
|||
int cm = CM_DEFAULT;
|
||||
auto map = swrenderer::CameraLight::Instance()->ShaderColormap();
|
||||
if (map) cm = (int)(ptrdiff_t)(map - SpecialColormaps.Data()) + CM_FIRSTSPECIALCOLORMAP;
|
||||
screen->PostProcessScene(true, cm, [&]() { });
|
||||
screen->PostProcessScene(true, cm, 1.f, [&]() { });
|
||||
|
||||
SWRenderer->DrawRemainingPlayerSprites();
|
||||
screen->Draw2D();
|
||||
|
|
|
@ -6,8 +6,13 @@ layout(binding=0) uniform sampler2D SceneTexture;
|
|||
void main()
|
||||
{
|
||||
vec4 frag = texture(SceneTexture, TexCoord);
|
||||
frag.rgb = clamp(pow(frag.rgb, vec3(uFixedColormapStart.a)), 0.0, 1.0);
|
||||
if (uFixedColormapRange.a == 0)
|
||||
{
|
||||
float gray = (frag.r * 0.3 + frag.g * 0.56 + frag.b * 0.14);
|
||||
vec4 cm = uFixedColormapStart + gray * uFixedColormapRange;
|
||||
FragColor = vec4(clamp(cm.rgb, 0.0, 1.0), frag.a);
|
||||
frag.rgb = clamp(cm.rgb, 0.0, 1.0);
|
||||
}
|
||||
FragColor = frag;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue