Jump to content
  • Advertisement

Archived

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

Kronuz

Multiple tiles in one texture.

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

In DirectX8, if we want to have a texture tiled, that''s easy, we only need to enter the uv texture coordinates as a range above 1... but what about if we want to tile just a part of the texture and not all of it? To say, let''s think about a "tile set" or an array of tiles contained in one texture, loaded from a single bitmap. I have been trying to do this, but since I''m new to DirectX I haven''t been able to figure this out. Should I use a texture transformation matrix or what?

Share this post


Link to post
Share on other sites
Advertisement
That''s easy. For instance if you just want a quarter of your source texture to cover a tile - say the upper right quarter - use:

(u, v)
(0.5f, 0.0f) - (1.0f, 0.0f)
(0.5f, 0.5f) - (1.0f, 0.5f)

Share this post


Link to post
Share on other sites
I see what you are saying.... but that way I would only get that part of the texture rendered just once on the primitive, but what I need is to have that part of the texture tiled (rendered several times, or wraped) on the primitive.

Let's say we have a bmp file with several images a "tile set" or tile array (each number irepresents a image or sprite; the image 1 and 3 are 30x40 pixeles; the x represents not usable or empty space):

111223333
111223333
111222333
1114444xx
5554444xx
5554444xx

After loading the bitmap we end up with a texture like the next one (the asterisks represent empty space left there by DirectX to make the texture a 2^n texture sqare)

111223333*
111223333*
111222333*
1114444xx*
5554444xx*
5554444xx*
**********
**********
**********
**********

What I want is to be able to tile a single image (a part of the texture) to a primitive. For example what should I do to wrap image 4 in a rectangle like this:

4444 4444 4444 4444 4444
4444 4444 4444 4444 4444
4444 4444 4444 4444 4444
4444 4444 4444 4444 4444

4444 4444 4444 4444 4444
4444 4444 4444 4444 4444
4444 4444 4444 4444 4444
4444 4444 4444 4444 4444

I was thinking about using the hardware to do this tiling, but without having a separate texture for each tile in the "tile set". I was told that it might be possible using pixel shaders, but I don't know how to... besides I think there should be an easier, better way to do it.

there is an article that explains how this was possible a long time ago (1997) using Direct3D retained mode function CreateWarp
The article is: "Texture Wrapping Simplified" at

http://msdn.microsoft.com/archive/en-us/dnardir3d/html/msdn_wrapfun.asp

Check under the Texture origin (ou, ov) parameter.




[edited by - Kronuz on May 26, 2003 2:19:04 PM]

Share this post


Link to post
Share on other sites
"If you haven''t read, don''t bother asking." -Me

So go read an article/tutorial about texturemapping/texturecoordinates and I''m sure you know how to find one.

.lick

Share this post


Link to post
Share on other sites
Pipo DeClown, I have been reading all I can about this matter, I wouldn't be asking if I hadn't. Do you really think everybody is that idiot to ask something before researching a little? I could bet you didn't even "read" the question, since for what I've seen and read, there is no simple way found on "tutorials" explaining how to accomplish this kind of tiling.

[edited by - Kronuz on May 26, 2003 2:41:16 PM]

Share this post


Link to post
Share on other sites
I think I understand what you mean. The wrap addressing mode is the normal way for this sort of thing. However you want to tile just a part of a texture within the same primitive if I understand correctly? - Sorry don''t know if it is possible to do that. Would be interesting to know though.

Share this post


Link to post
Share on other sites
quote:
Original post by Kronuz
Pipo DeClown, I have been reading all I can about this matter, I wouldn''t be asking if I hadn''t. Do you really think everybody is that idiot to ask something before researching a little? I could bet you didn''t even "read" the question, since for what I''ve seen and read, there is no simple way found on "tutorials" explaining how to accomplish this kind of tiling.

[edited by - Kronuz on May 26, 2003 2:41:16 PM]


If you have really read about it, you would understand that the whole picture in UV equals 1.0 1.0. If you take both values less than 1.0 would mean its a point somewhere inside the picture.
If you have 3 vertices(triangle) and all of the UV-values are inside of the picture, you WONT get the hwole picture?
Get it? No? Read it again.

.lick

Share this post


Link to post
Share on other sites
Pipo DeClown, it looks you're the one who don't get it, read the question again, and check the example I posted. I don't just want to show a part of the "picture", I want to tile (wrap) that part of the picture in a primitive.


[edited by - Kronuz on May 26, 2003 3:03:19 PM]

Share this post


Link to post
Share on other sites
Hi Kronuz,

I had the same problem and I could find only one solution.
I had to use triangle list (no strip), and so it is possible to calculate the right UV coordinates for each triangle. So that means that the size of the triangle must be smaller (but sure not bigger) than the bitmap tile!!!! All the UV coordinates of the triangle must be 0<=UV<=1 !!
Calculating the right UV coordinates one part of a bitmap can be tiled. Not a beautiful solution, and perhaps can not be used in every case, but I really could not find better solution.

Share this post


Link to post
Share on other sites
juhaszt, I think I get it now... the thing is to subdivide the primitive in several triangles to texture each right?

[edited by - Kronuz on May 26, 2003 8:33:22 PM]

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!