Material shader for Texture

Feb 24, 2010 at 11:50am

Material shader for Texture

Hi,
I would like to apply to a gl.mesh’s texture (it could be a videoplane texture too !) materials shader (mat.glass,…)

I’ve tried to bind the texture and set sampler2DRect…
But I’m pretty newbie in gl.shader…

Any help would be pretty appreciated.

Thx.

Ad.

#48743
Feb 24, 2010 at 5:51pm

something like this?


< ![CDATA[
void main()
{
gl_FrontColor = gl_Color;
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_Position = ftransform();
}
]]>

< ![CDATA[
uniform sampler2DRect tex;

void main()
{
gl_FragColor = gl_Color * texture2DRect(tex, gl_TexCoord[0].xy);
}
]]>

#175141
Feb 25, 2010 at 7:47am

Thank you for your response;
If i use your code as a single shader, it gives nothing else than a back sea !

Is this more like a program that I would have to bind in the futures shaders ?

Ad.

#175142
Feb 25, 2010 at 6:23pm

a few issues with the shader.
a single texture parameter should be bound to int 0, not int 1 (assuming you only have one texture bound).
second, for rectangular textures you’re going to want to multiply the texcoord by the gl_TextureMatrix before sending to the fragment shade.

here’s modified shader code and a simple test patch:

save as simple.jxs:

test patch

– Pasted Max Patch, click to expand. –
#175143
Feb 25, 2010 at 6:29pm

Good one rob!

#175144
Feb 28, 2010 at 7:26am

Is the previous example working with sampler2D?

#175145

You must be logged in to reply to this topic.