I am trying to create a new terrain object with any number of different textures and automatic transition-blending. First I thought I could simply prepare transition-textures, but the number of possible blends would be too high. So now the idea is to use a custom shader to create the blend dynamically with up to 4 different textures per pixel (every pixel being located between 4 terrain-grid-nodes).
The first problem I am having is that I can't seem to pass a sampler-array to my GLSL shader:
uniform sampler2D mTexture[4];// from the fragment-shader, compiles fine
s32 texture[4] = {0,1,2,3};
services->setPixelShaderConstant("mTexture", texture, 4);// from the shader-callback, returns false! using single sampler works, but I want to access samplers directly by index
Problem two would be the 4-texture restriction on irrlicht-materials. Is there a way to have more than that?
Multi-Texture Blend
Re: Multi-Texture Blend
in IrrCompileConfig.h
change the value to what ever you need
how ever you are limited to 8 on dx due to a bug in the engine
and to 16 on ogl due to the texture matrix defines i think but i'm not as familiar with OGL
Code: Select all
#define _IRR_MATERIAL_MAX_TEXTURES_ 4change the value to what ever you need
how ever you are limited to 8 on dx due to a bug in the engine
and to 16 on ogl due to the texture matrix defines i think but i'm not as familiar with OGL
Re: Multi-Texture Blend
Thanks! I only wish there was a way without having to recompile the engine 
Now there's still the question of how I get a sampler-array into my shader.
edit: kind of unrelated, but when I try to compile Irrlicht using the msvc10 sln project file, it tells me d3dx9shader.h (include) is missing.
Now there's still the question of how I get a sampler-array into my shader.
edit: kind of unrelated, but when I try to compile Irrlicht using the msvc10 sln project file, it tells me d3dx9shader.h (include) is missing.
Re: Multi-Texture Blend
sampler array are not availible for dx9 they can be emulated or faked using atlasses or other technique
the dx11 driver when completed will have support for those
ogl i cannot help you there
if you try to build with directx you neeed the dxsdk june 2010
the dx11 driver when completed will have support for those
ogl i cannot help you there
if you try to build with directx you neeed the dxsdk june 2010
Re: Multi-Texture Blend
Sorry for the off-topic,
Is June 2010 the latest version of DX we can have installed to compile Irrlicht with DX9.0 support? I assume that is 9.0C or..?
Is June 2010 the latest version of DX we can have installed to compile Irrlicht with DX9.0 support? I assume that is 9.0C or..?
Dream Big Or Go Home.
Help Me Help You.
Help Me Help You.
Re: Multi-Texture Blend
Yes that contain dx9.0c and dx11 it how ever does not contain dx11.1 so the current irrlicht driver will not compile without windows 8 sdk
Re: Multi-Texture Blend
I've been busy with other stuff the last couple of days. Now that I want to get back to this I realize it's probably not as simple as I thought...
I was planning to use vertex-data (alpha value probably) as a texture index (0, 1, 2, 3...), but it's no use if I get an interpolated value for these into the pixel shader. And vertex 4 isn't involved at all in the individual polygon.
Any suggestions how I could actually do this? I will probably need one vertex-value for each texture to be interpolated, but creating a blend involving 4 vertices doesn't seem possible
edit: I guess I could use tex-coords to let the pixel know what grid-position it is in. Each vertex would get a tex-coord.x equal to its column index and y equal to its row, which wouldn't have any visual effect afaik. Then in the pixel shader I would cut off the interpolated float-part (use as int) to know the terrain-vertex to the upper left. But then I would still need a uniform array [columns][rows] inside the pixel-shader to look up the 4 texture indices from x/y to x+1/y+1... maybe I could pass a sampler instead acting as that array: prepare a texture of scale columns*rows and set one color-value to the tex-index of the corresponding terrain-vertex. Good idea? Hmm... maybe I should do this whenever I need an array inside a shader
edit2: another question - in the IShaderConstantSetCallBack, is it possible to pass textures to the shaders that are not part of the material? In that case I wouldn't mind how many textures are allowed per material, I would just set them constantly for the terrain-material-shader.
I was planning to use vertex-data (alpha value probably) as a texture index (0, 1, 2, 3...), but it's no use if I get an interpolated value for these into the pixel shader. And vertex 4 isn't involved at all in the individual polygon.
Any suggestions how I could actually do this? I will probably need one vertex-value for each texture to be interpolated, but creating a blend involving 4 vertices doesn't seem possible
edit: I guess I could use tex-coords to let the pixel know what grid-position it is in. Each vertex would get a tex-coord.x equal to its column index and y equal to its row, which wouldn't have any visual effect afaik. Then in the pixel shader I would cut off the interpolated float-part (use as int) to know the terrain-vertex to the upper left. But then I would still need a uniform array [columns][rows] inside the pixel-shader to look up the 4 texture indices from x/y to x+1/y+1... maybe I could pass a sampler instead acting as that array: prepare a texture of scale columns*rows and set one color-value to the tex-index of the corresponding terrain-vertex. Good idea? Hmm... maybe I should do this whenever I need an array inside a shader
edit2: another question - in the IShaderConstantSetCallBack, is it possible to pass textures to the shaders that are not part of the material? In that case I wouldn't mind how many textures are allowed per material, I would just set them constantly for the terrain-material-shader.