Atlas - testgpurender_msdf.frag.hlsl

Home / ext / SDL / test Lines: 1 | Size: 1069 bytes [Download] [Show on GitHub] [Search similar files] [Raw] [Raw (proxy)]
[FILE BEGIN]
1cbuffer Context : register(b0, space3) { 2 float distance_field_range; 3 float2 texture_size; 4}; 5 6Texture2D u_texture : register(t0, space2); 7SamplerState u_sampler : register(s0, space2); 8 9struct PSInput { 10 float4 v_color : COLOR0; 11 float2 v_uv : TEXCOORD0; 12}; 13 14struct PSOutput { 15 float4 o_color : SV_Target; 16}; 17 18float median(float r, float g, float b) { 19 return max(min(r, g), min(max(r, g), b)); 20} 21 22float screenPxRange(float2 texCoord) { 23 float2 unitRange = float2(distance_field_range, distance_field_range)/texture_size; 24 float2 screenTexSize = float2(1.0, 1.0)/fwidth(texCoord); 25 return max(0.5*dot(unitRange, screenTexSize), 1.0); 26} 27 28PSOutput main(PSInput input) { 29 PSOutput output; 30 float3 msd = u_texture.Sample(u_sampler, input.v_uv).rgb; 31 float sd = median(msd.r, msd.g, msd.b); 32 float screenPxDistance = screenPxRange(input.v_uv)*(sd - 0.5); 33 float opacity = clamp(screenPxDistance + 0.5, 0.0, 1.0); 34 output.o_color.rgb = input.v_color.rgb; 35 output.o_color.a = (input.v_color.a * opacity); 36 return output; 37} 38
[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.