From 9b4edc8fb0c07d876ae39679874330243e88efcb Mon Sep 17 00:00:00 2001 From: Michael Fabian 'Xaymar' Dirks Date: Thu, 31 Jan 2019 02:25:09 +0100 Subject: [PATCH] filter-sdf-effects: Improve shadow rendering This works around the incorrect shadow on the edge of the Signed Distance Field, but it does not get rid of it completely. Due to linear sampling it will still show at some point so a different solution has to be found in the future. --- data/effects/sdf-shadow.effect | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/data/effects/sdf-shadow.effect b/data/effects/sdf-shadow.effect index 2ffed03..b75201b 100644 --- a/data/effects/sdf-shadow.effect +++ b/data/effects/sdf-shadow.effect @@ -32,7 +32,7 @@ sampler_state sdfSampler1_1 { Filter = Linear; AddressU = Border; AddressV = Border; - BorderColor = FFFF0000; + BorderColor = 000000FF; }; sampler_state imageSampler { @@ -106,7 +106,7 @@ float4 PS_SDFShadow_v1_1(VertDataOut v_in) : TARGET //! Outer Shadow // Are we allowed to draw an outer shadow? - float2 outer_sdf = _sdf.Sample(sdfSampler, v_in.uv + _outer_offset).rg * float2(MAX_DISTANCE, MAX_DISTANCE); + float2 outer_sdf = _sdf.Sample(sdfSampler1_1, v_in.uv + _outer_offset).rg * float2(MAX_DISTANCE, MAX_DISTANCE); if ((_outer_color.a > 0.) && (outer_sdf.r < MAX_DISTANCE)) { // Calculate the true distance value: // - If we are outside, this will be positive. @@ -129,7 +129,7 @@ float4 PS_SDFShadow_v1_1(VertDataOut v_in) : TARGET //! Inner Shadow // Are we allowed to draw an inner shadow? - float2 inner_sdf = _sdf.Sample(sdfSampler, v_in.uv + _inner_offset).rg * float2(MAX_DISTANCE, MAX_DISTANCE); + float2 inner_sdf = _sdf.Sample(sdfSampler1_1, v_in.uv + _inner_offset).rg * float2(MAX_DISTANCE, MAX_DISTANCE); if ((_inner_color.a > 0.) && (inner_sdf.g < MAX_DISTANCE) && (inner_sdf.r <= FLT_SMALL)) { // Calculate the true distance value: // - If we are outside, this will be positive.