Skip to content

Commit

Permalink
fix(rendering): fix bloom not working (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
Imitater967 committed Apr 4, 2024
1 parent b357ad3 commit b84fcfb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
13 changes: 4 additions & 9 deletions assets/shaders/highPass_frag.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,14 @@ in vec2 v_uv0;

uniform sampler2D tex;
uniform float highPassThreshold;
uniform float highPassIntensity;

layout(location = 0) out vec4 outColor;

void main() {
vec4 color = texture(tex, v_uv0.xy);

// vec3 brightColor = max(color.rgb - vec3(highPassThreshold), vec3(0.0));
float relativeLuminance = dot(vec3(0.2126, 0.7152, 0.0722),color.rgb - vec3(highPassThreshold));
// bright = smoothstep(0.0, 0.5, bright);

if(relativeLuminance * highPassThreshold > 1.0) {
outColor.rgba = vec4(color.rgb, 1);
} else {
outColor.rgba = vec4(0);
}
float relativeLuminance = dot(vec3(0.2125, 0.7154, 0.0721), color.rgb);
relativeLuminance = clamp(relativeLuminance - highPassThreshold, 0, 1);
outColor = color * relativeLuminance * highPassIntensity;
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,12 @@ public class HighPassNode extends ConditionDependentNode {
public static final FboConfig HIGH_PASS_FBO_CONFIG = new FboConfig(HIGH_PASS_FBO_URI, FULL_SCALE, FBO.Type.DEFAULT);
private static final ResourceUrn HIGH_PASS_MATERIAL_URN = new ResourceUrn("CoreRendering:highPass");

@SuppressWarnings("FieldCanBeLocal")
@Range(min = 0.0f, max = 1.0f)
private float highPassThreshold = 0.02f;
@SuppressWarnings("FieldCanBeLocal")
@Range(min = 0.0f, max = 5.0f)
private float highPassThreshold = 0.05f;
private float highPassIntensity = 0.6f;

private Material highPass;
private Mesh renderQuad;
Expand Down Expand Up @@ -86,6 +89,7 @@ public void process() {
PerformanceMonitor.startActivity("rendering/" + getUri());

highPass.setFloat("highPassThreshold", highPassThreshold, true);
highPass.setFloat("highPassIntensity", highPassIntensity, true);

renderQuad.render();

Expand Down

0 comments on commit b84fcfb

Please sign in to comment.