-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement crosstalk for tonemapping, begin implementing simple bloom
- Loading branch information
1 parent
efce2f6
commit 81d0f40
Showing
13 changed files
with
1,364 additions
and
223 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#version 450 | ||
#pragma optimize(on) | ||
#pragma shader_stage(fragment) | ||
|
||
layout(location = 0) out vec4 outColor; | ||
|
||
layout(set = 0, binding = 0) uniform sampler s_Color; | ||
layout(set = 0, binding = 1) uniform Locals { | ||
vec2 a_Offset; | ||
}; | ||
layout(set = 1, binding = 0) uniform texture2D t_Diffuse; | ||
layout(set = 1, binding = 1) uniform TexLocals { | ||
vec2 a_InvResolution; | ||
}; | ||
|
||
void main() { | ||
vec2 uv = gl_FragCoord.xy * a_InvResolution; | ||
|
||
vec4 sum = texture(sampler2D(t_Diffuse, s_Color), uv) * 4.0; | ||
sum += texture(sampler2D(t_Diffuse, s_Color), uv - vec2(1.0) * a_Offset); | ||
sum += texture(sampler2D(t_Diffuse, s_Color), uv + vec2(1.0) * a_Offset); | ||
sum += texture(sampler2D(t_Diffuse, s_Color), uv + vec2(1.0, -1.0) * a_Offset); | ||
sum += texture(sampler2D(t_Diffuse, s_Color), uv - vec2(1.0, -1.0) * a_Offset); | ||
|
||
outColor = sum / 8.0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#version 450 | ||
#pragma optimize(on) | ||
#pragma shader_stage(fragment) | ||
|
||
layout(location = 0) out vec4 outColor; | ||
|
||
layout(set = 0, binding = 0) uniform sampler s_Color; | ||
layout(set = 0, binding = 1) uniform Locals { | ||
vec2 a_Offset; | ||
}; | ||
layout(set = 1, binding = 0) uniform texture2D t_Diffuse; | ||
layout(set = 1, binding = 1) uniform TexLocals { | ||
vec2 a_InvResolution; | ||
}; | ||
|
||
void main() { | ||
vec2 uv = gl_FragCoord.xy * a_InvResolution; | ||
|
||
vec4 sum = texture(sampler2D(t_Diffuse, s_Color), uv + vec2(-2.0, 0.0) * a_Offset); | ||
sum += texture(sampler2D(t_Diffuse, s_Color), uv + vec2(-1.0, 1.0) * a_Offset) * 2.0; | ||
sum += texture(sampler2D(t_Diffuse, s_Color), uv + vec2(0.0, 2.0) * a_Offset); | ||
sum += texture(sampler2D(t_Diffuse, s_Color), uv + vec2(1.0, 1.0) * a_Offset) * 2.0; | ||
sum += texture(sampler2D(t_Diffuse, s_Color), uv + vec2(2.0, 0.0) * a_Offset); | ||
sum += texture(sampler2D(t_Diffuse, s_Color), uv + vec2(1.0, -1.0) * a_Offset) * 2.0; | ||
sum += texture(sampler2D(t_Diffuse, s_Color), uv + vec2(0.0, -2.0) * a_Offset); | ||
sum += texture(sampler2D(t_Diffuse, s_Color), uv + vec2(-1.0, -1.0) * a_Offset) * 2.0; | ||
|
||
outColor = sum / 12.0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#version 450 | ||
#pragma optimize(on) | ||
#pragma shader_stage(fragment) | ||
|
||
layout(location = 0) out vec4 outColor; | ||
|
||
layout(set = 0, binding = 0) uniform texture2D t_Diffuse; | ||
layout(set = 0, binding = 1) uniform sampler s_Color; | ||
layout(set = 0, binding = 2) uniform Locals { | ||
vec2 a_InvResolution; | ||
float a_Cutoff; | ||
}; | ||
|
||
float luminance(vec3 color) { | ||
const float RAmount = 0.2126; | ||
const float GAmount = 0.7152; | ||
const float BAmount = 0.0722; | ||
|
||
return dot(color, vec3(RAmount, GAmount, BAmount)); | ||
} | ||
|
||
vec3 ifLt(float a, float b, vec3 ifTrue, vec3 ifFalse) { | ||
float lt = step(b, a); | ||
|
||
return ifFalse * lt + ifTrue * (1 - lt); | ||
} | ||
|
||
void main() { | ||
vec2 uv = gl_FragCoord.xy * a_InvResolution; | ||
vec3 color = texture(sampler2D(t_Diffuse, s_Color), uv).rgb; | ||
|
||
outColor = vec4(ifLt(luminance(color), a_Cutoff, vec3(0), color), 1.0); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.