jit.gl.multiple texcoords (again)

Mar 20, 2008 at 6:06pm

jit.gl.multiple texcoords (again)

hello
i’m trying to get the texturing to work on jit.gl.multiple:
clearly setting the tex_plane_s tex_plane_t coordinates via matrices
still doesn’t work.

having found wes’ shader from 2006 i was wondering what the changes to
it would have to be, in order for it to evenly distribute the texture
across the entire grid.

wes?

thanks

/*j

// jit.gl.multiple patch //

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P message 205 251 95 196617 file td.reflect2.jxs;
#P message 691 84 74 196617 shader reflect;
#P newex 82 192 71 196617 prepend read;
#P user ubumenu 82 166 108 196617 0 1 1 0;
#X add audio;
#X add audio/ap.chorus.jxs;
#X prefix_set 0 1 c74:/jitter-shaders/ 1;
#X pattrmode 1;
#P newex 204 176 49 196617 pak 0. 0.;
#P flonum 204 155 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 538 96 40 196617 shader;
#P flonum 243 155 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 277 204 94 196617 param scale $1 $2;
#P message 182 204 89 196617 file td.reflect.jxs;
#P message 524 78 74 196617 shader relfect;
#P newex 182 231 353 196617 jit.gl.shader foo @file td.reflect.jxs
@name reflect @param scale 1.05 0.28;
#P toggle 371 437 15 0;
#P message 371 457 68 196617 fullscreen $1;
#N vpatcher 30 89 166 253;
#P window setfont “Sans Serif” 9.;
#P newex 50 71 35 196617 sel 27;
#P newex 50 50 40 196617 key;
#P outlet 50 93 15 0;
#P connect 1 0 2 0;
#P connect 2 0 0 0;
#P pop;
#P newobj 371 417 33 196617 p Esc;
#P user ubumenu 720 284 100 196617 0 1 1 0;
#X add none;
#X add objectspace;
#X add viewspace;
#X add environment;
#X prefix_set 0 0 0;
#X pattrmode 1;
#P newex 727 305 75 196617 prepend texgen;
#P newex 627 268 56 196617 r loadbang;
#P message 556 295 67 196617 autoscale $1;
#P message 627 294 79 196617 read dozer.mov;
#P newex 627 355 148 196617 jit.gl.texture foo @name dozer;
#P toggle 556 275 15 0;
#P newex 437 74 50 196617 r lkj;
#P newex 301 290 50 196617 r lkj;
#P newex 128 103 41 196617 s draw;
#P newex 296 51 56 196617 r loadbang;
#P newex 155 301 56 196617 s loadbang;
#P newex 629 199 32 196617 print;
#P newex 210 70 54 196617 r multiple;
#N vpatcher 87 366 859 812;
#P window setfont “Sans Serif” 9.;
#P message 148 225 31 196617 0.13;
#P message 238 299 80 196617 setall 0 , bang;
#P newex 238 322 117 196617 jit.matrix 1 char 15 15;
#P newex 146 248 130 196617 jit.matrix 3 float32 15 15;
#P newex 84 188 256 196617 jit.expr @expr “0″ “0″ “0″;
#P newex 84 167 130 196617 jit.matrix 3 float32 15 15;
#P window linecount 2;
#P newex 17 98 180 196617 jit.expr @expr “snorm[0]*2″ “snorm[1]*2″ “0″;
#P window linecount 1;
#P newex 17 74 130 196617 jit.matrix 3 float32 15 15;
#P inlet 91 36 15 0;
#P outlet 238 344 15 0;
#P outlet 146 296 15 0;
#P outlet 84 210 15 0;
#P outlet 17 132 15 0;
#P connect 4 0 5 0;
#P connect 5 0 6 0;
#P connect 6 0 0 0;
#P connect 4 0 7 0;
#P connect 7 0 8 0;
#P connect 8 0 1 0;
#P connect 12 0 9 0;
#P connect 9 0 2 0;
#P connect 4 0 12 0;
#P connect 4 0 11 0;
#P connect 11 0 10 0;
#P connect 10 0 3 0;
#P pop 1;
#P newobj 296 92 79 196617 p GenGLParams;
#P newex 135 272 48 196617 loadbang;
#P message 222 105 65 196617 getglparams;
#P user jit.fpsgui 108 125 60 196617 0;
#P message 102 421 34 196617 reset;
#P newex 102 440 255 196617 jit.gl.handle foo @inherit_transform 1
@auto_rotate 1;
#P newex 371 482 188 196617 jit.window foo @depthbuffer 1 @sync 0;
#P number 131 23 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P toggle 84 21 15 0;
#P newex 84 43 57 196617 qmetro 20;
#P newex 84 65 58 196617 t b b erase;
#P newex 84 482 271 196617 jit.gl.render foo @erase_color 1. 1. 1. 1.
@camera 0 0 4;
#P button 135 300 15 0;
#P button 296 72 15 0;
#P window linecount 2;
#P newex 135 326 403 196617 jit.gl.gridshape foo @shape plane
@lighting_enable 1 @blend_enable 1 @smooth_shading 1 @automatic 0
@depth_enable 1 @dim 2 2 @name me @tex_map 2 @color 1 1 1 1;
#P window linecount 3;
#P newex 296 140 343 196617 jit.gl.multiple foo 4 @targetname me
@glparams position rotatexyz scale texture @texture dozer @targetmode
1 @lighting_enable 1 @blend_enable 1 @depth_enable 1 @smooth_shading 1
@color 1 1 1 1 @shader reflect;
#B color 5;
#P window setfont “Sans Serif” 12.;
#P comment 650 142 220 196620 < = more efficient in targetmode 1 , but
you have to set all the opengl attrs here;
#P connect 45 0 34 0;
#P connect 44 0 1 3;
#P connect 43 0 34 0;
#P fasten 42 1 43 0 136 187 87 187;
#P connect 1 1 18 0;
#P fasten 16 3 1 3 370 121 634 121;
#P fasten 16 2 1 2 347 127 523 127;
#P fasten 16 1 1 1 324 133 412 133;
#P connect 23 0 1 0;
#P connect 16 0 1 0;
#P fasten 17 0 1 0 215 136 301 136;
#P fasten 14 0 1 0 227 136 301 136;
#P fasten 35 0 1 0 529 115 301 115;
#P fasten 39 0 1 0 543 115 301 115;
#P connect 6 1 13 0;
#P fasten 6 1 21 0 113 97 133 97;
#P fasten 30 1 29 0 770 302 732 302;
#P connect 26 0 25 0;
#P connect 27 0 25 0;
#P connect 29 0 25 0;
#P connect 28 0 26 0;
#P connect 24 0 27 0;
#P connect 32 0 10 0;
#P connect 33 0 32 0;
#P connect 31 0 33 0;
#P connect 3 0 16 0;
#P connect 20 0 3 0;
#P fasten 41 0 37 0 209 198 282 198;
#P connect 38 0 41 1;
#P connect 40 0 41 0;
#P fasten 37 0 34 0 282 225 187 225;
#P connect 36 0 34 0;
#P connect 15 0 4 0;
#P fasten 15 0 19 0 140 295 160 295;
#P connect 4 0 2 0;
#P connect 22 0 2 0;
#P connect 9 0 7 1;
#P connect 12 0 11 0;
#P connect 6 0 5 0;
#P fasten 6 2 5 0 137 88 89 88;
#P fasten 11 0 5 0 107 469 89 469;
#P connect 7 0 6 0;
#P connect 8 0 7 0;
#P window clipboard copycount 46;

////////

// td.reflect.jxs

////////


Shader for for modifying image contrast by interpolation
and extrapolation


< ![CDATA[

varying vec2 texcoord0;
varying vec2 texdim0;
varying vec4 V;
varying vec4 E;
varying vec3 N;

void main (void)

{
V = gl_ModelViewMatrix * gl_Vertex;
E = gl_ProjectionMatrixInverse * vec4(0.,0.,-1., 0.);
N = normalize(gl_NormalMatrix * gl_Normal);

texdim0 = vec2 (abs(gl_TextureMatrix[0][0][0]),
abs(gl_TextureMatrix[0][1][1]));
texcoord0 = vec2(gl_TextureMatrix[0] * gl_MultiTexCoord0);
gl_Position = ftransform();
}
]]>

< ![CDATA[

varying vec2 texcoord0;
varying vec2 texdim0;
uniform sampler2DRect tex0;

varying vec4 V;
varying vec4 E;
varying vec3 N;

uniform vec2 scale;

void main (void)
{
vec3 Nn = scale.y * normalize(N);
vec3 Vn = scale.x * normalize(V.xyz);

/*
vec3 In = normalize(V.xyz*E.w – E.xyz*V.w);
vec3 R = reflect(In, Nn);

vec2 reflectCoords = 0.5 + 0.5 * normalize(R + vec3(0., 0., 1.)).xy;
reflectCoords *= texdim0;
*/

vec3 R = Vn – 2. * Nn * dot(Nn, Vn);
float m = 2. * sqrt(R.x * R.x + R.y * R.y + (R.z + 1.) * (R.z + 1.));
vec2 reflectCoords;

//because of flip in Gridshape’s texcoords
// reflectCoords.s = (R.x / m + 0.5);
// reflectCoords.t = 1. – (R.y / m + 0.5);
reflectCoords.s = R.x;
reflectCoords.t = 1. – R.y;
reflectCoords *= texdim0;

vec4 color = texture2DRect(tex0, reflectCoords);
gl_FragColor = color;
// gl_FragColor = vec4((R), 1.);
}
]]>

#36439

You must be logged in to reply to this topic.