Atlas - testgpurender_effects_CRT.frag.hlsl

Home / ext / SDL / test Lines: 1 | Size: 1674 bytes [Download] [Show on GitHub] [Search similar files] [Raw] [Raw (proxy)]
[FILE BEGIN]
1// This shader is adapted from the Lightweight CRT Effect at: 2// https://godotshaders.com/shader/lightweight-crt-effect/ 3 4cbuffer Context : register(b0, space3) { 5 float2 resolution; 6}; 7 8Texture2D u_texture : register(t0, space2); 9SamplerState u_sampler : register(s0, space2); 10 11struct PSInput { 12 float4 v_color : COLOR0; 13 float2 v_uv : TEXCOORD0; 14}; 15 16struct PSOutput { 17 float4 o_color : SV_Target; 18}; 19 20static const float PI = 3.14159265f; 21 22// These could be turned into uniforms if you wanted to tweak them 23static const float scan_line_amount = 0.5; // Range 0-1 24static const float warp_amount = 0.05; // Range 0-1 25static const float vignette_amount = 0.5; // Range 0-1 26static const float vignette_intensity = 0.3; // Range 0-1 27static const float grille_amount = 0.05; // Range 0-1 28static const float brightness_boost = 1.2; // Range 1-2 29 30PSOutput main(PSInput input) { 31 PSOutput output; 32 33 float2 uv = input.v_uv; 34 35 float2 delta = uv - 0.5; 36 float warp_factor = dot(delta, delta) * warp_amount; 37 uv += delta * warp_factor; 38 39 float scanline = sin(uv.y * resolution.y * PI) * 0.5 + 0.5; 40 scanline = lerp(1.0, scanline, scan_line_amount * 0.5); 41 42 float grille = fmod(uv.x * resolution.x, 3.0) < 1.5 ? 0.95 : 1.05; 43 grille = lerp(1.0, grille, grille_amount * 0.5); 44 45 float4 color = u_texture.Sample(u_sampler, input.v_uv) * input.v_color; 46 color.rgb *= scanline * grille; 47 48 float2 v_uv = uv * (1.0 - uv.xy); 49 float vignette = v_uv.x * v_uv.y * 15.0; 50 vignette = lerp(1.0, vignette, vignette_amount * 0.7); 51 52 color.rgb *= vignette * brightness_boost; 53 54 output.o_color = color; 55 return output; 56} 57
[FILE END]
(C) 2025 0x4248 (C) 2025 4248 Media and 4248 Systems, All part of 0x4248 See LICENCE files for more information. Not all files are by 0x4248 always check Licencing.