add more post processing effects!
This commit is contained in:
parent
a52cc6a934
commit
eabf4bf2cf
@ -330,6 +330,13 @@ backend_process_command_buckets :: () {
|
|||||||
sg_apply_bindings(*gPipelines.postprocess.bind);
|
sg_apply_bindings(*gPipelines.postprocess.bind);
|
||||||
post_process_config_uniform : Post_Process_Config;
|
post_process_config_uniform : Post_Process_Config;
|
||||||
fill_uniform_with_engine_data(*post_process_config_uniform , *current_post_process);
|
fill_uniform_with_engine_data(*post_process_config_uniform , *current_post_process);
|
||||||
|
post_process_config_uniform.vignette_intensity = current_post_process.vignette_intensity;
|
||||||
|
post_process_config_uniform.vignette_radius = current_post_process.vignette_radius;
|
||||||
|
post_process_config_uniform.scanlines_intensity = current_post_process.scanlines_intensity;
|
||||||
|
post_process_config_uniform.scanlines_density = current_post_process.scanlines_density;
|
||||||
|
post_process_config_uniform.chromatic_aberration_intensity = current_post_process.chromatic_aberration_intensity;
|
||||||
|
post_process_config_uniform.film_grain_intensity = current_post_process.film_grain_intensity;
|
||||||
|
post_process_config_uniform.barrel_distortion_intensity = current_post_process.barrel_distortion_intensity;
|
||||||
sg_apply_uniforms(UB_post_process_config, *(sg_range.{ ptr = *post_process_config_uniform, size = size_of(type_of(post_process_config_uniform)) }));
|
sg_apply_uniforms(UB_post_process_config, *(sg_range.{ ptr = *post_process_config_uniform, size = size_of(type_of(post_process_config_uniform)) }));
|
||||||
sg_draw(0, 6, 1);
|
sg_draw(0, 6, 1);
|
||||||
|
|
||||||
|
|||||||
@ -18,6 +18,13 @@ Post_Process :: struct {
|
|||||||
bloom_separation : float = 3.0; @Slider,0,10,1;
|
bloom_separation : float = 3.0; @Slider,0,10,1;
|
||||||
bloom_treshold : float = 0.4; @Slider,0,1,0.1;
|
bloom_treshold : float = 0.4; @Slider,0,1,0.1;
|
||||||
bloom_amount : float = 1.0; @Slider,0,5,0.1;
|
bloom_amount : float = 1.0; @Slider,0,5,0.1;
|
||||||
|
vignette_intensity: float = 0.5; @Slider,0,1,0.1;
|
||||||
|
vignette_radius: float = 0.5; @Slider,0,1,0.1;
|
||||||
|
scanlines_intensity: float = 0.1; @Slider,0,1,0.1;
|
||||||
|
scanlines_density: float = 1; @Slider,0,2,0.1;
|
||||||
|
chromatic_aberration_intensity: float = 0.0; @Slider,0,0.05,0.001;
|
||||||
|
film_grain_intensity: float = 0.0; @Slider,0,0.5,0.001;
|
||||||
|
barrel_distortion_intensity: float = 0.0; @Slider,-2,2,0.1;
|
||||||
}
|
}
|
||||||
|
|
||||||
current_post_process : Post_Process;
|
current_post_process : Post_Process;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -23,6 +23,13 @@ layout(binding=0) uniform post_process_config {
|
|||||||
float saturation;
|
float saturation;
|
||||||
float gamma;
|
float gamma;
|
||||||
float tonemap;
|
float tonemap;
|
||||||
|
float vignette_intensity;
|
||||||
|
float vignette_radius;
|
||||||
|
float scanlines_intensity;
|
||||||
|
float scanlines_density;
|
||||||
|
float chromatic_aberration_intensity;
|
||||||
|
float film_grain_intensity;
|
||||||
|
float barrel_distortion_intensity;
|
||||||
};
|
};
|
||||||
|
|
||||||
vec3 aces(vec3 x) {
|
vec3 aces(vec3 x) {
|
||||||
@ -34,8 +41,30 @@ vec3 aces(vec3 x) {
|
|||||||
return clamp((x * (a * x + b)) / (x * (c * x + d) + e), 0.0, 1.0);
|
return clamp((x * (a * x + b)) / (x * (c * x + d) + e), 0.0, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float rand(vec2 co){
|
||||||
|
return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
|
||||||
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
vec4 sampled = texture(sampler2D(pptex, ppsmp), texcoord.xy);
|
vec2 distorted_texcoord = texcoord;
|
||||||
|
float barrel_dist = length(texcoord - 0.5);
|
||||||
|
distorted_texcoord -= 0.5;
|
||||||
|
distorted_texcoord *= 1.0 + barrel_dist * barrel_distortion_intensity;
|
||||||
|
distorted_texcoord += 0.5;
|
||||||
|
|
||||||
|
if (barrel_distortion_intensity > 0.0) {
|
||||||
|
if (distorted_texcoord.x < 0.0 || distorted_texcoord.x > 1.0 || distorted_texcoord.y < 0.0 || distorted_texcoord.y > 1.0) {
|
||||||
|
frag_color = vec4(0.0, 0.0, 0.0, 1.0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vec4 sampled = vec4(0.0);
|
||||||
|
float r = texture(sampler2D(pptex, ppsmp), distorted_texcoord + vec2(chromatic_aberration_intensity, 0.0)).r;
|
||||||
|
float g = texture(sampler2D(pptex, ppsmp), distorted_texcoord).g;
|
||||||
|
float b = texture(sampler2D(pptex, ppsmp), distorted_texcoord - vec2(chromatic_aberration_intensity, 0.0)).b;
|
||||||
|
sampled = vec4(r, g, b, 1.0);
|
||||||
|
|
||||||
vec3 tonemapped = aces(sampled.xyz);
|
vec3 tonemapped = aces(sampled.xyz);
|
||||||
if(tonemap > 0.5) {
|
if(tonemap > 0.5) {
|
||||||
tonemapped = aces(sampled.xyz);
|
tonemapped = aces(sampled.xyz);
|
||||||
@ -50,6 +79,15 @@ void main() {
|
|||||||
float lum = (0.2125 * gammaCorrected.r) + (0.7154 * gammaCorrected.g) + (0.0721 * gammaCorrected.b);
|
float lum = (0.2125 * gammaCorrected.r) + (0.7154 * gammaCorrected.g) + (0.0721 * gammaCorrected.b);
|
||||||
vec3 brtColor = vec3(lum, lum, lum);
|
vec3 brtColor = vec3(lum, lum, lum);
|
||||||
gammaCorrected.rgb = mix(brtColor, gammaCorrected.rgb, saturation);
|
gammaCorrected.rgb = mix(brtColor, gammaCorrected.rgb, saturation);
|
||||||
|
|
||||||
|
float vignette = 1.0 - smoothstep(0.0, vignette_radius, length(texcoord - vec2(0.5))) * vignette_intensity;
|
||||||
|
gammaCorrected.rgb *= vignette;
|
||||||
|
|
||||||
|
float scanline = 1.0 - (sin(texcoord.y * textureSize(sampler2D(pptex, ppsmp), 0).y * scanlines_density) * 0.5 + 0.5) * scanlines_intensity;
|
||||||
|
gammaCorrected.rgb *= scanline;
|
||||||
|
|
||||||
|
float grain = (rand(texcoord) - 0.5) * film_grain_intensity;
|
||||||
|
gammaCorrected.rgb += grain;
|
||||||
|
|
||||||
frag_color = vec4(gammaCorrected, 1.0);
|
frag_color = vec4(gammaCorrected, 1.0);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user