The mystical teapot (beginner question)

Hi all,

I’m currently learning the basics of GLSL, following the lighthouse3d tutorials. One of the very first shaders presented is a flatten (vertex) shader, where every incoming vertex’s z value is set to 0.0 before transforming it. Like this:

void main()
{
   vec4 v = vec4(gl_Vertex);
   v.z = 0.0;
   gl_Position = gl_ModelViewProjectionMatrix * v;
}

The result ought to be obejects that are projected on the xy-plane. This works when I draw a quad, or a glutSolidSphere. However, when I a draw a glutSolidTeapot, somehow that one is flattened
in the y-direction, or projected on the xz-plane.

The source I downloaded from lighthouse3d had the same effect so its not some side effect from my code I think. Any toughts on this one? I’m very curious to why the teapot behaves differently.

Thanks for reading,
groovemaster

It is possible that the theapot geometry has its object space oriented differently and the glutSolidTeapot uses the modelview matrix to orient the teapot to its final orientation.

I think the teapot has an internal transformation into the z-direction in the Windows implementation of glut…I had the same problem too.

Ah, I see, that would explain why my results differ from those in the tutorial. I guess there is no other way than flattening in the y-direction to emulate the tutorial stuff then. Thanks for your quick reactions!

I can confirm that the teapot is indeed mystical on Windows (lid up the y-axis). Is it really different on other systems?

I guess there is no other way than flattening in the y-direction to emulate the tutorial stuff then.
You could apply your own transformations to align it along the axis of your choosing. Personally, I like having z pointing up (if anyone cares).

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.