Forums > Jitter

Material shader for Texture


Ad.
February 24, 2010 | 11:50 am

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.



efe
February 24, 2010 | 5:51 pm

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);
}
]]>



Ad.
February 25, 2010 | 7:47 am

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.


February 25, 2010 | 6:23 pm

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. –


efe
February 25, 2010 | 6:29 pm

Good one rob!



efe
February 28, 2010 | 7:26 am

Is the previous example working with sampler2D?


Viewing 6 posts - 1 through 6 (of 6 total)