-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathx_renderchain.js
More file actions
122 lines (88 loc) · 2.17 KB
/
x_renderchain.js
File metadata and controls
122 lines (88 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
autowatch = 1;
inlets = 1;
outlets = 4;
//var listener = new JitterListener('player', callbackfun);
//var enable = 1;
include('scalingfunctions.js');
//output = new Global('player');
//output.screensize;
var screensize = [512, 512];
declareattribute('screensize');
// declare input attributes
var adapt = 1;
declareattribute('adapt');
var dim = [256, 256];
declareattribute('dim');
var scale = 1.0;
declareattribute('scale');
var position = [0.0,0.0];
declareattribute('position');
var mode = 0;
declareattribute('mode');
// init objects and states
var vp = new JitterObject('jit.gl.videoplane');
var otx = new JitterObject('jit.gl.texture');
var itx = new JitterObject('jit.gl.texture');
itx.drawto = 'XPARTICLE';
itx.automatic = 0;
itx.adapt = 1;
otx.drawto = 'XPARTICLE';
otx.adapt = 0;
otx.automatic = 0;
vp.drawto = 'XPARTICLE';
vp.transform_reset = 2;
vp.automatic = 0;
function scalarproduct(arr,scalar)
{
for(var i=0; i<arr.length; i++) {
arr[i] *= scalar;
}
return arr;
}
// for modules with texture input
function jit_gl_texture(texture_in)
{
rendertexture(texture_in);
}
function rendertexture(tx_in)
{
itx.texture = tx_in;
itx.jit_gl_texture(tx_in);
dim = itx.dim;
var dimscale = [dim[0] / screensize[0],dim[1] / screensize[1]];
var txscale = [1.0,1.0];
if (mode == 0)
{
txscale = scalarproduct([1.0,1.0],scale);
otx.dim = screensize;
} else if (mode == 1)
{
txscale = scalarproduct(dimscale,scale);
otx.dim = screensize;
} else {
txscale = scalarproduct([1.0,1.0],scale);
otx.dim = dim;
}
vp.texture = itx.texture;
vp.scale = txscale;
vp.position = position;
vp.capture = otx.name;
vp.draw();
outlet(0, 'jit_gl_texture', otx.name);
outlet(1, 'set','Resolution Out: ', otx.dim[0], otx.dim[1]);
outlet(2, 'dim', otx.dim[0], otx.dim[1]);
outlet(3, 'set', 'Resolution In: ', itx.dim[0], itx.dim[1]);
}
rendertexture.local = 1;
/*
function callbackfun(event)
{
if (enable == 1)
{
if (event.eventname == ("draw") || event.eventname == ("swap"))
{
renderscene();
}
}
}
*/