Jump to content
  • Advertisement
Sign in to follow this  
mlt

Plotting normals on a sphere?

This topic is 3457 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have created a sphere as a triangular mesh which I render with my vertex and fragment shaders. But is there some way to plot the normals for each vertex in the vertex program as small arrows on the sphere?

Share this post


Link to post
Share on other sites
Advertisement
But how do I plot it as an arrow pointing from the sphere surface? In the fragment program its only possible to draw the color of a fragment/pixel. I don't see how I can draw and arrow for each fragment.

Share this post


Link to post
Share on other sites
Oh, yeah that would be tricky, and probably isn't the best way to go about it in the first place. Maybe someone will have some ideas.

Share this post


Link to post
Share on other sites
In my engine, each object create function (disk, tube, cone, sphere, etc) supports an options argument. Three bits in the options tell the routine to draw east/north/zenith vectors (in my lingo) or "tangent", "bitangent", "normal" vectors (in more common lingo) at each vertex.

My engine draws each east vector as a red-line, each north vector as a green-line, and each zenith-vector as a blue-line. This makes totally clear which directions the surface vectors point.

I guess my main point is, they look best when drawn with lines, not triangles. Sure, some people create nice fancy smooth-shaded solid arrows, but they are FAR too large where vertices are close together, and provide zero extra information.

Assuming your code supports object hierarchies (objects attached to objects at "pivot points"), you can attach one "lines object" for each color lines (as I do), or only one "lines object" and set the colors separately.

Another reason lines look great is - lines are "emissive" (in my engine). That is, the shader does not compute colors for lines or points based upon lighting or texture-maps or normal-maps - right at the top of the fragment shader code is a line that tests one bit, sees the object is "emissive" and simply sets the final color equal to the vertex color... fragment shader done.

Hope this helps. The following is an old, crude image I had lying around. It is not that great (due to solid red/green/blue lights flooding the scene), but if you look close, you can see the vectors on the closer surfaces.


Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!