more than 2 Textures

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
Guest

more than 2 Textures

Post by Guest »

How can I use more than two textures in a shader?

Thx!
Fernando Alonso

Post by Fernando Alonso »

in SMaterial.h

change "const s32 MATERIAL_MAX_TEXTURES = 2;"

and recompile

I hope it will change in future release of irrlicht, to 3 or 4 textures...
Ishtm
Posts: 37
Joined: Mon May 09, 2005 8:03 pm

Post by Ishtm »

Anywone has some code to made light map with 3 textures?
something like diffuse 2 layers + lightmap ?
Guest

Post by Guest »

I already did that but it doesn't work!

i set it to 6 and loaded 6 different textures.

The result:

tex0,tex1,tex2,tex4,tex5 = the first loaded texture
tex3= the secound loaded texture


What am I doing wrong?
pfo
Posts: 370
Joined: Mon Aug 29, 2005 10:54 pm
Location: http://web.utk.edu/~pfox1

Post by pfo »

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...)
Guest

Post by Guest »

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!
Fernando Alonso

Post by Fernando Alonso »

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)
Guest

Post by Guest »

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).. ?
Guest

Post by Guest »

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 . . .
ThommyE
Posts: 48
Joined: Sun Sep 18, 2005 3:02 pm
Location: germany/badnerlaendle

Post by ThommyE »

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).
athlon2400xp+,geforce4200ti, 0.2Tb hd+64mb extern, 512mb ram, linux FC5 2.6.16-1.2096, 100%gates-free system
Post Reply