Last active
February 3, 2022 14:59
-
-
Save yanorei32/c9d3d138edf69c98fe2afb4003b73e0c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uniform int shadow_blur_unit_dist; | |
uniform float shadow_blur_gain; | |
uniform float4 shadow_color; | |
float4 mainImage(VertData v_in) : TARGET { | |
float invsqrt2 = 0.70710678118654; | |
float2x2 rotateClockwise45 = { | |
invsqrt2, -invsqrt2, | |
invsqrt2, invsqrt2, | |
}; | |
float sampled_shadow_alpha = 0; | |
float2 offset = float2(0, shadow_blur_unit_dist); | |
sampled_shadow_alpha += image.Sample(textureSampler, v_in.uv + offset * uv_pixel_interval).a; | |
offset = mul(rotateClockwise45, offset); | |
sampled_shadow_alpha += image.Sample(textureSampler, v_in.uv + offset * uv_pixel_interval).a; | |
offset = mul(rotateClockwise45, offset); | |
sampled_shadow_alpha += image.Sample(textureSampler, v_in.uv + offset * uv_pixel_interval).a; | |
offset = mul(rotateClockwise45, offset); | |
sampled_shadow_alpha += image.Sample(textureSampler, v_in.uv + offset * uv_pixel_interval).a; | |
offset = mul(rotateClockwise45, offset); | |
sampled_shadow_alpha += image.Sample(textureSampler, v_in.uv + offset * uv_pixel_interval).a; | |
offset = mul(rotateClockwise45, offset); | |
sampled_shadow_alpha += image.Sample(textureSampler, v_in.uv + offset * uv_pixel_interval).a; | |
offset = mul(rotateClockwise45, offset); | |
sampled_shadow_alpha += image.Sample(textureSampler, v_in.uv + offset * uv_pixel_interval).a; | |
offset = mul(rotateClockwise45, offset); | |
sampled_shadow_alpha += image.Sample(textureSampler, v_in.uv + offset * uv_pixel_interval).a; | |
sampled_shadow_alpha /= 8; | |
sampled_shadow_alpha *= shadow_blur_gain; | |
float4 final_shadow_color = float4(shadow_color.rgb, sampled_shadow_alpha); | |
float4 color = image.Sample(textureSampler, v_in.uv); | |
return final_shadow_color * (1-color.a) + color; | |
} |
Author
yanorei32
commented
Jan 28, 2022
•
GPU Util | |
---|---|
Disable | 6% |
drop_shadow.shader (shadow_blur_size: 50) | 69% (+63%) |
fake_blur.shader | 6% (+<1%) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment