Shared vertices or not for primitives

Started by
7 comments, last by JohnnyCode 9 years, 9 months ago

Hello,

I was about to create a some classes to create primitives in order to help me with debugging. However, I don't know if each primitive should share its vertices. For example, a cube should not share its vertices because the normals would be inadequate for lighting and the uv coordinates wouldn't fit for a cubemap. However, for a sphere the normals would be better with shared vertices but what about the uv's? Would it work or should I not share the vertices for a sphere and instead calculate the normals as if they were shared?

Thank you! :)

Hide yo cheese! Hide yo wife!

Advertisement

I don't see any problem with using texture coordinates the way you described, although it greatly depends on how you do the mapping of your texture coordinates.

When using a spheremap you could assign textcoord for each vertex just like you described, no need for dublicating any vertices.

If you go ahead an try to project a rectangular texture (or other more fancy things) onto the sphere, you have to dublicate the "top" and "bootom" of the sphere, where you have that triangle fan like structure.

Hope that answers your question.


If you go ahead an try to project a rectangular texture (or other more fancy things) onto the sphere, you have to dublicate the "top" and "bootom" of the sphere, where you have that triangle fan like structure.

What about the sides? If one vertex reaches the end of the texture on the X axis how will it go back to the beginning?

Hide yo cheese! Hide yo wife!

Texture coordinates, normals, etc., are all part of the vertex information.

When 2 vertices (including all of this data) are exactly the same they should be shared. It is that simple.

The same vertex should never appear twice in a vertex buffer.

If 2 vertices have the same position but different normals, then by definition they are not the same vertex and cannot be shared.

L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

What are these debug shapes used for? Do they even need uv's?

What are these debug shapes used for? Do they even need uv's?

Yes they need uv's because I'm learning GLSL and testing shaders.

And I'm still confused. I have a rectangular map that I want to apply to a sphere. How could the vertices that are at the beginning and the end of the texture in uv coordinates work normally, and by working normally I mean making a beautiful sphere. If a vertex at (0.9,0) (in uv's) makes a triangle with a random vertex and the one with (0,0) the texels applied to the triangle will cover the whole texture on the X axis instead of making a continuous texture mapping, i.e. (-0.1,0) to (0,0).

Hide yo cheese! Hide yo wife!

by working normally I mean making a beautiful sphere

When applying a rectangular texture to a sphere you always will suffer certain deformation of the image you are texturing.

I don't know the exact representation of your sphere but I will just guess, that it consists of "stacks and slices" (Like starting with one vertex at the bottom and then creating concentric circles around an axis with first growing and then shrinking radii).

So lets just look at the body of the sphere (excluding the start and end points) the only thing you have to take care of here are the vertices located at the fissure points (the points where the UVs (0, t) and (1, t) meet). Since they have the same position and normal but different UVs you have to save 2 vertices here (like L. Spiro described). Note that the image will be interpolated to fit the sphere (just like the opposite, that is happening when you try to draw a world map onto a rectangular area the image is stretched).

For the top and bottom vertices you might want to save them multiple times so that each face can address its own vertex (you would then have number of slices times vertices with the same position and normal but different UVs for the top or the bottom vertice).

If its for learning just test around and you'll find your way.

Maybe try to texture an image that looks like this one: http://www.mediavr.com/belmorepark1left.jpg there the textured image would look a little nicer, because the image itself is streched beforehand.

hopefully i am not further confusing you.

Ok thanks everyone! Now I understand! :)

Hide yo cheese! Hide yo wife!

a vertex is a redundant vertex only if its entire attributes are equal to other one.... as normals, texture coordinates, colors, or weights, you name it, only if a vertex is enterily redundant, it can get reindexed. Else how you have to establish the unique vertex

This topic is closed to new replies.

Advertisement