Results 1 to 2 of 2

Thread: Great Circle Lines on Sphere

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2013

    Great Circle Lines on Sphere


    I am trying to recode the antialiasing chapter 8 of the redbook ed8. It is about how to use the smoothstep function as a lowpass filter, to avoid aliasing.

    As an expample they used a sphere with great circle stripes. They write:
    Using the s texture coordinate to create stripes on a sphere (In (A), the s texture coordinate is used directly as the intensity (gray) value. In (B), a modulus function creates a sawtooth function.
    I hope its ok to post it like this.

    I have trouble finding the right values to feed to the fragment shader. As quoted I tried using just the s texture coordinate (actually I am using the x coordinate of the vertices but this should be the same right?)
    This way I get straight lines from top to bottom with a fixed width. So I tried y/x which leads to this:


    I tried a few multiplications to counter the infinity problem, but failed. I think the problem is something else though, since I can't even get (A) to be rendered.
    I am unsure if the calculation of the fragment color is actually very simple or mathematically more complex. It starts with the gradient. It looks to me as if a logarithm was used. But maybe this is still within the definiton of the authors sense of: "S is used directly as the intensity (gray) value"

    I Would be glad, if someone could give me a hint here. Thanks

    Here is the same example from a different source:

    Here is my fragment shader
    Code :
      #version 430 core
    uniform sampler2D tex;
    in vec2 vs_tex_coord;
    in vec4 vs_vPosition;
    out vec4 color;
    int stripes = 3;
    float sawtooth;
    float triangle;
    float square;
    void main(void) {
        sawtooth = mod((vs_vPosition.y/vs_vPosition.x),1);
        triangle = abs(2.0 * sawtooth - 1.0);
        square = step(0.5, triangle);
        color = vec4(sawtooth, sawtooth, sawtooth, 1);

  2. #2
    Junior Member Newbie
    Join Date
    Jul 2013
    Ok found the solution.
    Had to convert from cartesian coordinates to spherical coordinates.

Similar Threads

  1. Drawing a 3D Sphere with a circle on its surface
    By rnvis0 in forum OpenGL: Advanced Coding
    Replies: 0
    Last Post: 01-14-2019, 07:08 AM
  2. circle with lines
    By Pedrosanchez87 in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 03-09-2017, 01:24 PM
  3. Make sphere move in a circle
    By uberweiss in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 04-21-2010, 12:07 AM
  4. Drawing sphere, circle in OpenGL?
    By in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 06-05-2002, 06:47 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean