Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

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

  1. #1
    Newbie Newbie
    Join Date
    Jul 2014
    Posts
    1

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

    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

  2. #2
    Junior Member Regular Contributor Agent D's Avatar
    Join Date
    Sep 2011
    Location
    Innsbruck, Austria
    Posts
    150
    There is a smoothstep function since GLSL 130
    Last edited by Agent D; 07-11-2014 at 01:10 PM.

  3. #3
    Advanced Member Frequent Contributor arekkusu's Avatar
    Join Date
    Nov 2003
    Posts
    783
    That man page is wrong; smoothstep() has been there since the very beginning (100, 110 and 120.)

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,212
    ...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.

  5. #5
    Junior Member Regular Contributor Agent D's Avatar
    Join Date
    Sep 2011
    Location
    Innsbruck, Austria
    Posts
    150
    Quote Originally Posted by mhagain View Post
    ...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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •