Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4234734
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T02:23:52+00:00 2026-05-21T02:23:52+00:00

How to implement this tunnel like animation in WebGL? Source: http://dvdp.tumblr.com/ See also: How

  • 0

How to implement this tunnel like animation in WebGL?

enter image description here

Source: http://dvdp.tumblr.com/

See also: How to implement this rotating spiral in WebGL?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T02:23:53+00:00Added an answer on May 21, 2026 at 2:23 am

    Well, this was fun. 🙂

    A WebGL demo is available here: http://boblycat.org/~knute/webgl/tunnel/

    (EDIT: no longer available, but I created a ShaderToy version: https://www.shadertoy.com/view/XdKfRD)

    The main algorithm is in the fragment shader. The basic idea is a for loop iterating over the black rings/circles, from large to small, also offsetting the center to produce a tunnel-like effect.

    Given any pixel, we can check if the pixel is close enough to the ring to be a candidate for a black pixel or not. If it is outside the ring, break the loop to avoid seeing smaller rings through the larger ones.

    The distance from the previous (outer) circle is used to “squeeze” the pattern together when rings are close, this helps create the illusion of a 3D surface.

    The wavy pattern of each ring is of course a sine curve. The angle of the pixel (compared to the circle center) is combined with a uniform time parameter to animate the wavy pattern for each ring.

    And finally, there was lots of experimentation with different parameters and transformation functions like pow() to get the result close to the target animation. It’s not perfect, but pretty close.

    The fragment shader code:

    #ifdef GL_ES
    precision highp float;
    #endif
    
    const float PI = 3.14159265358979323846264;
    const float TWOPI = PI*2.0;
    
    const vec4 WHITE = vec4(1.0, 1.0, 1.0, 1.0);
    const vec4 BLACK = vec4(0.0, 0.0, 0.0, 1.0);
    
    const vec2 CENTER = vec2(0.0, 0.0);
    
    const int MAX_RINGS = 30;
    const float RING_DISTANCE = 0.05;
    const float WAVE_COUNT = 60.0;
    const float WAVE_DEPTH = 0.04;
    
    uniform float uTime;
    varying vec2 vPosition;
    
    void main(void) {
        float rot = mod(uTime*0.0006, TWOPI);
        float x = vPosition.x;
        float y = vPosition.y;
    
        bool black = false;
        float prevRingDist = RING_DISTANCE;
        for (int i = 0; i < MAX_RINGS; i++) {
            vec2 center = vec2(0.0, 0.7 - RING_DISTANCE * float(i)*1.2);
            float radius = 0.5 + RING_DISTANCE / (pow(float(i+5), 1.1)*0.006);
            float dist = distance(center, vPosition);
            dist = pow(dist, 0.3);
            float ringDist = abs(dist-radius);
            if (ringDist < RING_DISTANCE*prevRingDist*7.0) {
                float angle = atan(y - center.y, x - center.x);
                float thickness = 1.1 * abs(dist - radius) / prevRingDist;
                float depthFactor = WAVE_DEPTH * sin((angle+rot*radius) * WAVE_COUNT);
                if (dist > radius) {
                    black = (thickness < RING_DISTANCE * 5.0 - depthFactor * 2.0);
                }
                else {
                    black = (thickness < RING_DISTANCE * 5.0 + depthFactor);
                }
                break;
            }
            if (dist > radius) break;
            prevRingDist = ringDist;
        }
    
        gl_FragColor = black ? BLACK : WHITE;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to implement this JQuery ImageBubbles that I found here: http://www.dynamicdrive.com/dynamicindex4/imagebubbles.htm However,
I'm trying to implement this project: http://img7.imagebanana.com/img/cnb46ti2/relationships.png I want to let view the skills
I am trying to implement this multi-touch android tutorial http://www.zdnet.com/blog/burnette/how-to-use-multi-touch-in-android-2-part-5-implementing-the-drag-gesture/1789?tag=mantle_skin;content I am stuck in
I'm trying to implement this: from https://docs.google.com/viewer?url=http://www.tinaja.com/glib/bezdist.pdf&pli=1 The following BASIC program uses the method
How do I implement this method (see below)? I'm new to Objective-C and I'm
I'm trying to implement this pattern in my WinForms application (I don't like it,
I am trying to implement this demo on my local machine. http://bit.ly/4g4o1r I have
I'm trying to implement this protocol: http://en.wikipedia.org/wiki/Chord_(peer-to-peer ) What i understood from it is
I've tried to implement this CSS3 slideshow on my site ( http://www.designmadeingermany.de/slideshow/ ) But
I would like to implement this in Linq to SQL: select * from (

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.