PDA

View Full Version : I suggest to replace step() by my softstep() -> soft egdes for lighting and shadowing



toki78
07-11-2014, 03:19 AM
Hi,
I suggest

float softstep(float f,float x,float edge) {
float y = edge - x;
return 1.0 / (1.0 + exp(-f * y));
}


I have an application for this, but I am not allowed to post links here.

Regards
Thorsten Kiefer

Agent D
07-11-2014, 03:46 AM
There is a smoothstep (http://www.opengl.org/sdk/docs/man4/html/smoothstep.xhtml) function since GLSL 130

arekkusu
07-11-2014, 12:44 PM
That man page is wrong; smoothstep() has been there since the very beginning (100, 110 and 120.)

mhagain
07-11-2014, 05:36 PM
...and it's no good unless it's implemented in hardware. Otherwise you may as well just write the function in the OP and use that instead.

Agent D
07-12-2014, 02:00 AM
...and it's no good unless it's implemented in hardware. Otherwise you may as well just write the function in the OP and use that instead.
So if you use the smoothstep function you have a chance that some implementations support it in hardware and some others at least generate efficient
code as it is a builtin compiler intrinsic in their GLSL compiler, but when you use your own function it will always be implementend in software, which
makes the builtin function more desireable than writing your own.

But IMO that's not the point of the OP. As I understood it, the GLSL step function should be replaced with their smother setep function.

I tried a few combinations of both the "softstep" and smoothstep function above in wxmaxima+gnuplot and I see no problem approximating the behaviour of the former by
using the later.

Therefore I suggested to look at the manpage of the smoothstep function as I thought the OP might not know about it.