Archived

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

steg

Multi-texturing

Recommended Posts

Hi, I have a cube and want to place a different texture on each face - 6 textures (using for skyboxing), what''s the best/preferred way of doing this (I guess you load all the textures in at the beginning ?). Kind regards, sTeVe

Share this post


Link to post
Share on other sites
For one thing, that isn''t multitexturing. Multitexturing is blending two or more textures on one face. But anyway. The way I created a skybox is to actually just use an .x file (try skybox3.x in the media directory of the DX8 SDK) and change the texture names in the actual .x file (open it in notepad). Then load the skybox into your engine, set its world matrix to the camera''s view matrix, and poof....you''ve got a skybox.

Ryan Buhr
Trifinity Interactive, LLC.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Hi,
Then how''s about *real* multitexturing?
I''ve been playing around with it to render Quake3-Bsp but it doesnt work.(Though in OpenGL, a piece of cake)

Can anyone give me a simple start on this?

Share this post


Link to post
Share on other sites
Thanks,

I didn''t know about the .x idea. Although I think I''ll stay with the cube method. Again, what I want to do is put a different texture on each face, my thinking is that I will have to load the six textures into memory using D3DXCreateTextureFromFileA and use the texture pointers in the rendering stage - is this correct ? I don''t want to be loading the textures in the rendering stage.

Any help is much appreciated.

sTeVe

Share this post


Link to post
Share on other sites
Just create an array of textures, load each one in and then in your render function, set the right texture before drawing each face.

    
// put this in your header

LPDIRECT3DTEXTURE8 pFaceTex[6]; // The array for the textures


// Then when rendering

...
pD3DDevice->SetTexture(0, pFaceTex[0]);
//Draw the first face here

pD3DDevice->SetTexture(0, pFaceTex[1]);
//Draw the second face here, and so on...



hopefully that makes sense. Just load each of your six bitmaps into the six pFaceTex elements, and you should be good.

edit: noiticed there was a problem in the code.

Edited by - Anozireth on January 15, 2002 2:31:11 AM

Share this post


Link to post
Share on other sites
Thanks Anozireth,

I thought this was the answer, although I wasn''t sure if you was limited to a certain amount of textures you can have ?

One more question, could I not have these 6 textures in one big bitmap and index into it - although I don''t know how I''d do this as texture coordinates are from 0,0 to 1,1 ?

Thanks,
sTeVe

Share this post


Link to post
Share on other sites
quote:
Original post by steg
Thanks Anozireth,
I thought this was the answer, although I wasn't sure if you was limited to a certain amount of textures you can have ?
One more question, could I not have these 6 textures in one big bitmap and index into it - although I don't know how I'd do this as texture coordinates are from 0,0 to 1,1 ?



There is *virtually* no limit appart the fact that when it run out of video memory it start to swap constantly the texture
and this will kill the framerate.

The second option having one texture instead of 6 is the most preffered way. Directx is *slow* at changing texture so you may avoid this as much as possible. (see optimizing in the doc "avoiding change state" or something like that).

For the coordinate a square cannot be divided evently in 6 part but for 4 part you must do something like that 0->0.5 one face
0.5->1.0 second face etc etc...

Also if you want to render you cube with different texture you may split it like this:

Apply texture 1
render one face
apply texture 2
render second face
apply texture 3
render third face

and so on....

For the cube it doesn't matter but if you make all your game like this I'm affraid the framerate will not be good.

For a skybox as said beffore I personnaly use a demi sphere that surround the player loaded from a X model with one texture repeated onto it. I than use a matrix to make the texture scrolling.




Hope this help

Dan

Edited by - dansteph on January 15, 2002 4:23:01 AM

Share this post


Link to post
Share on other sites
Thanks for your help Dan,

Your screen shot is very nice !-)

As for a demi sphere I''m affraid I wouldn''t know how to model one, the cube method seems simple at this point in my learning of dx8. I wouldn''t mind reading about this method, I''ll search around to see if I can find anything.

PS - your terrain, are you using LOD algos ?

Kindest regards,
sTeVe

Share this post


Link to post
Share on other sites
quote:
Original post by steg
PS - your terrain, are you using LOD algos ?



No Brute force But I discard several unseen poly (mostly under the sea)
I don''t focus on the terrain while it''s a sail simulator so we don''t walk on the grass... :-)

Good luck for your learning,

Dan

Share this post


Link to post
Share on other sites