Skip to main content
gamedev.net
🔒 Locked

Texturing

Started by Squirell Apr 25, 2004 at 9:59 PM 14 replies 700+ views
Original Post
Squirell
Squirell
Im having problems texturing my images. I can easily do it with vertex buffers. Setting the coordinates blah blah blah. But when i use index buffers i get confused. The same vertex needs different texture cordinates. So how do i texture when im using index buffers?
Raloth
Raloth
You will need to make a new vertex for every vertex with a different texture coordinate. I have the same problem and I can''t figure out a way around it. I could make my terrain engine so much more efficient . (If only I could make the index buffer apply to only one vertex stream...)
____________________________________________________________AAAAA: American Association Against Adobe AcrobatYou know you hate PDFs...
de_matt
de_matt
So unless you can sort out a way to make the index buffer apply to only one vb stream, your best sticking with a vertex buffer.
Squirell
Squirell
Then wats the point of having an index buffer if you cant texture it?
Fingers_
Fingers_
It *is* efficient to duplicate the vertices when you need different texture coordinates. When the UV, color, normal and xyz coordinates are stored together it''s much easier for the GPU than if they were stored in separate locations in VRAM. (Reading sequentially is faster than jumping around)
nibmike
nibmike
one of the tradeoffs with using index buffers is in fact the loss of control over texturing and normals. There are work-arounds, but you''d use index buffers when you''re not so fussy over having textures and having realistic lighting.
Wheel is spinning... but the hamster is dead
Squirell
Squirell
But in the directx tutorials at andypike, in tutorial 8 he creates a really simple terrain using index buffers and textures it. How does he do it?
Nik02
Nik02
Using index buffers and texturing are not, by any means, mutually exclusive techniques.
Why do you hold the necessary data duplication issue in such high regard when it comes to difficulty? It is not really that complex, you know

Kind rgds,
-Nik

EDIT: My point being - while index buffers are used to reduce data duplication, one can still duplicate the vertex data if necessary (and in case of different texture coordinates, the vertices actually are different).

[edited by - Nik02 on April 27, 2004 12:18:15 PM]
Niko Suni
Squirell
Squirell
Alright, how do I do that then. Is there any good tutorials around on it?
Nik02
Nik02
I recommend that you study the arts of texturing and using indices separately and thoroughly. One of them does not, in any way, prevent or even make very difficult to use the other.
Try to understand how geometry indexing really works instead of copy-pasting the code from some tutorial; when you do, this will be as clear as morning dew

-Nik

PS. Sorry about the lack of links...
Niko Suni
Squirell
Squirell
I understand what your saying. And i do understand indexing. So basically i have to create a seperate vertex to use for each different texture coordinate right? Since I''m basically rendering a 10x10 array of textured squares I need 4 texture coordiantes for each vertex (except for edges of course). This means i need four different vertices right?
Nik02
Nik02
If you need to have discontinuous texture coordinates, then you have to use multiple vertices in the same position. They are not the same vertices, despite the exact same position - the texcoords make them different.

I''m sorry I can''t explain this more intuitively; to me, it just made sense one day in the past.

I could prepare a graphic explanation, if you want, but I''m quite busy with my studio. However, I''m glad to help if I can

Kind rgds,
-Nik
Niko Suni
Ataru
Ataru
Here's an easy way to explain it.

Say you have one texture and want to stretch it

you do it like this

x----x----x
|......|......|
|......|......|
x----x----x

Each x is one vertex, and has one texture coordinate. Along X this would be (0, 0.5 and 1)

So if you are going to have this kind of model, one texture wrapped over several polygons, you don't duplicate anything.

Now say you you have two textures, you will have to map it like so:

x----xx----x
|......||......|
|......||......|
x----xx----x

(it's so hard to do ascii here)

Thhe middle is actually stuck together, but it illustrates the point.

Indexing is great for terrains, since you are stretching one big texture over a grid of vertices. It's awfulf for cubes, since you have to make a copy of every vertex.

However, most complicated geometry is the former rather than the latter. If you look at quake models for instance, they all use one texture, and each vertex has a unique coordinate. The texture is literelay wrapped on it.

People realize you have to make copies of vertices when indexing a cube, but that is literaly the worst case scneario, usually, there are big gains to be made by indexing, even if you have to make some copies.

[edited by - ataru on April 28, 2004 6:05:33 PM]

[edited by - ataru on April 28, 2004 6:06:07 PM]
Squirell
Squirell
quote:
Original post by Ataru

Indexing is great for terrains, since you are stretching one big texture over a grid of vertices.




Ohhhh, so if I have a 10x10 array of squares for the terrain I set the top left vertex to (0, 0), middle square vertex to like (0.5, 0.5), bottom right vertex (1, 1), etc?



[edited by - Squirell on April 29, 2004 9:40:29 AM]
Ataru
Ataru
Exactly.
Squirell
Squirell
Thanks so much

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.