20 lines
713 B
WebGPU Shading Language
20 lines
713 B
WebGPU Shading Language
#import bevy_core_pipeline::fullscreen_vertex_shader::FullscreenVertexOutput
|
|
|
|
struct VignetteSettings {
|
|
intensity: f32,
|
|
radius: f32,
|
|
}
|
|
|
|
@group(0) @binding(2) var<uniform> settings: VignetteSettings;
|
|
@group(0) @binding(0) var screen_texture: texture_2d<f32>;
|
|
@group(0) @binding(1) var texture_sampler: sampler;
|
|
|
|
@fragment
|
|
fn fragment(in: FullscreenVertexOutput) -> @location(0) vec4<f32> {
|
|
let color = textureSample(screen_texture, texture_sampler, in.uv);
|
|
let dist = distance(in.uv, vec2<f32>(0.5, 0.5));
|
|
let vignette = smoothstep(settings.radius, settings.radius - 0.35, dist);
|
|
let strength = mix(1.0, vignette, settings.intensity);
|
|
return vec4<f32>(color.rgb * strength, color.a);
|
|
}
|