mirror of
https://bitbucket.org/CPMADevs/cnq3
synced 2024-11-21 19:41:10 +00:00
draw Dear ImGUI after tone mapping
This commit is contained in:
parent
8063962ed6
commit
ca3d15282b
16 changed files with 284 additions and 108 deletions
|
@ -471,6 +471,19 @@ static void ImGUI_ApplyTheme()
|
|||
colors[ImGuiCol_SeparatorHovered] = hover;
|
||||
colors[ImGuiCol_SeparatorActive] = hover;
|
||||
|
||||
const float brightness = 2.0f;
|
||||
const float gamma = 1.3f;
|
||||
for(int i = 0; i < ImGuiCol_COUNT; i++)
|
||||
{
|
||||
colors[i].x = min(powf(colors[i].x * brightness, gamma), 1.0f);
|
||||
colors[i].y = min(powf(colors[i].y * brightness, gamma), 1.0f);
|
||||
colors[i].z = min(powf(colors[i].z * brightness, gamma), 1.0f);
|
||||
Q_assert(colors[i].x >= 0.0f && colors[i].x <= 1.0f);
|
||||
Q_assert(colors[i].y >= 0.0f && colors[i].y <= 1.0f);
|
||||
Q_assert(colors[i].z >= 0.0f && colors[i].z <= 1.0f);
|
||||
Q_assert(colors[i].w >= 0.0f && colors[i].w <= 1.0f);
|
||||
}
|
||||
|
||||
ImGuiStyle& style = ImGui::GetStyle();
|
||||
style.WindowPadding = ImVec2(8.00f, 8.00f);
|
||||
style.FramePadding = ImVec2(5.00f, 2.00f);
|
||||
|
|
|
@ -687,8 +687,8 @@ void CRP::EndFrame()
|
|||
volumetricLight.DrawGUI();
|
||||
vdbManager.DrawGUI();
|
||||
im3d.DrawGUI();
|
||||
imgui.Draw(renderTarget);
|
||||
toneMap.DrawToneMap();
|
||||
imgui.Draw(renderTarget);
|
||||
magnifier.Draw();
|
||||
BlitRenderTarget(GetSwapChainTexture(), "Blit to Swap Chain");
|
||||
BlitRenderTarget(readbackRenderTarget, "Blit to Readback Texture");
|
||||
|
|
147
code/renderer/grp_blit.cpp
Normal file
147
code/renderer/grp_blit.cpp
Normal file
|
@ -0,0 +1,147 @@
|
|||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 2024 Gian 'myT' Schellenbaum
|
||||
|
||||
This file is part of Challenge Quake 3 (CNQ3).
|
||||
|
||||
Challenge Quake 3 is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
Challenge Quake 3 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Challenge Quake 3. If not, see <https://www.gnu.org/licenses/>.
|
||||
===========================================================================
|
||||
*/
|
||||
// Gameplay Rendering Pipeline - blitting
|
||||
|
||||
|
||||
#include "grp_local.h"
|
||||
#include "compshaders/grp/blit.h"
|
||||
|
||||
|
||||
#pragma pack(push, 4)
|
||||
|
||||
struct BlitVertexRC
|
||||
{
|
||||
float scaleX;
|
||||
float scaleY;
|
||||
};
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
|
||||
void Blitter::Init()
|
||||
{
|
||||
if(!srp.firstInit)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
RootSignatureDesc desc("blitter");
|
||||
desc.usingVertexBuffers = false;
|
||||
desc.constants[ShaderStage::Vertex].byteCount = sizeof(BlitVertexRC);
|
||||
desc.samplerCount = 1;
|
||||
desc.samplerVisibility = ShaderStages::PixelBit;
|
||||
desc.AddRange(DescriptorType::Texture, 0, 1);
|
||||
desc.genericVisibility = ShaderStages::PixelBit;
|
||||
rootSignature = CreateRootSignature(desc);
|
||||
}
|
||||
{
|
||||
DescriptorTableDesc desc("blitter", rootSignature);
|
||||
descriptorTable = CreateDescriptorTable(desc);
|
||||
|
||||
DescriptorTableUpdate update;
|
||||
update.SetSamplers(1, &grp.samplers[GetSamplerIndex(TW_CLAMP_TO_EDGE, TextureFilter::Linear)]);
|
||||
UpdateDescriptorTable(descriptorTable, update);
|
||||
}
|
||||
{
|
||||
GraphicsPipelineDesc desc("blitter", rootSignature);
|
||||
desc.vertexShader = ShaderByteCode(g_blit_vs);
|
||||
desc.pixelShader = ShaderByteCode(g_blit_ps);
|
||||
desc.depthStencil.DisableDepth();
|
||||
desc.rasterizer.cullMode = CT_TWO_SIDED;
|
||||
desc.AddRenderTarget(0, TextureFormat::R8G8B8A8_UNorm);
|
||||
pipeline = CreateGraphicsPipeline(desc);
|
||||
}
|
||||
}
|
||||
|
||||
void Blitter::Blit(HTexture renderTarget)
|
||||
{
|
||||
SCOPED_RENDER_PASS("Blit to Swap Chain", 0.125f, 0.125f, 0.5f);
|
||||
|
||||
CmdBeginBarrier();
|
||||
CmdTextureBarrier(grp.renderTarget, ResourceStates::PixelShaderAccessBit);
|
||||
CmdTextureBarrier(renderTarget, ResourceStates::RenderTargetBit);
|
||||
CmdEndBarrier();
|
||||
|
||||
float vsX = 1.0f; // vertex shader scale factors
|
||||
float vsY = 1.0f;
|
||||
float srX = 1.0f; // scissor rectangle scale factors
|
||||
float srY = 1.0f;
|
||||
if(r_fullscreen->integer == 1 && r_mode->integer == VIDEOMODE_UPSCALE)
|
||||
{
|
||||
if(r_blitMode->integer == BLITMODE_CENTERED)
|
||||
{
|
||||
vsX = (float)glConfig.vidWidth / (float)glInfo.winWidth;
|
||||
vsY = (float)glConfig.vidHeight / (float)glInfo.winHeight;
|
||||
}
|
||||
else if(r_blitMode->integer == BLITMODE_ASPECT)
|
||||
{
|
||||
const float ars = (float)glConfig.vidWidth / (float)glConfig.vidHeight;
|
||||
const float ard = (float)glInfo.winWidth / (float)glInfo.winHeight;
|
||||
if(ard > ars)
|
||||
{
|
||||
vsX = ars / ard;
|
||||
vsY = 1.0f;
|
||||
srX = (float)glInfo.winHeight / (float)glConfig.vidHeight;
|
||||
srY = srX;
|
||||
}
|
||||
else
|
||||
{
|
||||
vsX = 1.0f;
|
||||
vsY = ard / ars;
|
||||
srX = (float)glInfo.winWidth / (float)glConfig.vidWidth;
|
||||
srY = srX;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(vsX != 1.0f || vsY != 1.0f)
|
||||
{
|
||||
CmdClearColorTarget(renderTarget, colorBlack);
|
||||
|
||||
const int x = (glInfo.winWidth - glInfo.winWidth * vsX) / 2.0f;
|
||||
const int y = (glInfo.winHeight - glInfo.winHeight * vsY) / 2.0f;
|
||||
CmdSetViewport(0, 0, glInfo.winWidth, glInfo.winHeight);
|
||||
CmdSetScissor(x, y, glConfig.vidWidth * srX, glConfig.vidHeight * srY);
|
||||
}
|
||||
else
|
||||
{
|
||||
CmdSetViewportAndScissor(0, 0, glInfo.winWidth, glInfo.winHeight);
|
||||
}
|
||||
|
||||
BlitVertexRC vertexRC = {};
|
||||
vertexRC.scaleX = vsX;
|
||||
vertexRC.scaleY = vsY;
|
||||
|
||||
CmdBindRenderTargets(1, &renderTarget, NULL);
|
||||
CmdBindPipeline(pipeline);
|
||||
CmdBindRootSignature(rootSignature);
|
||||
CmdBindDescriptorTable(rootSignature, descriptorTable);
|
||||
CmdSetRootConstants(rootSignature, ShaderStage::Vertex, &vertexRC);
|
||||
CmdDraw(3, 0);
|
||||
}
|
||||
|
||||
void Blitter::SetInputTexture(HTexture source)
|
||||
{
|
||||
DescriptorTableUpdate update;
|
||||
update.SetTextures(1, &source);
|
||||
UpdateDescriptorTable(descriptorTable, update);
|
||||
}
|
|
@ -256,6 +256,18 @@ private:
|
|||
HDescriptorTable inverseToneMapDescriptorTable;
|
||||
};
|
||||
|
||||
struct Blitter
|
||||
{
|
||||
void Init();
|
||||
void SetInputTexture(HTexture source);
|
||||
void Blit(HTexture renderTarget);
|
||||
|
||||
private:
|
||||
HPipeline pipeline;
|
||||
HRootSignature rootSignature;
|
||||
HDescriptorTable descriptorTable;
|
||||
};
|
||||
|
||||
struct SMAA
|
||||
{
|
||||
void Init();
|
||||
|
@ -333,8 +345,6 @@ struct GRP : IRenderPipeline
|
|||
|
||||
uint32_t CreatePSO(CachedPSO& cache, const char* name);
|
||||
|
||||
void UpdateReadbackTexture();
|
||||
|
||||
UI ui;
|
||||
World world;
|
||||
MipMapGenerator mipMapGen;
|
||||
|
@ -343,8 +353,8 @@ struct GRP : IRenderPipeline
|
|||
PostProcess post;
|
||||
SMAA smaa;
|
||||
Nuklear nuklear;
|
||||
Blitter blitter;
|
||||
float frameSeed;
|
||||
bool updateReadbackTexture;
|
||||
|
||||
HTexture renderTarget;
|
||||
TextureFormat::Id renderTargetFormat;
|
||||
|
|
|
@ -216,7 +216,7 @@ void GRP::Init()
|
|||
ui.Init(false, ShaderByteCode(g_ui_vs), ShaderByteCode(g_ui_ps), renderTargetFormat, descriptorTable, &rootSignatureDesc);
|
||||
world.Init();
|
||||
mipMapGen.Init(false, ShaderByteCode(g_mip_1_cs), ShaderByteCode(g_mip_2_cs), ShaderByteCode(g_mip_3_cs));
|
||||
const HTexture fontAtlas = imgui.Init(false, ShaderByteCode(g_imgui_vs), ShaderByteCode(g_imgui_ps), renderTargetFormat, descriptorTable, &rootSignatureDesc);
|
||||
const HTexture fontAtlas = imgui.Init(false, ShaderByteCode(g_imgui_vs), ShaderByteCode(g_imgui_ps), TextureFormat::R8G8B8A8_UNorm, descriptorTable, &rootSignatureDesc);
|
||||
const uint32_t fontAtlasSRV = RegisterTexture(fontAtlas);
|
||||
imgui.RegisterFontAtlas(fontAtlasSRV);
|
||||
im3d.Init(false, im3dShaders, renderTargetFormat);
|
||||
|
@ -224,6 +224,8 @@ void GRP::Init()
|
|||
post.Init();
|
||||
post.SetToneMapInput(renderTarget);
|
||||
smaa.Init(); // must be after post
|
||||
blitter.Init();
|
||||
blitter.SetInputTexture(readbackRenderTarget);
|
||||
|
||||
srp.firstInit = false;
|
||||
}
|
||||
|
@ -266,25 +268,19 @@ void GRP::BeginFrame()
|
|||
|
||||
void GRP::EndFrame()
|
||||
{
|
||||
// issue ImGUI calls
|
||||
srp.DrawGUI();
|
||||
im3d.DrawGUI();
|
||||
imgui.Draw(renderTarget);
|
||||
post.Draw("Post-process", GetSwapChainTexture());
|
||||
|
||||
// now using a R8G8B8A8 UNorm render target
|
||||
post.Draw("Post-process", readbackRenderTarget);
|
||||
imgui.Draw(readbackRenderTarget);
|
||||
blitter.Blit(GetSwapChainTexture());
|
||||
|
||||
world.EndFrame();
|
||||
UpdateReadbackTexture();
|
||||
srp.EndFrame();
|
||||
}
|
||||
|
||||
void GRP::UpdateReadbackTexture()
|
||||
{
|
||||
if(!updateReadbackTexture)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
post.Draw("Readback post-process", readbackRenderTarget);
|
||||
}
|
||||
|
||||
void GRP::CreateTexture(image_t* image, int mipCount, int width, int height)
|
||||
{
|
||||
TextureDesc desc(image->name, width, height, mipCount);
|
||||
|
@ -603,10 +599,8 @@ uint32_t GRP::CreatePSO(CachedPSO& cache, const char* name)
|
|||
return index;
|
||||
}
|
||||
|
||||
void GRP::ExecuteRenderCommands(const byte* data, bool readbackRequested)
|
||||
void GRP::ExecuteRenderCommands(const byte* data, bool /*readbackRequested*/)
|
||||
{
|
||||
updateReadbackTexture = readbackRequested;
|
||||
|
||||
for(;;)
|
||||
{
|
||||
const int commandId = ((const renderCommandBase_t*)data)->commandId;
|
||||
|
|
|
@ -28,12 +28,6 @@ along with Challenge Quake 3. If not, see <https://www.gnu.org/licenses/>.
|
|||
|
||||
#pragma pack(push, 4)
|
||||
|
||||
struct GammaVertexRC
|
||||
{
|
||||
float scaleX;
|
||||
float scaleY;
|
||||
};
|
||||
|
||||
struct GammaPixelRC
|
||||
{
|
||||
float invGamma;
|
||||
|
@ -69,7 +63,6 @@ void PostProcess::Init()
|
|||
{
|
||||
RootSignatureDesc desc("tone map");
|
||||
desc.usingVertexBuffers = false;
|
||||
desc.constants[ShaderStage::Vertex].byteCount = sizeof(GammaVertexRC);
|
||||
desc.constants[ShaderStage::Pixel].byteCount = sizeof(GammaPixelRC);
|
||||
desc.samplerCount = 1;
|
||||
desc.samplerVisibility = ShaderStages::PixelBit;
|
||||
|
@ -135,76 +128,22 @@ void PostProcess::Draw(const char* renderPassName, HTexture renderTarget)
|
|||
CmdTextureBarrier(renderTarget, ResourceStates::RenderTargetBit);
|
||||
CmdEndBarrier();
|
||||
|
||||
float vsX = 1.0f; // vertex shader scale factors
|
||||
float vsY = 1.0f;
|
||||
float srX = 1.0f; // scissor rectangle scale factors
|
||||
float srY = 1.0f;
|
||||
if(r_fullscreen->integer == 1 && r_mode->integer == VIDEOMODE_UPSCALE)
|
||||
{
|
||||
if(r_blitMode->integer == BLITMODE_CENTERED)
|
||||
{
|
||||
vsX = (float)glConfig.vidWidth / (float)glInfo.winWidth;
|
||||
vsY = (float)glConfig.vidHeight / (float)glInfo.winHeight;
|
||||
}
|
||||
else if(r_blitMode->integer == BLITMODE_ASPECT)
|
||||
{
|
||||
const float ars = (float)glConfig.vidWidth / (float)glConfig.vidHeight;
|
||||
const float ard = (float)glInfo.winWidth / (float)glInfo.winHeight;
|
||||
if(ard > ars)
|
||||
{
|
||||
vsX = ars / ard;
|
||||
vsY = 1.0f;
|
||||
srX = (float)glInfo.winHeight / (float)glConfig.vidHeight;
|
||||
srY = srX;
|
||||
}
|
||||
else
|
||||
{
|
||||
vsX = 1.0f;
|
||||
vsY = ard / ars;
|
||||
srX = (float)glInfo.winWidth / (float)glConfig.vidWidth;
|
||||
srY = srX;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(vsX != 1.0f || vsY != 1.0f)
|
||||
{
|
||||
CmdClearColorTarget(renderTarget, colorBlack);
|
||||
|
||||
const int x = (glInfo.winWidth - glInfo.winWidth * vsX) / 2.0f;
|
||||
const int y = (glInfo.winHeight - glInfo.winHeight * vsY) / 2.0f;
|
||||
CmdSetViewport(0, 0, glInfo.winWidth, glInfo.winHeight);
|
||||
CmdSetScissor(x, y, glConfig.vidWidth * srX, glConfig.vidHeight * srY);
|
||||
}
|
||||
else
|
||||
{
|
||||
CmdSetViewportAndScissor(0, 0, glInfo.winWidth, glInfo.winHeight);
|
||||
}
|
||||
|
||||
GammaVertexRC vertexRC = {};
|
||||
vertexRC.scaleX = vsX;
|
||||
vertexRC.scaleY = vsY;
|
||||
|
||||
GammaPixelRC pixelRC = {};
|
||||
pixelRC.invGamma = 1.0f / r_gamma->value;
|
||||
pixelRC.brightness = r_brightness->value;
|
||||
pixelRC.greyscale = r_greyscale->value;
|
||||
|
||||
CmdSetViewportAndScissor(0, 0, glConfig.vidWidth, glConfig.vidHeight);
|
||||
CmdBindRenderTargets(1, &renderTarget, NULL);
|
||||
CmdBindPipeline(toneMapPipeline);
|
||||
CmdBindRootSignature(toneMapRootSignature);
|
||||
CmdBindDescriptorTable(toneMapRootSignature, toneMapDescriptorTable);
|
||||
CmdSetRootConstants(toneMapRootSignature, ShaderStage::Vertex, &vertexRC);
|
||||
CmdSetRootConstants(toneMapRootSignature, ShaderStage::Pixel, &pixelRC);
|
||||
CmdDraw(3, 0);
|
||||
}
|
||||
|
||||
void PostProcess::ToneMap()
|
||||
{
|
||||
GammaVertexRC vertexRC = {};
|
||||
vertexRC.scaleX = 1.0f;
|
||||
vertexRC.scaleY = 1.0f;
|
||||
|
||||
GammaPixelRC pixelRC = {};
|
||||
pixelRC.invGamma = 1.0f / r_gamma->value;
|
||||
pixelRC.brightness = r_brightness->value;
|
||||
|
@ -213,7 +152,6 @@ void PostProcess::ToneMap()
|
|||
CmdBindPipeline(toneMapPipeline);
|
||||
CmdBindRootSignature(toneMapRootSignature);
|
||||
CmdBindDescriptorTable(toneMapRootSignature, toneMapDescriptorTable);
|
||||
CmdSetRootConstants(toneMapRootSignature, ShaderStage::Vertex, &vertexRC);
|
||||
CmdSetRootConstants(toneMapRootSignature, ShaderStage::Pixel, &pixelRC);
|
||||
CmdDraw(3, 0);
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ cbuffer RootConstants : register(b0)
|
|||
uint textureIndex;
|
||||
uint samplerIndex;
|
||||
float mipIndex;
|
||||
float colorScale;
|
||||
};
|
||||
|
||||
struct VIn
|
||||
|
@ -58,8 +57,7 @@ float4 ps(VOut input) : SV_Target
|
|||
{
|
||||
Texture2D texture0 = ResourceDescriptorHeap[textureIndex];
|
||||
SamplerState sampler0 = SamplerDescriptorHeap[samplerIndex];
|
||||
float4 color = float4(colorScale.xxx, 1);
|
||||
float4 result = input.col * color * texture0.SampleLevel(sampler0, input.uv, mipIndex);
|
||||
float4 result = input.col * texture0.SampleLevel(sampler0, input.uv, mipIndex);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
71
code/renderer/shaders/grp/blit.hlsl
Normal file
71
code/renderer/shaders/grp/blit.hlsl
Normal file
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 2024 Gian 'myT' Schellenbaum
|
||||
|
||||
This file is part of Challenge Quake 3 (CNQ3).
|
||||
|
||||
Challenge Quake 3 is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
Challenge Quake 3 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Challenge Quake 3. If not, see <https://www.gnu.org/licenses/>.
|
||||
===========================================================================
|
||||
*/
|
||||
// blit shader - unlike texture copies, it doesn't care about the specific formats used
|
||||
|
||||
|
||||
#include "shared.hlsli"
|
||||
|
||||
|
||||
struct VOut
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float2 texCoords : TEXCOORD0;
|
||||
};
|
||||
|
||||
|
||||
#if VERTEX_SHADER
|
||||
|
||||
cbuffer RootConstants
|
||||
{
|
||||
float scaleX;
|
||||
float scaleY;
|
||||
};
|
||||
|
||||
VOut vs(uint id : SV_VertexID)
|
||||
{
|
||||
VOut output;
|
||||
output.position.x = scaleX * ((float)(id / 2) * 4.0 - 1.0);
|
||||
output.position.y = scaleY * ((float)(id % 2) * 4.0 - 1.0);
|
||||
output.position.z = 0.0;
|
||||
output.position.w = 1.0;
|
||||
output.texCoords.x = (float)(id / 2) * 2.0;
|
||||
output.texCoords.y = 1.0 - (float)(id % 2) * 2.0;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if PIXEL_SHADER
|
||||
|
||||
Texture2D texture0 : register(t0);
|
||||
SamplerState sampler0 : register(s0);
|
||||
|
||||
float4 ps(VOut input) : SV_Target
|
||||
{
|
||||
float3 color = texture0.Sample(sampler0, input.texCoords).rgb;
|
||||
float4 result = float4(color, 1.0);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 2023 Gian 'myT' Schellenbaum
|
||||
Copyright (C) 2023-2024 Gian 'myT' Schellenbaum
|
||||
|
||||
This file is part of Challenge Quake 3 (CNQ3).
|
||||
|
||||
|
@ -34,17 +34,11 @@ struct VOut
|
|||
|
||||
#if VERTEX_SHADER
|
||||
|
||||
cbuffer RootConstants
|
||||
{
|
||||
float scaleX;
|
||||
float scaleY;
|
||||
};
|
||||
|
||||
VOut vs(uint id : SV_VertexID)
|
||||
{
|
||||
VOut output;
|
||||
output.position.x = scaleX * ((float)(id / 2) * 4.0 - 1.0);
|
||||
output.position.y = scaleY * ((float)(id % 2) * 4.0 - 1.0);
|
||||
output.position.x = (float)(id / 2) * 4.0 - 1.0;
|
||||
output.position.y = (float)(id % 2) * 4.0 - 1.0;
|
||||
output.position.z = 0.0;
|
||||
output.position.w = 1.0;
|
||||
output.texCoords.x = (float)(id / 2) * 2.0;
|
||||
|
|
|
@ -41,7 +41,6 @@ struct ImGUIPixelRC
|
|||
uint32_t texture;
|
||||
uint32_t sampler;
|
||||
float mip;
|
||||
float colorScale;
|
||||
};
|
||||
|
||||
#pragma pack(pop)
|
||||
|
@ -59,7 +58,7 @@ HTexture ImGUI::Init(bool ddhi_, const ShaderByteCode& vs, const ShaderByteCode&
|
|||
if(srp.firstInit)
|
||||
{
|
||||
io.BackendRendererUserData = this;
|
||||
io.BackendRendererName = "CNQ3 Direct3D 12";
|
||||
io.BackendRendererName = "CNQ3";
|
||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
||||
|
||||
for(int i = 0; i < FrameCount; i++)
|
||||
|
@ -213,6 +212,10 @@ void ImGUI::Draw(HTexture renderTarget)
|
|||
const uint32_t vertexStride = sizeof(ImDrawVert);
|
||||
static_assert(sizeof(ImDrawIdx) == 4, "uint32 indices expected!");
|
||||
|
||||
CmdBeginBarrier();
|
||||
CmdTextureBarrier(renderTarget, ResourceStates::RenderTargetBit);
|
||||
CmdEndBarrier();
|
||||
|
||||
CmdBindRenderTargets(1, &renderTarget, NULL);
|
||||
if(!ddhi)
|
||||
{
|
||||
|
@ -259,7 +262,6 @@ void ImGUI::Draw(HTexture renderTarget)
|
|||
pixelRC.texture = (uint32_t)cmd->TextureId & 0xFFFF;
|
||||
pixelRC.sampler = GetSamplerIndex(TW_CLAMP_TO_EDGE, TextureFilter::Linear);
|
||||
pixelRC.mip = (float)(((uint32_t)cmd->TextureId >> 16) & 0xFFFF);
|
||||
pixelRC.colorScale = tr.identityLight;
|
||||
if(ddhi)
|
||||
{
|
||||
CmdSetGraphicsRootConstants(sizeof(vertexRC), sizeof(pixelRC), &pixelRC);
|
||||
|
|
|
@ -231,11 +231,6 @@ static ImVec4 GetColorFromCPMACode(char colorCode)
|
|||
return color;
|
||||
}
|
||||
|
||||
static float InverseToneMap(float x)
|
||||
{
|
||||
return powf(x / r_brightness->value, r_gamma->value);
|
||||
}
|
||||
|
||||
static bool CPMAColorCodeButton(const char* title, const char* id, char& currentColor)
|
||||
{
|
||||
const char* const popupId = va("##color_popup_%s", id);
|
||||
|
@ -278,10 +273,7 @@ static bool CPMAColorCodeButton(const char* title, const char* id, char& current
|
|||
|
||||
const char colorCode = row[x];
|
||||
const ImGuiColorEditFlags buttonFlags = ImGuiColorEditFlags_InputRGB | ImGuiColorEditFlags_NoAlpha;
|
||||
ImVec4 color = GetColorFromCPMACode(colorCode);
|
||||
color.x = InverseToneMap(color.x);
|
||||
color.y = InverseToneMap(color.y);
|
||||
color.z = InverseToneMap(color.z);
|
||||
const ImVec4 color = GetColorFromCPMACode(colorCode);
|
||||
if(ImGui::ColorButton(va("%c", colorCode), color, buttonFlags))
|
||||
{
|
||||
currentColor = colorCode;
|
||||
|
|
|
@ -384,6 +384,7 @@ void ProcessGRP()
|
|||
CompileGraphics("ui.h", "ui.hlsl", "ui");
|
||||
CompileGraphics("depth_pre_pass.h", "depth_pre_pass.hlsl", "zpp");
|
||||
CompileGraphics("dynamic_light.h", "dynamic_light.hlsl", "dl");
|
||||
CompileGraphics("blit.h", "blit.hlsl", "blit");
|
||||
CompileVertexShader("fog.h", "fog_inside.hlsl", "fog");
|
||||
CompilePixelShader("fog_inside.h", "fog_inside.hlsl", "fog_inside");
|
||||
CompilePixelShader("fog_outside.h", "fog_outside.hlsl", "fog_outside");
|
||||
|
|
|
@ -147,6 +147,7 @@
|
|||
<ClCompile Include="..\..\code\renderer\crp_transp_draw.cpp" />
|
||||
<ClCompile Include="..\..\code\renderer\crp_transp_resolve.cpp" />
|
||||
<ClCompile Include="..\..\code\renderer\crp_volumetric_light.cpp" />
|
||||
<ClCompile Include="..\..\code\renderer\grp_blit.cpp" />
|
||||
<ClCompile Include="..\..\code\renderer\grp_geometry.cpp" />
|
||||
<ClCompile Include="..\..\code\renderer\grp_main.cpp" />
|
||||
<ClCompile Include="..\..\code\renderer\grp_post.cpp" />
|
||||
|
@ -394,6 +395,9 @@
|
|||
<FxCompile Include="..\..\code\renderer\shaders\crp\wireframe_normals.hlsl">
|
||||
<ExcludedFromBuild>true</ExcludedFromBuild>
|
||||
</FxCompile>
|
||||
<FxCompile Include="..\..\code\renderer\shaders\grp\blit.hlsl">
|
||||
<ExcludedFromBuild>true</ExcludedFromBuild>
|
||||
</FxCompile>
|
||||
<FxCompile Include="..\..\code\renderer\shaders\grp\depth_pre_pass.hlsl">
|
||||
<ExcludedFromBuild>true</ExcludedFromBuild>
|
||||
</FxCompile>
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
<ClCompile Include="..\..\code\renderer\crp_transp_draw.cpp" />
|
||||
<ClCompile Include="..\..\code\renderer\crp_transp_resolve.cpp" />
|
||||
<ClCompile Include="..\..\code\renderer\crp_volumetric_light.cpp" />
|
||||
<ClCompile Include="..\..\code\renderer\grp_blit.cpp" />
|
||||
<ClCompile Include="..\..\code\renderer\grp_geometry.cpp" />
|
||||
<ClCompile Include="..\..\code\renderer\grp_main.cpp" />
|
||||
<ClCompile Include="..\..\code\renderer\grp_post.cpp" />
|
||||
|
@ -300,6 +301,9 @@
|
|||
<FxCompile Include="..\..\code\renderer\shaders\crp\wireframe_normals.hlsl">
|
||||
<Filter>shaders\crp</Filter>
|
||||
</FxCompile>
|
||||
<FxCompile Include="..\..\code\renderer\shaders\grp\blit.hlsl">
|
||||
<Filter>shaders\grp</Filter>
|
||||
</FxCompile>
|
||||
<FxCompile Include="..\..\code\renderer\shaders\grp\depth_pre_pass.hlsl">
|
||||
<Filter>shaders\grp</Filter>
|
||||
</FxCompile>
|
||||
|
|
|
@ -149,6 +149,7 @@
|
|||
<ClCompile Include="..\..\code\renderer\crp_transp_draw.cpp" />
|
||||
<ClCompile Include="..\..\code\renderer\crp_transp_resolve.cpp" />
|
||||
<ClCompile Include="..\..\code\renderer\crp_volumetric_light.cpp" />
|
||||
<ClCompile Include="..\..\code\renderer\grp_blit.cpp" />
|
||||
<ClCompile Include="..\..\code\renderer\grp_geometry.cpp" />
|
||||
<ClCompile Include="..\..\code\renderer\grp_main.cpp" />
|
||||
<ClCompile Include="..\..\code\renderer\grp_post.cpp" />
|
||||
|
@ -396,6 +397,9 @@
|
|||
<FxCompile Include="..\..\code\renderer\shaders\crp\wireframe_normals.hlsl">
|
||||
<ExcludedFromBuild>true</ExcludedFromBuild>
|
||||
</FxCompile>
|
||||
<FxCompile Include="..\..\code\renderer\shaders\grp\blit.hlsl">
|
||||
<ExcludedFromBuild>true</ExcludedFromBuild>
|
||||
</FxCompile>
|
||||
<FxCompile Include="..\..\code\renderer\shaders\grp\depth_pre_pass.hlsl">
|
||||
<ExcludedFromBuild>true</ExcludedFromBuild>
|
||||
</FxCompile>
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
<ClCompile Include="..\..\code\renderer\crp_transp_draw.cpp" />
|
||||
<ClCompile Include="..\..\code\renderer\crp_transp_resolve.cpp" />
|
||||
<ClCompile Include="..\..\code\renderer\crp_volumetric_light.cpp" />
|
||||
<ClCompile Include="..\..\code\renderer\grp_blit.cpp" />
|
||||
<ClCompile Include="..\..\code\renderer\grp_geometry.cpp" />
|
||||
<ClCompile Include="..\..\code\renderer\grp_main.cpp" />
|
||||
<ClCompile Include="..\..\code\renderer\grp_post.cpp" />
|
||||
|
@ -300,6 +301,9 @@
|
|||
<FxCompile Include="..\..\code\renderer\shaders\crp\wireframe_normals.hlsl">
|
||||
<Filter>shaders\crp</Filter>
|
||||
</FxCompile>
|
||||
<FxCompile Include="..\..\code\renderer\shaders\grp\blit.hlsl">
|
||||
<Filter>shaders\grp</Filter>
|
||||
</FxCompile>
|
||||
<FxCompile Include="..\..\code\renderer\shaders\grp\depth_pre_pass.hlsl">
|
||||
<Filter>shaders\grp</Filter>
|
||||
</FxCompile>
|
||||
|
|
Loading…
Reference in a new issue