Skip to content

Commit

Permalink
Merge pull request #78 from hotstreams/feature/settable-gamma
Browse files Browse the repository at this point in the history
allow composite pass gamma to be set
  • Loading branch information
hotstreams authored Dec 13, 2024
2 parents 96fb53a + 92dbb4b commit d9487ad
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions include/limitless/renderer/composite_pass.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace Limitless {
Framebuffer framebuffer;
public:
float tone_mapping_exposure = 1.0f;
float gamma = 2.2f;

explicit CompositePass(Renderer& renderer);

Expand Down
2 changes: 1 addition & 1 deletion shaders/pipeline/composite.frag
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ uniform sampler2D bloom;
uniform sampler2D outline;
uniform float bloom_strength;
uniform float tone_mapping_exposure;
uniform float gamma;

void main() {
vec3 bloom_color = texture(bloom, uv).rgb * bloom_strength;
Expand All @@ -21,7 +22,6 @@ void main() {
color = toneMapping(color, tone_mapping_exposure);

// apply gamma correction
float gamma = 2.2;
color = pow(color, vec3(1.0 / gamma));

// add objects outlining
Expand Down
3 changes: 2 additions & 1 deletion src/limitless/renderer/composite_pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ void CompositePass::render(
shader.setUniform("bloom", bloom_pass.getResult())
.setUniform("outline", renderer.getPass<OutlinePass>().getResult())
.setUniform("bloom_strength", bloom_strength)
.setUniform("tone_mapping_exposure", tone_mapping_exposure);
.setUniform("tone_mapping_exposure", tone_mapping_exposure)
.setUniform("gamma", gamma);
}

shader.use();
Expand Down

0 comments on commit d9487ad

Please sign in to comment.