More than 4 textures... [solved]

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Delight
Posts: 42
Joined: Tue Jul 05, 2005 3:16 pm
Location: Muenster, Germany

More than 4 textures... [solved]

Post by Delight »

I got a simple question: How is it possible to use more than 4 textures? I worry that a couple of modifications to the engine are necessary, or? Perhaps there is already a patch?
Last edited by Delight on Fri Jun 08, 2007 11:14 am, edited 1 time in total.
omar shaaban
Posts: 616
Joined: Wed Nov 01, 2006 6:26 pm
Location: Cairo,Egypt
Contact:

Post by omar shaaban »

do u mean to use 4 textures in one model if that ya u can it is about your model when exporting it u assign to it how many textures for it .
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

If you need more than four textures in one material you have to change the const MATERIAL_MAX_TEXTURES in SMaterial and recompile. You have to redefine your materials, though, to take an advantage of it - shaders should be able to use them right away.
greenya
Posts: 1012
Joined: Sun Jan 21, 2007 1:46 pm
Location: Ukraine
Contact:

Post by greenya »

Maybe offtopic, but:
Why MATERIAL_MAX_TEXTURES defined as 4 ?
Why not 8 or 16 for example ? (is this about the memory usage or speed?).
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Mainly memory, but also no need for more. We have no advanced materials, yet, so we can restrict to 4 materials. Also there are no card which support more than 8 materials, many even only have 6. 4 is pretty safe.
Delight
Posts: 42
Joined: Tue Jul 05, 2005 3:16 pm
Location: Muenster, Germany

Post by Delight »

I already changed the MATERIAL_MAX_TEXTURE constant, but when I use the new dll and assign a texture via setMaterialTexture( int, texture ), i got an unhandled exception during runtime in

CD3D9Driver::setTexture(s32 stage, video::ITexture* texture)

at

pID3DDevice->SetTexture(stage, ((CD3D9Texture*)texture)->getDX9Texture());

Not only setting a stage higher than 4 is the problem, even the first textures cannot be set...
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Maybe the d3d driver does not check for the maximal textures available in hardware. I doubt this, but might be true. In OpenGL I added this some month ago.
Delight
Posts: 42
Joined: Tue Jul 05, 2005 3:16 pm
Location: Muenster, Germany

Post by Delight »

Well I got a working example in Direct3D without Irrlicht, where 5 textures are set and all of them are displayed. OpenGl doesn't work for me neither...

Btw.: Beside setting the MATERIAL_MAX_TEXTURE constant I haven't to do anything?
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

From my experience, most OpenGL drivers only support 4 textures. I've had 8 textures working in DX, but never more than 4 working in OpenGL, not sure why.
Image
Delight
Posts: 42
Joined: Tue Jul 05, 2005 3:16 pm
Location: Muenster, Germany

Post by Delight »

So you got it working by setting the Max texture constant to 8? What could be the matter, that it's not working for me. The hardware shouldn't be the problem. As I already told I got a directX example with more than 4 textures working...
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

No, I'm sorry I didn't clarify. I maintain a different version of Irrlicht( IrrSpintz ). I used to support up to 8 textures, but stopped and dropped it to 4, because I couldn't get more than 4 to ever work in OpenGL.
Image
Halan
Posts: 447
Joined: Tue Oct 04, 2005 8:17 pm
Location: Germany, Freak City
Contact:

Post by Halan »

is there any tutorial how to join multiple texutres via a shader?
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Halan wrote:is there any tutorial how to join multiple texutres via a shader?
Hey good Idea I will use a shader! I was rolling around in bed trying to figure out how to do texture splatting with on DETAIL_MAP haha...
Delight
Posts: 42
Joined: Tue Jul 05, 2005 3:16 pm
Location: Muenster, Germany

Post by Delight »

I made some further tests. Setting the constant down works perfectly, but setting it to 5 crashes the application every time - even when I set the only first or second texture stage. The SetMaterialTexture(int, texture) doesn't seem to be the problem. The scene.DrawAll() is the problem. When I comment the line out, it's working perfectly...

A direct3d9 example with 5 textures works perfectly and shows all of them - so it cannot be a problem with my graphic card.

And finally I got it on my own: Beside the max texture constant i had to extend the E_TRANSFORMATION_STATE by one element (ETS_TEXTURE_4).

Now its working and my texture splatting fog of war and lighted terrain looks finally... veeeery nice :D
Halan
Posts: 447
Joined: Tue Oct 04, 2005 8:17 pm
Location: Germany, Freak City
Contact:

Post by Halan »

BlindSide wrote:
Halan wrote:is there any tutorial how to join multiple texutres via a shader?
Hey good Idea I will use a shader! I was rolling around in bed trying to figure out how to do texture splatting with on DETAIL_MAP haha...
please, please keep me up to date with your approach :)

greeets,
Halan
Post Reply