HDR, Bloom and SSR
This commit is contained in:
parent
577836a03f
commit
04befce27d
44 changed files with 1377 additions and 269 deletions
|
|
@ -2,13 +2,15 @@
|
|||
|
||||
layout(constant_id = 0) const int USE_AA = 0;
|
||||
|
||||
const float GAMMA_CONST = 0.8545;
|
||||
const float GAMMA_CONST = 0.4545;
|
||||
const float Exposure = 2.0;
|
||||
const float SPAN_MAX = 8.0;
|
||||
const float REDUCE_MIN = 1.0/128.0;
|
||||
const float REDUCE_MUL = 1.0/32.0;
|
||||
|
||||
layout(location = 0) in vec2 inTextCoord;
|
||||
layout(location = 0) out vec4 outFragColor;
|
||||
layout(location = 1) out vec4 outBloomColour;
|
||||
|
||||
layout(set = 0, binding = 0) uniform sampler2D inputTexture;
|
||||
|
||||
|
|
@ -20,6 +22,13 @@ vec4 gamma(vec4 color){
|
|||
return color = vec4(pow(color.rgb,vec3(GAMMA_CONST)),color.a);
|
||||
}
|
||||
|
||||
vec3 HDR(float Gamma, float Exposure, sampler2D Texture, vec2 TexCoords){
|
||||
vec3 hdrColor = texture(Texture, TexCoords).rgb;
|
||||
vec3 mapped = vec3(1.0) - exp(-hdrColor * Exposure);
|
||||
mapped = pow(mapped, vec3(1.0 / Gamma));
|
||||
return mapped;
|
||||
}
|
||||
|
||||
// Sourced from: https://mini.gmshaders.com/p/gm-shaders-mini-fxaa
|
||||
vec4 fxaa(sampler2D tex, vec2 uv) {
|
||||
vec2 u_texel = 1.0 / screenSize.size;
|
||||
|
|
@ -74,17 +83,32 @@ void main(){
|
|||
|
||||
if(USE_AA == 1){
|
||||
outFragColor = fxaa(inputTexture, inTextCoord);
|
||||
outFragColor = gamma(outFragColor);
|
||||
return;
|
||||
}
|
||||
if(USE_AA == 2){
|
||||
else if(USE_AA == 2){
|
||||
|
||||
outFragColor = texture(inputTexture, inTextCoord);
|
||||
}
|
||||
if(USE_AA == 3){
|
||||
else if(USE_AA == 3){
|
||||
|
||||
outFragColor = texture(inputTexture, inTextCoord);
|
||||
}
|
||||
if(USE_AA == 4){
|
||||
else if(USE_AA == 4){
|
||||
|
||||
outFragColor = texture(inputTexture, inTextCoord);
|
||||
}
|
||||
outFragColor = gamma(texture(inputTexture,inTextCoord));
|
||||
else {
|
||||
outFragColor = texture(inputTexture, inTextCoord);
|
||||
}
|
||||
|
||||
vec3 color = outFragColor.rgb;
|
||||
|
||||
float brightness = dot(color, vec3(0.2126, 0.7152, 0.0722));
|
||||
|
||||
float threshold = 1.0;
|
||||
float softKnee = 0.5;
|
||||
|
||||
float contribution = max(brightness - threshold, 0.0);
|
||||
contribution = contribution / max(contribution + softKnee, 0.0001);
|
||||
|
||||
outBloomColour = vec4(color * contribution, 1.0);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue