# Great Circle Lines on Sphere

• 11-24-2013, 03:50 AM
sektion31
Great Circle Lines on Sphere
Hi,

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:
Quote:

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.
Attachment 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:

Attachment 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: http://www.yaldex.com/open-gl/ch18lev1sec1.html

``` #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); }```