Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(rendering): fix bloom not working #78

Merged
merged 4 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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