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 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.
    Click image for larger version. 

Name:	Unbenannt2.jpg 
Views:	1087 
Size:	8.6 KB 
ID:	1188
    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:

    Click image for larger version. 

Name:	Unbenannt.jpg 
Views:	171 
Size:	13.3 KB 
ID:	1187

    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);
    Last edited by sektion31; 11-24-2013 at 02:21 PM.

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

Posting Permissions

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