finish fast_crt shader

This commit is contained in:
2022-07-12 00:22:05 +02:00
parent ba0b037ec2
commit e9a5f702b4
2 changed files with 11 additions and 3 deletions

View File

@@ -29,7 +29,7 @@ fn sample_pixel(coords: vec2<i32>, offset: vec4<f32>) -> vec3<f32> {
if(is_outside) {
return vec3<f32>(0.0);
} else {
let f = max(vec4<f32>(0.01) / offset - vec4<f32>(0.003), vec4<f32>(0.0));
let f = max(vec4<f32>(0.008) / offset - vec4<f32>(0.0024), vec4<f32>(0.0));
return textureLoad(screen_texture, coords, 0).rgb * (f.x + f.y + f.z + f.w);
}
}

View File

@@ -29,6 +29,11 @@ fn row_factor(offset: f32) -> f32 {
return 1.0 / (1.0 + offset * offset * 16.0);
}
fn col_factor(offset: f32) -> f32 {
let offset = max(0.0, abs(offset) - 0.4);
return 1.0 / (1.0 + offset * offset * 16.0);
}
@fragment
fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {
let base = round(in.tex_coords) - vec2<f32>(0.5);
@@ -39,8 +44,11 @@ fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {
let v = base.y + bottom_factor / (bottom_factor + top_factor);
let u = in.tex_coords.x;
let left_factor = col_factor(frac.x);
let right_factor = col_factor(frac.x - 1.0);
return textureSample(screen_texture, linear_sampler, vec2<f32>(u, v) / vec2<f32>(320.0, 240.0)) * (top_factor + bottom_factor) * 2.0;
let u = base.x + right_factor / (right_factor + left_factor);
return textureSample(screen_texture, linear_sampler, vec2<f32>(u, v) / vec2<f32>(320.0, 240.0)) * (top_factor + bottom_factor) * (left_factor + right_factor) * 1.1;
}