mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-06-30 07:11:48 -07:00
doing blur shader without alpha blending
This commit is contained in:
committed by
Ryan Fleury
parent
82f86d654f
commit
bae91cd40c
@@ -227,6 +227,7 @@ str8_lit_comp(
|
||||
" float4 position : SV_POSITION;\n"
|
||||
" float2 texcoord : TEX;\n"
|
||||
" float2 sdf_sample_pos : SDF;\n"
|
||||
" nointerpolation float2 rect_half_size : RHS;\n"
|
||||
" float corner_radius : RAD;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
@@ -271,6 +272,7 @@ str8_lit_comp(
|
||||
" v2p.position = float4(vertex_position__scr.x, -vertex_position__scr.y, 0.f, 1.f);\n"
|
||||
" v2p.texcoord = vertex_position__pct;\n"
|
||||
" v2p.sdf_sample_pos = (2.f * cornercoords__pct - 1.f) * rect_half_size;\n"
|
||||
" v2p.rect_half_size = rect_half_size - 2.f;\n"
|
||||
" v2p.corner_radius = corner_radii__px[c2v.vertex_id];\n"
|
||||
" }\n"
|
||||
" return v2p;\n"
|
||||
@@ -282,33 +284,28 @@ str8_lit_comp(
|
||||
"ps_main(Vertex2Pixel v2p) : SV_TARGET\n"
|
||||
"{\n"
|
||||
" // rjf: blend weighted texture samples into color\n"
|
||||
" float4 color = kernel[0].x * stage_t2d.Sample(stage_sampler, v2p.texcoord);\n"
|
||||
" color.a = kernel[0].x;\n"
|
||||
" float3 color = kernel[0].x * stage_t2d.Sample(stage_sampler, v2p.texcoord).rgb;\n"
|
||||
" \n"
|
||||
" for(uint i = 1; i < blur_count; i += 1)\n"
|
||||
" {\n"
|
||||
" float weight = kernel[i].x;\n"
|
||||
" float offset = kernel[i].y;\n"
|
||||
" float4 min_sample = stage_t2d.Sample(stage_sampler, v2p.texcoord - offset * direction);\n"
|
||||
" float4 max_sample = stage_t2d.Sample(stage_sampler, v2p.texcoord + offset * direction);\n"
|
||||
" min_sample.a = 1.f;\n"
|
||||
" max_sample.a = 1.f;\n"
|
||||
" color += min_sample * weight;\n"
|
||||
" color += max_sample * weight;\n"
|
||||
" color += weight * stage_t2d.Sample(stage_sampler, v2p.texcoord - offset * direction).rgb;\n"
|
||||
" color += weight * stage_t2d.Sample(stage_sampler, v2p.texcoord + offset * direction).rgb;\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" // rjf: determine SDF sample position\n"
|
||||
" float2 rect_half_size = float2((rect.z-rect.x)/2, (rect.w-rect.y)/2);\n"
|
||||
" float2 sdf_sample_pos = v2p.sdf_sample_pos;\n"
|
||||
" \n"
|
||||
" // rjf: sample for corners\n"
|
||||
" float corner_sdf_s = rect_sdf(sdf_sample_pos, rect_half_size - 2.f, v2p.corner_radius);\n"
|
||||
" float corner_sdf_s = rect_sdf(v2p.sdf_sample_pos, v2p.rect_half_size, v2p.corner_radius);\n"
|
||||
" float corner_sdf_t = 1-smoothstep(0, 2, corner_sdf_s);\n"
|
||||
" \n"
|
||||
" // rjf: weight output color by sdf\n"
|
||||
" color.a *= corner_sdf_t;\n"
|
||||
" // this is doing alpha testing, leave blurring only where mostly opaque pixels are\n"
|
||||
" if (corner_sdf_t < 0.9f)\n"
|
||||
" {\n"
|
||||
" discard;\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" return color;\n"
|
||||
" return float4(color, 1.f);\n"
|
||||
"}\n"
|
||||
""
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user