add : censor blur for bodies

This commit is contained in:
2026-07-09 12:27:20 +02:00
parent f2bf499ca8
commit 2347084a4e
50 changed files with 49666 additions and 244 deletions
@@ -2,19 +2,16 @@
#define STRIPES_INCLUDED
/*
STRIPES - MEDIUM VERSION
STRIPES - AGGRESSIVE / HEAVY HATCH VERSION
Goal:
Reduce the GPU cost of the procedural stripe pattern.
Make the hatch pattern much stronger, darker and more visible.
Changes from the original version:
- Removed the dynamic loop over the full stripe count.
Original behavior: evaluate every stripe from 0 to Count.
New behavior: evaluate only 6 nearby stripe candidates.
- Clamped Count to 32 to prevent expensive high-count cases.
- Kept Van der Corput distribution to preserve stable pseudo-random variation.
- Kept the two distortion paths to preserve part of the organic look.
- Visual result is an approximation of the original, but much cheaper.
Changes from the Medium version:
- Stronger width multiplier.
- Stronger final mask shaping.
- Weak strokes are boosted aggressively.
- Output saturates faster, producing a harsher graphic look.
*/
float VanDerCorput(uint index)
@@ -41,47 +38,53 @@ float EvalStripeCandidate(
float vdc = VanDerCorput(index);
/*
Same progressive reveal logic as the original shader.
Original:
saturate(density * stripeCount - vdc * stripeCount)
Equivalent simplified form:
saturate((density - vdc) * stripeCount)
Stronger reveal than the Medium version.
This makes stripes appear earlier and more densely.
*/
float localProgress = saturate((density - vdc) * stripeCount);
float localProgress = saturate((density - vdc) * stripeCount * 1.35);
if (localProgress <= 0.0001)
return 0.0;
/*
Keep the original two distortion paths.
Each stripe chooses one path based on its pseudo-random value.
*/
float wrappedX = vdc >= 0.5 ? wrappedXB : wrappedXA;
/*
Keep the original thickness variation.
This prevents the stripes from looking too uniform.
Original random thickness variation, but heavily boosted.
*/
float thickness = vdc < 0.3 ? 1.0 : (vdc < 0.6 ? 1.8 : 2.6);
thickness *= saturate(thicknessInput);
/*
Aggressive thickness boost.
Raise this if you want even fatter strokes.
*/
const float HATCH_WIDTH_BOOST = 2.4;
thickness *= saturate(thicknessInput) * HATCH_WIDTH_BOOST;
float stripeCenterX = ((float)index + 0.5) / (float)stripeCount;
float stripDistanceX = abs(wrappedX - stripeCenterX);
stripDistanceX = min(stripDistanceX, 1.0 - stripDistanceX);
/*
Wider X footprint = thicker hatch lines.
*/
float stepX = (1.0 / (float)stripeCount) * localProgress * thickness * 0.5;
float stepY = localProgress * 0.5 - 0.01;
/*
Soft edges are kept from the original shader.
If more performance is needed, these smoothstep calls can be replaced
with step calls, but the result will look harsher.
Taller Y footprint = hatch bands cover more vertical space.
*/
float widthMask = 1.0 - smoothstep(stepX - 0.01, stepX, stripDistanceX);
float heightMask = 1.0 - smoothstep(stepY - 0.05, stepY, stripDistanceY);
float stepY = localProgress * 0.65;
/*
Softer but larger edge zone.
This makes strokes bleed more into nearby pixels.
*/
float softEdgeX = 0.025;
float softEdgeY = 0.085;
float widthMask = 1.0 - smoothstep(stepX - softEdgeX, stepX, stripDistanceX);
float heightMask = 1.0 - smoothstep(stepY - softEdgeY, stepY, stripDistanceY);
return widthMask * heightMask;
}
@@ -97,25 +100,29 @@ void Stripes_float(
out float Stripes
)
{
float density = saturate(Density);
/*
Aggressive density boost.
Even if the material density is moderate, the shader pushes it harder.
*/
float density = saturate(Density * 1.45);
float offset = frac(Offset);
/*
Intentional clamp.
Above 32 stripes, the cost increases while the visual gain is usually limited,
especially on distant objects or in a strongly stylized render.
Keep the optimized candidate-based approach.
Count is clamped to avoid bringing back the old expensive behavior.
*/
uint stripeCount = max((uint)round(Count), 1u);
stripeCount = min(stripeCount, 32u);
float distortionAmplitude = DistortionAmplitude * 0.1;
/*
Stronger distortion for a more nervous hand-drawn look.
*/
float distortionAmplitude = DistortionAmplitude * 0.16;
float2 uv = UV;
uv.x = frac(uv.x + offset);
/*
The two distortion paths are computed once and reused for all nearby candidates.
*/
float wrappedXA = frac(
uv.x + cos((uv.y + offset) * sin(uv.x) * DistortionFrequency + offset * 7.8)
* distortionAmplitude
@@ -130,16 +137,18 @@ void Stripes_float(
int sc = (int)stripeCount;
/*
Find the nearest stripe indices for both distortion paths.
Original shader tested every stripe.
Medium version tests only base - 1, base, base + 1 for A and B.
*/
int baseA = (int)floor(wrappedXA * sc);
int baseB = (int)floor(wrappedXB * sc);
float stripeMax = 0.0;
/*
Still only 6 candidates total:
- 3 around distortion A
- 3 around distortion B
So this remains much cheaper than the original full Count loop.
*/
[unroll]
for (int k = -1; k <= 1; k++)
{
@@ -173,7 +182,19 @@ void Stripes_float(
);
}
Stripes = stripeMax;
/*
Brutal final shaping.
- smoothstep makes weak strokes become visible sooner.
- pow with low exponent pulls mid/low values upward.
- final multiplier forces a strong black graphic result downstream.
*/
stripeMax = smoothstep(0.02, 0.28, stripeMax);
const float HATCH_POWER = 0.38;
const float HATCH_FINAL_BOOST = 2.8;
Stripes = saturate(pow(stripeMax, HATCH_POWER) * HATCH_FINAL_BOOST);
}
#endif