Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411430 Posts in 69363 Topics- by 58416 Members - Latest Member: JamesAGreen

April 19, 2024, 07:02:30 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Sharing vertices - UV coordinates?
Pages: [1]
Print
Author Topic: Sharing vertices - UV coordinates?  (Read 707 times)
Eendhoorn
Level 6
*

Quak


View Profile
« on: November 07, 2014, 07:25:40 PM »

Somehow there was nothing to find about this on the interwebz. I'm trying to build some tiled geometry.



Behold this amazing drawing. The top method shares vertices 1 and 2 for the second square. While the bototm method just creates 2 additional vertices for the second square.

Saving on vertices obviously seems like the better way to go in the long run. I also want to displace the top vertices to create some height in a 2D perspective.
Without sharing the vertices I would have to move both vertex 1 and 4 to lift the center up, which just feels kind of messy.

However, with the bottom method I cannot figure out how I can tile the second square, since it hold information from the first square's UV's.

Here you can sea I can select the appropriate tile just fine for the first square, but not for the second.

Maybe I'm missing something on how to properly UV, can anyone enlighten me?
Logged

ThemsAllTook
Administrator
Level 10
******



View Profile WWW
« Reply #1 on: November 07, 2014, 07:38:09 PM »

The answer to this might differ depending on your tool, graphics API, and what you're specifically doing with the vertices at this stage. I think the most general answer is to use separate vertices when you need different UVs or other information, even if their position is the same. However, in some situations it might be possible to store a list of unique positions, and assign different UVs to different instances of each. What are the specifics of your setup?
Logged

BorisTheBrave
Level 10
*****


View Profile WWW
« Reply #2 on: November 08, 2014, 03:46:32 AM »

Yep, you fully share vertices unless they have all attributes the same. But you can share some of your vertices twice as they are used by both triangles making up the square tile.

I wouldn't bother with sharing in your case, tiles this big are not likely to be a performance issue for the GPU, and the code is actually simpler without sharing.

If you insisted on sharing, the alternative is to have some non straightforward mapping between UVs and tiles. For example, you could simply record the x-y position of the tiles as the UV, and then in the shader look up that, say, the (5,3) tile reads from (0.3, 0.Cool in your tile atlas.
Logged
Eendhoorn
Level 6
*

Quak


View Profile
« Reply #3 on: November 08, 2014, 11:53:44 AM »

The answer to this might differ depending on your tool, graphics API, and what you're specifically doing with the vertices at this stage. I think the most general answer is to use separate vertices when you need different UVs or other information, even if their position is the same. However, in some situations it might be possible to store a list of unique positions, and assign different UVs to different instances of each. What are the specifics of your setup?
I'm using Unity3D.

Yep, you fully share vertices unless they have all attributes the same. But you can share some of your vertices twice as they are used by both triangles making up the square tile.

I wouldn't bother with sharing in your case, tiles this big are not likely to be a performance issue for the GPU, and the code is actually simpler without sharing.

If you insisted on sharing, the alternative is to have some non straightforward mapping between UVs and tiles. For example, you could simply record the x-y position of the tiles as the UV, and then in the shader look up that, say, the (5,3) tile reads from (0.3, 0.Cool in your tile atlas.
I have actually recently gotten into shaders and the solution you're proposing makes sense, but indeed sounds like too much trouble for what's it worth.

Thanks for the clear answers, I'll just go with duplicate vertices for simplicity's sake.
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic