How can I use more than two textures in a shader?
Thx!
more than 2 Textures
-
- Posts: 370
- Joined: Mon Aug 29, 2005 10:54 pm
- Location: http://web.utk.edu/~pfox1
Do you mean more than 2 textures? Or more than 2 materials? There is a difference. I don't think increasing MATERIAL_MAX_TEXTURES will do anything useful, unless your shader specifically works on those textures. I don't know much about shaders yet though....
If you mean more than 2 materials, use node->getMaterialCount() to determine how many you have, and you can get and set materials through node->getMaterial(i).Value = MyValue; where Value and MyValue is what you want to change (texture, color, etc...)
If you mean more than 2 materials, use node->getMaterialCount() to determine how many you have, and you can get and set materials through node->getMaterial(i).Value = MyValue; where Value and MyValue is what you want to change (texture, color, etc...)
no - i wan't to use more than two textures!
my shader loads textures and uses them to generate effects. In other applications this works perfect - but if i try to use them in irrlicht, it does not!
for example, my shader loads 2 textures - tex0 and tex1. This works quite well in irrlicht - the first loaded texture is tex0 and the secound is tex1
But another shader, which loads 4 textures - tex0-tex3 - does not work. the first loaded texture becomes tex0-tex2, the secound loaded texture becomes tex3 and the two other loaded textures get ignored completely!
my shader loads textures and uses them to generate effects. In other applications this works perfect - but if i try to use them in irrlicht, it does not!
for example, my shader loads 2 textures - tex0 and tex1. This works quite well in irrlicht - the first loaded texture is tex0 and the secound is tex1
But another shader, which loads 4 textures - tex0-tex3 - does not work. the first loaded texture becomes tex0-tex2, the secound loaded texture becomes tex3 and the two other loaded textures get ignored completely!
I think , if :
change "const s32 MATERIAL_MAX_TEXTURES = 4;"
ITexture * text1;
ITexture * text2;
ITexture * text3;
ITexture * text4;
and after:
node->setTextureMaterial(0,text1);
node->setTextureMaterial(1,text2);
node->setTextureMaterial(2,text3);
node->setTextureMaterial(3,text4);
and, in shader:
VS_OUT pixelMain( float2 TexCoord0 : TEXCOORD0,float2 TexCoord1 : TEXCOORD1,float2 TexCoord2 : TEXCOORD2,float2 TexCoord3 : TEXCOORD3,float4 Position : POSITION)
and inside this funtion:
sampler2D tex0;
sampler2D tex1;
sampler2D tex2;
sampler2D tex3;
float4 col0 = tex2D( tex0, TexCoord0 );
float4 col1 = tex2D( tex1, TexCoord1 );
float4 col2 = tex2D( tex2, TexCoord2 );
float4 col3 = tex2D( tex3, TexCoord3 );
And you can use it
I think in openGL and D3D is a machine of state, the textures are selected while you dont change it, And I think the maximo number of texture is 8
( but it depend of the type of graphics hardware)
change "const s32 MATERIAL_MAX_TEXTURES = 4;"
ITexture * text1;
ITexture * text2;
ITexture * text3;
ITexture * text4;
and after:
node->setTextureMaterial(0,text1);
node->setTextureMaterial(1,text2);
node->setTextureMaterial(2,text3);
node->setTextureMaterial(3,text4);
and, in shader:
VS_OUT pixelMain( float2 TexCoord0 : TEXCOORD0,float2 TexCoord1 : TEXCOORD1,float2 TexCoord2 : TEXCOORD2,float2 TexCoord3 : TEXCOORD3,float4 Position : POSITION)
and inside this funtion:
sampler2D tex0;
sampler2D tex1;
sampler2D tex2;
sampler2D tex3;
float4 col0 = tex2D( tex0, TexCoord0 );
float4 col1 = tex2D( tex1, TexCoord1 );
float4 col2 = tex2D( tex2, TexCoord2 );
float4 col3 = tex2D( tex3, TexCoord3 );
And you can use it
I think in openGL and D3D is a machine of state, the textures are selected while you dont change it, And I think the maximo number of texture is 8
( but it depend of the type of graphics hardware)
ok. So most typical hardware these days supports 8 textures say. IN older games (unreal T) you had bsp polys + detail textures + reflections + lightmaps so that was at least 4 materials. How did they manage that but yet in 2005 nearly every renderer I look at says "max 2" textures??? Do we have to resort to multi rendering of scenes to get this effect (if we dont wish to use shaders).. ?
I think they just merged some textures together and used UV mapping to acess the right pixels...
But for me this doesn't work, because i need for example one 1024x1024, one 512x512 and one 64x64 texture. Of course I could make one 2048x1024 texture and put all other textures in this one - but this way, I would waste a lot of texturememory because i can't fill a 2048x1024 texture with my three textures . . .
But for me this doesn't work, because i need for example one 1024x1024, one 512x512 and one 64x64 texture. Of course I could make one 2048x1024 texture and put all other textures in this one - but this way, I would waste a lot of texturememory because i can't fill a 2048x1024 texture with my three textures . . .
i dont "know" but i dont "think"^^
.. i mean i dont think ut just merges pixels together. wouldn't this cause a lot of cpu-usage(without sahders.. were not invented back there)?
i would rather guess they used the hardware-side multitextures. even older card can manage 4 textures (per pass think).
.. i mean i dont think ut just merges pixels together. wouldn't this cause a lot of cpu-usage(without sahders.. were not invented back there)?
i would rather guess they used the hardware-side multitextures. even older card can manage 4 textures (per pass think).
athlon2400xp+,geforce4200ti, 0.2Tb hd+64mb extern, 512mb ram, linux FC5 2.6.16-1.2096, 100%gates-free system