- Home /
Question by
jamesflowerdew · Apr 15, 2015 at 04:52 PM ·
shadersnumbers
up the contrast (0-1) in shader code
After lots of searching I wrote my own method of upping the contrast of 0 to 1 numbers in shaders to sharpen gradients. It's dead simple but I'm pretty sure there'll be an inbuilt optimised version, and searching nvidia plain didn't work (I probably just need the correct term).
Here is my version.
half UpContrast(float nNum,float nCont){//nCont should be > 0
return saturate(nNum+((nNum-.5)*nCont));
}
You'd use it like this:
blend=UpContrast(blend,howmuch);
Is there a "proper" one?
I'd been using
Pow (number,value);
but it has the unfortunate side effect of always shrinking the number unless it's exactly 1. It can also go kind of crazy if your value is higher or lower than (0>1)
Comment