HLSL Texture Array Support

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
robmar
Posts: 1125
Joined: Sun Aug 14, 2011 11:30 pm

HLSL Texture Array Support

Post by robmar »

Texture arrays are supported in HLSL under DX10, but as Irrlicht is currently at DX9, what is the best way to support multiple textures for Irrlicht shaders?

For example, say 3D meshs have from 1 to 32 textures, and we want to fade the textures usind a single shader, is there a method to index to any required shader just by passing the total number of textures and using a loop in the shader?
Mel
Competition winner
Posts: 2293
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: HLSL Texture Array Support

Post by Mel »

For now, Irrlicht doesn't support texture arrays. There is a patch to enable them under OpenGL though, and seems that no one is willing/able to create a DX11 driver.

The best way in Irrlicht, for now, is to have a texture atlas.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
robmar
Posts: 1125
Joined: Sun Aug 14, 2011 11:30 pm

Re: HLSL Texture Array Support

Post by robmar »

not heard about a texture atlas, how does it work, any code samples?
Mel
Competition winner
Posts: 2293
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: HLSL Texture Array Support

Post by Mel »

A texture atlas is to have all the textures in a single big texture, so you sample from portions of the texture, instead of the whole map; the drawback is that you have to take care of the boundaries of the textures and the mipmap levels

tex2Dlod may help you here, it samples directly from a specific mipmap level, just prevent it from reaching the first mipmap level in which your textures in the atlas will start to blend.

Say for instance that you have an atlas of 4096x4096 pixels which stores 64 512x512 textures. These will start to blend with each other when the mip level reaches the smallest level a 512x512 texture support, which is 11, beyond that, the textures will blend with each other, breaking the effect.

It is much more elaborate than a simple texture array, but it gives the same results, and reaches a wider range of hardware
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
robmar
Posts: 1125
Joined: Sun Aug 14, 2011 11:30 pm

Re: HLSL Texture Array Support

Post by robmar »

sadly thats no good for me, the textures are always unknown separate files.

with hlsl there is the register accessing, but i guess as i have 32 textures, I´ll just have to define 32 of them individually.

be great to get at least DX10 supported for Irr
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: HLSL Texture Array Support

Post by Nadro »

You can find a DX111 driver here:
http://irrlicht.sourceforge.net/forum/v ... =6&t=38510
We'll officially add Texture Arrays for Irrlicht in v2.0.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
Granyte
Posts: 849
Joined: Tue Jan 25, 2011 11:07 pm
Contact:

Re: HLSL Texture Array Support

Post by Granyte »

the dx10/11 is really functional and people trying it and giving us feed back would actualy help us find bug and feature that should work but don't faster at this point

but ya for dx9 the only way are texture atlasses

i had the same issue where the possible texture to be combined might not be the same from one time to the other so i wrote a shader that can take 16 texture and combine them to one texture and because i then render each mipmap level and run my own mipmap algo i have no texture bleeding
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: HLSL Texture Array Support

Post by hendu »

It's really bad form for realtime use to have models with a ton of maps. I know it's common with modelers, they must have a map for this and a map for that, but that just won't fly for realtime.

Oh, oh, shiny! I must have an opacity map, falloff map, freshnel map, pure poop map, pink reflections map, pink reflections skip map, world map, map of the local food store, and the fully detailed map for Diablo 3.

Rant over.
Post Reply