How to change the color of a shape or add it a texture when using a 3D vertex displacement shader.
Hello,
I need help to change the color of this shape into white. I am using a shader from vade001, to displace vertex.
I tried to connect a jit.gl.texture object to the second inlet of jit.gl.mesh and it did not work.
I tried to change the glcolor attribute value in mesh, and it did not work.
I just can't figure out how to do it.
Hello, I don't know if I understood the problem correctly, but when I change the sampler2D and texture2D in your fragment program to the rectangle version then I can apply a texture (e.g. jit.playlist with argument output texture 1).
Change
uniform sampler2D tex0;
to
uniform sampler2DRect tex0;
texel = texture2D(tex0,gl_TexCoord[0].st);
to
texel = texture2DRect(tex0,gl_TexCoord[0].st);
Thanks Martin, It worked. I can see the texture now!
However, when I don't use the texture, I cannot change the color of the shape using the gl_color attribute in mesh. ( When I change this the shape looks orange and only smooth shades are varying). I would like it to be white.
I tried also to give jit.gl.mesh a color array in its 4th inlet and it didn't work. Perhaps I'm missing something really basic since I'm new using shaders.
Any idea about how to change the color of the shape when the texture is off?
Thanks in advance.
The fragment program of your shader overwrites color Information. Maybe the tutorials on shader programming here help you unserstand whats happening
https://www.federicofoderaro.com/videoTutorials.html
Maybe this written tutorial is a good start
https://www.federicofoderaro.com/introduction_to_shaders.html
And what you may want to try is to set your fragment program to this:
gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0)
Thank you!