Multi-texturing

Started by
8 comments, last by steg 22 years, 3 months ago
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

If it isn't working, take a bath, have a think and try again...

Advertisement
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.

Ryan Buhr

Technical Lead | Sector 13

Reactor Interactive, LLC

Facebook | Twitter

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?

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

If it isn't working, take a bath, have a think and try again...

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 headerLPDIRECT3DTEXTURE8    pFaceTex[6]; // The array for the textures// Then when rendering...pD3DDevice->SetTexture(0, pFaceTex[0]);//Draw the first face herepD3DDevice->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
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

If it isn't working, take a bath, have a think and try again...

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
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

If it isn't working, take a bath, have a think and try again...

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

Thanks Dan,

I''ve also done a brute force terrain, currently implementing a LOD algo with quad trees.

Regards,
sTeVe

If it isn't working, take a bath, have a think and try again...

This topic is closed to new replies.

Advertisement