Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Zipster

Questions regarding buffers and texturing

This topic is 5218 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

Just to get it out of the way, I''m using managed DirectX with C#. My map data consists of a unique set of vertexes that are shared by all the faces in the level. This leads naturally to a combination of vertex and index buffers for rendering. I simply extract the native map vertex, create an equivalent fixed-format vertex object, and load it into the vertex buffer. However, the map data also specified texture coordinates on a per face basis, while in Direct3D texture coordinates are done per vertex. My question is this. If several faces sharing the same vertexes have completely different texture coordinates, does this mean I have to end up duplicating the shared vertexes just for the sake of different texture coordinates, or does Direct3D have some sort of special provisions for this? Would I have to write my own vertex shader if I don''t want to duplicate vertexes? It would defeat the whole purpose of using the vertex and index buffers if they had to be duplicated, but it seems silly to me that I''d have to write my own shader otherwise... Also, a question a texture coordinates. It''s easy to apply a texture at a 1x scale or above, but how would I set the texture coordinates to have a scale of, say 0.5x (or anything less than 1x)? From what I know, the coords are clamped between 0.0 and 1.0. Would I have to break the face down into smaller primitives in order to have a repeating texture (the result of < 1x scale)? Thanks for any replies!

Share this post


Link to post
Share on other sites
Advertisement
Are you asking if you have a "part" of a larger texture that you want to duplicate do you have to break it down to a lower number on a new surface for instance so that you can replicate it at the scale of 1.0? (stating the max is 1.0 or higher).

I know you can "blit" a section multiple times, but to the best of my knowledge the answer is yes, you would have to create another smaller texture.

You could also write a function that would calculate the information(its an odd formula) but not extensively wonderful.

Fact is, you can''t do this by just using the texture you have. You have to split it, or right some "math code" to get it out.

There is another post on this as well and they all state the same as this.

Share this post


Link to post
Share on other sites
I''m not trying to extract portions of the texture, I''m trying to tile the texture several times over the face. However, since texture coordinates are clamped from 0.0 to 1.0, I can''t see how I''d do this. If I could specify 0.0 on one end and 2.0 on the other, I would get 0.5x scale, 0.0-4.0 is 0.25x scale, etc.

Share this post


Link to post
Share on other sites
Hmmm I just re-read what you said, but I do not notice that my "scale" changes. I merel notice that my bitmap that "used" to be stretched like crazy starts to fit properly. Meaning if I had 4 quads in a row with the same tile and then I turn it from 4 quads to 1 giant quad as long a proportionally the larger quad is equal to 4 smaller quads, then repeating the quad 4 times doesn't appear to scale it to .25 to me. Only if I change the size of the quad of course it does.

Maybe I am just crazy but I am doing exactly what you asked, for exactly the reason I describe above, and as long as my texture is square and my quads are it seems ok to me.

[edited by - 3dxd on June 8, 2004 1:40:50 AM]

Share this post


Link to post
Share on other sites
What you describe as "stretching" can also be called scaling, only in one dimension though. Hopefully I can rephrase my question is as simple terms as possible: is there any way to shrink the scale of the texture using only texture coordinates, without changing the size of the triangle? It's possible to increase the scale, using "stretching," by giving the upper left corner of the quad UV coordinate (0,0) and the lower right (0.25,0.25), which will induce a 4x scale. The pattern is that whatever scale you want, the texture coordinate is the inverse. However, the inverse of numbers less than 1, are greater than 1, and I don't believe texture coordinates can be larger than 1.

Anyway, that part doesn't really matter so much, I'll figure that out later. What's really important is my first question.

EDIT: I found what I needed regarding the scaling. If I use the wrap texture addressing mode, I can specify texture coordinates larger than 1.

[edited by - Zipster on June 8, 2004 2:34:30 AM]

Share this post


Link to post
Share on other sites
Nevermind, I''ve figured everything out. Here''s a brief summary for anything who runs into this problem in the future:

1) If you want to texture on a per-face basis, you need to use unique vertexes for different texture coordinates.

2) Use wrap texture addressing mode for texture coordinates larger than 1.0.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!