Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Shared vertices or not for primitives


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
8 replies to this topic

#1 thecheeselover   Members   -  Reputation: 330

Like
0Likes
Like

Posted 24 June 2014 - 08:56 AM

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!

Sponsor:

#2 Wh0p   Members   -  Reputation: 340

Like
1Likes
Like

Posted 24 June 2014 - 11:37 AM

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.



#3 thecheeselover   Members   -  Reputation: 330

Like
0Likes
Like

Posted 24 June 2014 - 05:14 PM


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!

#4 L. Spiro   Crossbones+   -  Reputation: 14391

Like
1Likes
Like

Posted 24 June 2014 - 07:44 PM

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


Edited by L. Spiro, 24 June 2014 - 07:45 PM.

It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#5 Hodgman   Moderators   -  Reputation: 31926

Like
0Likes
Like

Posted 25 June 2014 - 12:31 AM

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



#6 thecheeselover   Members   -  Reputation: 330

Like
0Likes
Like

Posted 25 June 2014 - 07:52 AM

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).


Edited by thecheeselover, 25 June 2014 - 08:00 AM.

Hide yo cheese! Hide yo wife!

#7 Wh0p   Members   -  Reputation: 340

Like
1Likes
Like

Posted 25 June 2014 - 09:23 AM

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.



#8 thecheeselover   Members   -  Reputation: 330

Like
0Likes
Like

Posted 28 June 2014 - 07:24 PM

Ok thanks everyone! Now I understand! :)


Hide yo cheese! Hide yo wife!

#9 JohnnyCode   Members   -  Reputation: 312

Like
0Likes
Like

Posted 29 June 2014 - 07:21 PM

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






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS