declare sampler2D

efe's icon

Hello to everyone:
Hope someone can help me to solve my next question. I am toying with the next shader based on a quartz composer example(attached on this post). I am trying to declare the data type sampler2D in order to use a texture. However, it seems i am doing something wrong. So, my questions are:
1-when I declare my param:

I am not sure that the type nor the default value are correct as every time I try to compile the shader the post window in Jitter throws the next message:
setting GLSL param: GL Error: Invalid operation
am I missing something here?, how can I declare the sample2D on the params?

2-I was taking a look around the shader folder but it seems that sample2D is never declared as such, is there a correct way to do such declaration?

Thank you very much for the help!
Emmanuel

efe's icon

Jesus!, so simple!
Sorry for the spam!, it is always good to take a second look!

the heating is making me slow!
Emmanuel

efe's icon

sorry for all this confusion:
I was trying again and the sampler2D doesn't seem to work. Am I doing something wrong?
I am pretty lost now
Emmanuel

pelado's icon

Just a guess without looking into your patch. Are you using a rectangular texture? If so look into sampler2DRect or use @rectangular 0 with jit.gl.texture.

pelado

pelado's icon

I have looked at your patch now and see that you do indeed need to disable the rectangle attribute to the texture object. But to get it fully working there are a couple of other things to note:

enable @doublebuffer for the window;
and in your shader code refer to the texture coordinates for texture unit0 by using this line in your fragment shader. ie [0] not [1].

    vec2 tex = gl_TexCoord[0].xy;

pelado

efe's icon

Hello Pelado.
First of all thanks for your answer and taking time to help me.
I just tried as you said and doesn't seem to work yet. I cannot figure out what I am missing here. I made a new change to the file, modified the sample2D type on the param declaration to int, so I can avoid having an error saying invalid operator and I enabled the doublebuffer on the window. However, the patch doesn't work properly. The texture still is not rendered properly.
What is that I am missing?
I am attaching the new version.
Thank you for your help!
Emmanuel

efe's icon

Really, long day. Just came back from a concert and my mind is a little bit blurry...
I managed to fix the shader. As Pelado said the issue was related with the unit number.
A piece of advice: always attach the params to your shader so you can know what is going on!. It seems the default value for the ration was the problem.
Here is a fixed version of the shader!
Thanks again for the help and sorry for the multiple wrong posts on this thread.
Emmanuel