Terrain texture layer limit?

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!
Post Reply
scriptr
Posts: 16
Joined: Wed Aug 12, 2009 12:14 pm

Terrain texture layer limit?

Post by scriptr »

Hi,

How do you handle your huge terrains' textures? As i googled a little, irrlicht support up to 4 texture layers for each node. Is that correct? Because, for example in wow, terrains have a lot of different textures. Isn't that possible in irrlicht?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

You can use as many textures as you want for a mesh, if you really need it you can put every face into its own meshbuffer and use a separate texture for it. The thing is, that there's a hard limit for textures used for one triangle . This technique, commonly referred to as multi-texturing, mixes the many textures together (or chooses among some of them) to color one triangle. The common limit for this on fixed function pipeline hardware (which is what Irrlicht uses for most materials) is 8, but many gfx card support even less. My nv6600, e.g., supports only 4.
You can alter the number of textures per triangle in Irrlicht versions up to 1.5.1 in the SMaterial.h file. Default is 4, but you can also put 8 there. This may lead to some problems, though, especially when using too many texture matrices. In Irrlicht 1.6, those problems will be resolved and you can safely choose any number from 1 to 8. If you need more than 8 textures per triangle, you will have to use shaders. Support for that many textures might require some more changes to Irrlicht, but maybe 8 will be enough for you.
scriptr
Posts: 16
Joined: Wed Aug 12, 2009 12:14 pm

Post by scriptr »

I have 7-8 different textures and their alpha maps painted on a terrain. And i want to texture my terrain with those textures. As i understood from your reply, that is possible, as no more 4 textures will instersect on the same triangle, right?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Well, if you can separate your terrain mesh into parts which only use at most 4 textures, than this works right away. You just need to define the proper materials. If you cannot tell which of the 8 textures are used on which tri, you have to put all 8 textures into the matrial, which would require to change the number of allowed textures. But in most cases you will get around with the first solution, which also runs on smaller computers.
sio2
Competition winner
Posts: 1003
Joined: Thu Sep 21, 2006 5:33 pm
Location: UK

Post by sio2 »

hybrid wrote:My nv6600, e.g., supports only 4.
Strange. Under Windows and DX9 with SM3 a 6600 should support 16 textures (at least for programmable shaders)... Are your drivers (for whichever OS or 3D API you're using) reporting 4?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Well, this is fixed function pipeline limit (under Linux, with latest drivers supporting this card):
GL_MAX_TEXTURE_UNITS_ARB = 4
Valmond
Posts: 308
Joined: Thu Apr 12, 2007 3:26 pm

Post by Valmond »

You might want to check out this thread where a patch for 16 textures is explained (scroll down quite much).

I'm using it for terrains and it is great.
Last edited by Valmond on Thu Aug 13, 2009 8:31 am, edited 1 time in total.
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Post by Nadro »

sio2 wrote:
hybrid wrote:My nv6600, e.g., supports only 4.
Strange. Under Windows and DX9 with SM3 a 6600 should support 16 textures (at least for programmable shaders)... Are your drivers (for whichever OS or 3D API you're using) reporting 4?
GL_MAX_TEXTURE_UNITS_ARB = 4 - in fixed function pipeline
GL_MAX_TEXTURE_IMAGE_UNITS_ARB = 16 - in shaders (SM2.0+)
So it's ok, 4 textures in fixed function are enought, so no differences for Windows/Linux/DirectX/OpenGL etc.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
scriptr
Posts: 16
Joined: Wed Aug 12, 2009 12:14 pm

Post by scriptr »

Thanks for your replies.

I have merged my 8 textures in two 1024x1024 picture. And in shader i have clipped and scaled them on terrain without changing any code in irrlicht. Now i can texture my terrain with 8 textures with only three texture channel (2 RGB + 1 Alpha RGB).
Valmond
Posts: 308
Joined: Thu Apr 12, 2007 3:26 pm

Post by Valmond »

If this is an "Atlas map" then you might need to disable mipmaps though as otherwise the "merged" textures will float over eachothers and not having mipmaps is a bit of a downside...
Post Reply