i still don't understand how to load a jpg file to MyTex.
attachement is my test patch. it does not render any texture.
thanks Cyrille
chris clepper a écrit :
Use a texture sampler in your shader. GLSL has a sampler for 2D and RECT texutres, so make sure you have the right one for the texture type (OSX defaults to RECT while Win/Linux are probably 2D).
uniform sampler2D MyTex;
void main (void) { vec4 color = texture2D(MyTex, gl_TexCoord[0].st); color = color * 0.5; gl_FragColor = color; }
That is untested but it should result in something.
cgc
On 8/25/06, *cyrille henry* <cyrille.henry@la-kitchen.fr mailto:cyrille.henry@la-kitchen.fr> wrote:
hello, i'm trying to learn glsl. I can't find how to use texture in the fragment shader. does anyone have an exemple how to load texture with GEM glsl? thanks Cyrille _______________________________________________ GEM-dev mailing list GEM-dev@iem.at <mailto:GEM-dev@iem.at> http://lists.puredata.info/listinfo/gem-dev
GEM-dev mailing list GEM-dev@iem.at http://lists.puredata.info/listinfo/gem-dev
void main() { // perform standard transform on vertex gl_Position = ftransform();
}
uniform sampler2D MyTex;
void main (void) { vec4 color = texture2D(MyTex, gl_TexCoord[0].st); color = color * 0.5; gl_FragColor = color; }
#N canvas 756 30 630 784 10; #X obj 75 22 gemhead; #X obj 87 173 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 -1; #N canvas 0 22 450 300 open 0; #X obj 75 103 openpanel; #X obj 75 173 outlet; #X obj 75 127 t b s; #X msg 105 152 set open $1; #X obj 75 80 inlet; #X connect 0 0 2 0; #X connect 2 0 1 0; #X connect 2 1 3 0; #X connect 3 0 1 0; #X connect 4 0 0 0; #X restore 87 193 pd open; #X msg 28 212 print; #X obj 73 623 glsl_program; #X obj 146 443 pack 0 0; #X obj 84 290 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 -1; #N canvas 0 22 450 300 open 0; #X obj 75 103 openpanel; #X obj 75 173 outlet; #X obj 75 127 t b s; #X msg 105 152 set open $1; #X obj 75 80 inlet; #X connect 0 0 2 0; #X connect 2 0 1 0; #X connect 2 1 3 0; #X connect 3 0 1 0; #X connect 4 0 0 0; #X restore 84 308 pd open; #X msg 30 324 print; #X obj 167 423 t b f; #X obj 167 378 change; #X obj 145 253 change; #X msg 146 483 link $1 $2; #X msg 29 549 print; #X text 187 361 the fragment shader; #X floatatom 167 404 2 0 0 0 ID - -; #X floatatom 145 276 2 0 0 0 ID - -; #X obj 164 504 print linking; #X obj 73 667 rotateXYZ; #X floatatom 92 645 5 0 0 0 - - -; #X obj 73 149 colorRGB; #X floatatom 185 112 5 0 0 0 - - -; #X floatatom 231 110 5 0 0 0 - - -; #X floatatom 136 645 5 0 0 0 - - -; #X floatatom 178 643 5 0 0 0 - - -; #X obj 73 358 glsl_fragment; #X obj 73 234 glsl_vertex; #X obj 75 82 pix_image; #X msg 102 53 open test.jpg; #X obj 75 115 pix_texture; #X msg 453 62 color 1 0 0; #X floatatom 278 110 5 0 0 0 - - -; #X obj 430 156 gemwin; #X msg 466 95 create , 1; #X msg 486 122 destroy; #X obj 74 700 square; #X msg 87 212 open test.vert; #X msg 83 328 open test.frag; #X connect 0 0 27 0; #X connect 1 0 2 0; #X connect 2 0 36 0; #X connect 3 0 26 0; #X connect 4 0 18 0; #X connect 5 0 12 0; #X connect 6 0 7 0; #X connect 7 0 37 0; #X connect 8 0 25 0; #X connect 9 0 5 0; #X connect 9 1 5 1; #X connect 10 0 15 0; #X connect 11 0 16 0; #X connect 12 0 4 0; #X connect 12 0 17 0; #X connect 13 0 4 0; #X connect 15 0 9 0; #X connect 16 0 5 0; #X connect 18 0 35 0; #X connect 19 0 18 1; #X connect 20 0 26 0; #X connect 21 0 20 1; #X connect 21 0 20 2; #X connect 22 0 20 3; #X connect 23 0 18 2; #X connect 24 0 18 3; #X connect 25 0 4 0; #X connect 25 1 10 0; #X connect 26 0 25 0; #X connect 26 1 11 0; #X connect 27 0 29 0; #X connect 28 0 27 0; #X connect 29 0 20 0; #X connect 30 0 32 0; #X connect 31 0 20 4; #X connect 33 0 32 0; #X connect 34 0 32 0; #X connect 36 0 26 0; #X connect 37 0 25 0;