Skip to content

Commit

Permalink
tonemap to srgb target
Browse files Browse the repository at this point in the history
  • Loading branch information
nem0 committed Sep 27, 2024
1 parent 2beff80 commit 8e0ec6d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
18 changes: 12 additions & 6 deletions data/pipelines/tonemap.hlsl
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
//@surface

#include "pipelines/common.hlsli"

cbuffer Data : register(b4) {
TextureHandle u_input;
RWTextureHandle u_output;
};

[numthreads(16, 16, 1)]
void main(uint3 thread_id : SV_DispatchThreadID) {
float4 v = bindless_textures[u_input][thread_id.xy];
v = float4(ACESFilm(v.rgb), 1);
bindless_rw_textures[u_output][thread_id.xy] = v;
float4 mainVS(uint vertexID : SV_VertexID) : SV_POSITION{
float2 uv;
return fullscreenQuad(vertexID, uv);
}

float4 mainPS(float4 frag_coord : SV_POSITION) : SV_TARGET {
uint2 ifrag_coord = uint2(frag_coord.xy);

float4 v = bindless_textures[u_input][ifrag_coord];
return float4(ACESFilm(v.rgb), 1);
}
2 changes: 1 addition & 1 deletion src/editor/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ void Settings::load() {
break;
default:
m_variables.erase(var_name.value);
logError("Unexpected token in settings: ", value.value);
logError(tokenizer.filename, "(", tokenizer.getLine(), "): Unexpected token in settings: ", value.value);
tokenizer.logErrorPosition(value.value.begin);
return false;
}
Expand Down
9 changes: 4 additions & 5 deletions src/renderer/pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1060,20 +1060,19 @@ struct PipelineImpl final : Pipeline {

beginBlock("tonemap");
const RenderBufferHandle rb = createRenderbuffer({
.format = gpu::TextureFormat::RGBA8,
.flags = gpu::TextureFlags::RENDER_TARGET | gpu::TextureFlags::NO_MIPS | gpu::TextureFlags::COMPUTE_WRITE,
.format = gpu::TextureFormat::SRGBA,
.flags = gpu::TextureFlags::RENDER_TARGET | gpu::TextureFlags::NO_MIPS,
.debug_name = "tonemap"
});
DrawStream& stream = m_renderer.getDrawStream();
struct {
gpu::BindlessHandle input;
gpu::RWBindlessHandle output;
} ubdata {
toBindless(input, stream),
toRWBindless(rb, stream)
};
setUniform(ubdata);
dispatch(*m_tonemap_shader, (m_viewport.w + 15) / 16, (m_viewport.h + 15) / 16, 1);
setRenderTargets(Span(&rb, 1));
drawArray(0, 3, *m_tonemap_shader, 0, gpu::StateFlags::NONE);
endBlock();
return rb;
}
Expand Down

0 comments on commit 8e0ec6d

Please sign in to comment.