Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: Wave/Ripple Fragment Shader Working but With Strange Side-Effects

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member Newbie
    Join Date
    Oct 2017

    Angry Wave/Ripple Fragment Shader Working but With Strange Side-Effects


    Hopefully this is the right place to post for this problem. I'm not sure if the problem is OpenGL or the shader(s), which is why I'm here.

    I want to incorporate a ShaderToy ripple/wave effect into my main C++ windows program:

    I slightly modified the fragment shader code to work under C++ with glew/freeglut and also removed mouse and image related code (image not needed for testing the problem). I'm using a basic "gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;" vertex shader.

    I borrowed and modified / simplified a multi-pass shader tester program in C++ from here:

    I've attached all the code I am using. I am using the latest freeglut and glew. I'm developing / running this on Windows 8.1 x64.

    The shader shows up and works under the ShaderTest program but has some strangeness to it. I'm not sure if this is a problem with my OpenGL approach or some kind of problem with running under OpenGL, rather than WebGL in the browser. The browser version runs fine for me.

    Strangeness Notes
    The shader effect creates a ripple and from that ripple the waves push out. In the WebGL version in the browser, this works perfectly. The ripple and wave generation will go on forever.

    Under the C++ test program, ripples are created, but also create ripple waves inside existing ripples (inner ripples), eventually creating an infinite loop of waves, which causes "black holes" to be generated over time. The black holes will consume the screen as time passes.

    When the shader runs in a full-screen quad, the "waves" will bounce off of the joined-triangles seem (a quad is two triangles joined).

    When the shader runs in an oversized triangle, the waves work correctly, but the inside ripples problem still happens.

    What I've Tried
    I've been at this problem for about a week now, so it's hard to detail everything I've tried. ShaderToy describes their buffer with linear 32-bit floating points. It seems that using that format for textures is correct.

    If I try using 16-bit float, or RBGA with unsigned byte, the side-effects get lesser and lesser, but never go away fully. The color quality of the effect obviously goes to crap, though, so it doesn't really help.

    With regards to textures and FBOs, I've tried many different approaches. Dual-FBOs, dual color-attachments with a single FBO, etc. Nothing seems to work. I have to use at least the one FBO on the buffer channel, it seems.

    The two problems I'm trying to solve are:
    1: inner ripple / infinite waves
    2: quad seem reflection

    My guesses: projection or shader coordinates precision issue (or both).

    I've attached the two source files and the vert/frag shaders. Screenshots in 2nd post.

    Any help much appreciated.


    Last edited by EloStorm; 10-05-2017 at 08:08 PM.

Posting Permissions

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