smooth step, but only for low end?

Started by Dune, June 10, 2018, 03:51:29 AM

Previous topic - Next topic

Dune

I need to 'soft clamp' the lows of unclamped gradient only because I need the dune displacement not to go negative (no clamping), but smooth step is doing both low and high end (smooth step), and clamping either in the fractal or separately is hard (clamp 0). I can't get soft minimum or soft maximum to work for this either.
Is there a way to just smooth step the low end of a greyscale?
If not, I will file a feature request, as I come across this regularly.

cyphyr

I'm probably missing the point here but can't you just add a displacement offset of half the amplitude... ? That should keep everything above zero.
www.richardfraservfx.com
https://www.facebook.com/RichardFraserVFX/
/|\

Ryzen 9 5950X OC@4Ghz, 64Gb (TG4 benchmark 4:13)

WAS

Could you use surface shaders and a mask to define lows, apply offset or clamp and merge with the other half of your dunes unmodified, but also masked invertedly? Offsetting the terrain sounds easier but may change how other things works.

Dune

Adding an offset would likely raise the whole thing (I work with the colors, not the displacements, but even then I think it would, and I want to keep the beaches low). But actually a plain distribution/surface shader with slight fuzz and min alti would work here. Sometimes the obvious is invisible  :P
But I'd still like a one-sided smooth 'clamp' for other uses.

Thanks.

WAS

Quote from: Dune on June 11, 2018, 01:55:10 AM
But I'd still like a one-sided smooth 'clamp' for other uses.

Thanks.

Yes That would be nice.

On second thought, couldn't you use a colour adjust, and clamp either side, black or white? By default both will be clamped.

Dune

I'm still bothered by this, so here's a series of experiments, none of which works. Some even work in strange ways. Water level is at -5.8m. River at right, dunes I need on the left part without the holes in ground.

Setting a minimum altitude for unclamped displacement doesn't work either (it wasn't as simple as that), as the negative displacement values are starting above water level (which you allow) but extend downward. So that's off.

I tried multiplying by a black (fuzzy/non-fuzzy) distribution shader with a minimum altitude, which (I'd say) would blacken the unclamped low blacks, thus cancelling those negative displacements out. Apparently not. I added a white before, just to make sure the rest is still present. But with that white off, it's just annihilating every 'displacement color'.

Distribution shader, even without any restriction seems to smooth both top and low end, strangely.

Btw. color adjust is also a hard clamp just like in pf's, and that's exactly what I don't want. I want a smooth low end only and and open unrestricted top end.

I finally used another approach, which works, but still want to see if there's a way to get this to work.

So any ideas are welcome.

Hetzen

Hey Ulco. If you're using PF displacements, then you could convert with a Displacement to Scaler, then divide by your PF's displacement value to pull the numbers into a -1 to 1 range, then use a Bias Scaler with a lower than 0.5 value to curve in the lower range. This will also clamp out anything in the negative. Then multiply by your division number to bring the numbers back into your displacement range, then use a displacement shade to re-apply.

Dune

Ah, that sounds like a good solution. Thanks Jon! I've now surpassed the problem, but I'll surely try. A simple 'smooth 0 clamp' would still be interesting to have.

Matt

Soft Maximum should work. Set the second input to 0 and experiment with the softness value.

Matt
Just because milk is white doesn't mean that clouds are made of milk.

Dune

Thanks, Matt. Sounds a bit counterintuitive, as I need a soft minimum, but I'll have another go.

Matt

#10
Yeah, for this particular use case - clamping an input variable to a constant - it may seem unintuitively named. But it's named this way because it returns the maximum (greater) of two numbers, and it would defy mathematical convention to call it minimum.

Matt
Just because milk is white doesn't mean that clouds are made of milk.

Dune

Thanks for explaining. It makes sense now  :)