Page 1 of 1

How to pass a texture to a shader?

Posted: Mon Jun 18, 2007 4:42 pm
by Joe Red
So, I would like to use a shader with irrlicht with the following line:

texture BaseTex;

How can I pass a texture to the shader? The setVertexShaderConstant function is just for matrices, and vectors, isn't it? My question is probably newbish, but I cant find it out. Please help!

Re: How to pass a texture to a shader?

Posted: Mon Jul 02, 2007 8:27 pm
by miha
Joe Red wrote:So, I would like to use a shader with irrlicht with the following line:

texture BaseTex;

How can I pass a texture to the shader? The setVertexShaderConstant function is just for matrices, and vectors, isn't it? My question is probably newbish, but I cant find it out. Please help!
If you want to use shaders,you can set them up as the material type,
when you set the material texture...Like this:

node.SetMaterialTexture(0, BaseTex);
node.SetMaterialType(MyShader);

if you need more info about defining the shader:
http://irrlichtnetcp.sourceforge.net/ph ... hlight=cel

Posted: Mon Jul 02, 2007 8:48 pm
by BlindSide
Joe red in HLSL you do this:

sampler2D myTex : register(s0) ; // (Before the pixel shader function)

This will set meTex to the first texture loaded in your model in irrlicht.
You can do s1, s2 and s3 for the second, third and fourth textures.

Cheers

Posted: Thu Jul 19, 2007 10:22 am
by Kalda
Joe red in HLSL you do this:

sampler2D myTex : register(s0) ; // (Before the pixel shader function)

This will set meTex to the first texture loaded in your model in irrlicht.
You can do s1, s2 and s3 for the second, third and fourth textures.

Cheers
And how do this in GLSL?

Posted: Fri Jul 20, 2007 1:13 am
by BlindSide
Kalda wrote:
Joe red in HLSL you do this:

sampler2D myTex : register(s0) ; // (Before the pixel shader function)

This will set meTex to the first texture loaded in your model in irrlicht.
You can do s1, s2 and s3 for the second, third and fourth textures.

Cheers
And how do this in GLSL?
Its a little more complicated, in the shader you do:

uniform sampler2D myTex;

and when you pass a constant thats the name of the texture (myTex) and is the number of the texture on the model (so 0, 1, 2 or 3).