diff options
author | Travis CI <zmoelnig@travis-ci.umlaeute.mur.at> | 2015-05-01 20:41:04 +0000 |
---|---|---|
committer | Travis CI <zmoelnig@travis-ci.umlaeute.mur.at> | 2015-05-01 20:41:04 +0000 |
commit | 4174b0e45055eda9b776d0f3cdfdbf48ccfd45a5 (patch) | |
tree | e486a71ed7e8ff2fa50489f1cd9c6bb44bbcf89f /Gem/examples | |
parent | c97266c552ff81e58446ddc9ef95c5b2a1b7836a (diff) |
Gem 52940d997a5dfcd482c52b52e083e9e3947e838f osx/i386
built 'master:52940d997a5dfcd482c52b52e083e9e3947e838f' for osx/i386
Diffstat (limited to 'Gem/examples')
-rw-r--r-- | Gem/examples/10.glsl/16.vertexbuffer_attributes.pd | 231 | ||||
-rw-r--r-- | Gem/examples/data/brick.frag | 24 | ||||
-rw-r--r-- | Gem/examples/data/brick.vert | 43 |
3 files changed, 298 insertions, 0 deletions
diff --git a/Gem/examples/10.glsl/16.vertexbuffer_attributes.pd b/Gem/examples/10.glsl/16.vertexbuffer_attributes.pd new file mode 100644 index 0000000..964b46b --- /dev/null +++ b/Gem/examples/10.glsl/16.vertexbuffer_attributes.pd @@ -0,0 +1,231 @@ +#N canvas 375 67 983 713 10; +#N canvas 1 89 450 300 fps 0; +#X obj 46 -61 gemhead; +#X obj 46 -21 realtime; +#X obj 46 -41 t b b; +#X obj 46 41 /; +#X msg 46 21 1000 \$1; +#X obj 46 106 outlet; +#X obj 46 63 + 0.5; +#X obj 46 85 i; +#X connect 0 0 2 0; +#X connect 1 0 4 0; +#X connect 2 0 1 0; +#X connect 2 1 1 1; +#X connect 3 0 6 0; +#X connect 4 0 3 0; +#X connect 6 0 7 0; +#X connect 7 0 5 0; +#X restore 806 149 pd fps; +#X floatatom 806 172 5 0 0 1 fps - -, f 5; +#N canvas 5 76 450 300 gemwin 0; +#X obj 132 246 gemwin; +#X obj 67 89 outlet; +#X obj 67 10 inlet; +#X obj 67 41 route create; +#X msg 67 70 set destroy; +#X msg 142 68 set create; +#X msg 198 142 destroy; +#X msg 132 142 create \, 1; +#X obj 245 38 loadbang; +#X msg 272 82 reset \, frame 100; +#X obj 245 58 t b b; +#X obj 132 117 t b b; +#X msg 376 135 \; pd dsp 1; +#X obj 349 114 t b b; +#X obj 349 181 del 100; +#X obj 349 201 s \$0-init100; +#X connect 2 0 3 0; +#X connect 3 0 4 0; +#X connect 3 0 11 0; +#X connect 3 1 5 0; +#X connect 3 1 6 0; +#X connect 4 0 1 0; +#X connect 5 0 1 0; +#X connect 6 0 0 0; +#X connect 7 0 0 0; +#X connect 8 0 10 0; +#X connect 9 0 0 0; +#X connect 10 0 5 0; +#X connect 10 1 9 0; +#X connect 11 0 7 0; +#X connect 11 1 13 0; +#X connect 13 0 14 0; +#X connect 13 1 12 0; +#X connect 14 0 15 0; +#X restore 577 115 pd gemwin; +#X msg 577 96 destroy; +#X text 573 75 Create window:; +#X msg 184 350 link \$1 \$2; +#X obj 154 264 glsl_vertex; +#X obj 154 307 glsl_fragment; +#X obj 168 150 loadbang; +#X obj 154 399 glsl_program; +#X obj 154 673 gemvertexbuffer; +#X obj 154 116 gemhead; +#X obj 36 403 tgl 15 1 empty empty empty 17 7 0 10 -262144 -1 -1 1 +1; +#X msg 36 433 position_enable \$1; +#X msg 105 366 print; +#X msg 101 278 print; +#X msg 103 233 print; +#X obj 246 548 cnv 15 90 40 empty empty empty 20 12 0 14 -204786 -66577 +0; +#X msg 255 559 program \$1; +#X obj 30 544 cnv 15 120 70 empty empty empty 20 12 0 14 -204786 -66577 +0; +#X msg 39 583 print_attributes; +#X msg 38 556 reset_attributes; +#X obj 27 487 cnv 15 140 40 empty empty empty 20 12 0 14 -204786 -66577 +0; +#X obj 36 465 tgl 15 1 empty empty empty 17 7 0 10 -262144 -1 -1 1 +1; +#X msg 36 498 attribute_enable \$1; +#X msg 223 475 position \$1_position \, attribute LightPosition \$1_LightPosition +\, attribute BrickColor \$1_BrickColor \, attribute MortarColor \$1_MortarColor +\, attribute BrickSize \$1_BrickSize \, attribute BrickPct \$1_BrickPct +; +#X obj 224 612 loadbang; +#X msg 224 629 resize 16 \, draw quad; +#X text 378 629 4 quads; +#X obj 168 179 t b b; +#X obj 223 421 t b f; +#X text 406 232 syntax:; +#X text 339 559 <----- essential for lookup functions; +#X text 406 248 attribute <name> <array> <offset(optional)>; +#X obj 358 431 print linking; +#X obj 184 372 t a a; +#N canvas 359 182 450 300 tables 0; +#N canvas 816 49 460 613 load_tables 0; +#X obj 39 17 loadbang; +#X msg 39 106 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0.5 0.5 1 0.5 0.5 1 0.5 0.5 +1 0.5 0.5 0 0.5 0.6 0 0.5 0.6 0 0.5 0.6 0 0.5 0.6 1 1 1 1 1 1 1 1 1 +1 1 1; +#X obj 39 149 s \$0_BrickColor; +#X msg 39 170 0 0.92 0.9 0.92 0.9 0.92 0.9 0.92 0.9 0.92 0.9 0.92 0.9 +0.92 0.9 0.92 0.9 0.82 0.7 0.82 0.7 0.82 0.7 0.82 0.7 0.92 0.9 0.92 +0.9 0.92 0.9 0.92 0.9; +#X obj 39 213 s \$0_BrickPct; +#X msg 39 266 0 0.32 0.2 0.32 0.2 0.32 0.2 0.32 0.2 0.32 0.2 0.32 0.2 +0.32 0.2 0.32 0.2 0.92 0.45 0.92 0.45 0.92 0.45 0.92 0.45 0.62 0.2 +0.62 0.2 0.62 0.2 0.62 0.2; +#X obj 39 309 s \$0_BrickSize; +#X msg 39 357 0 -3 -1 -0.2 -3 -1 -0.2 -3 -1 -0.2 -3 -1 -0.2 -3 -1 -0.2 +-3 -1 -0.2 -3 -1 -0.2 -3 -1 -0.2 3.5 -6 -0.4 3.5 -6 -0.4 3.5 -6 -0.4 +3.5 -6 -0.4 -3 -1 -0.2 -3 -1 -0.2 -3 -1 -0.2 -3 -1 -0.2; +#X obj 39 400 s \$0_LightPosition; +#X msg 39 505 0 -3.25 3.25 0 -0.75 3.25 0 -0.75 0.75 0 -3.25 0.75 0 +0.75 3.25 0 3.25 3.25 0 3.25 0.75 0 0.75 0.75 0 0.75 -0.75 0 3.25 -0.75 +0 3.25 -3.25 0 0.75 -3.25 0 -3.25 -0.75 0 -0.75 -0.75 0 -0.75 -3.25 +0 -3.25 -3.25 0; +#X obj 39 561 s \$0_position; +#X msg 39 437 0 1 0.5 0.5 1 0.5 0.5 1 0.5 0.5 1 0.5 0.5 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0; +#X obj 39 467 s \$0_MortarColor; +#X obj 39 39 t b b b b b b; +#X msg 133 15 bang; +#X connect 0 0 13 0; +#X connect 1 0 2 0; +#X connect 3 0 4 0; +#X connect 5 0 6 0; +#X connect 7 0 8 0; +#X connect 9 0 10 0; +#X connect 11 0 12 0; +#X connect 13 0 1 0; +#X connect 13 1 3 0; +#X connect 13 2 5 0; +#X connect 13 3 7 0; +#X connect 13 4 11 0; +#X connect 13 5 9 0; +#X connect 14 0 13 0; +#X restore 129 244 pd load_tables; +#X obj 129 66 table \$0_position 48; +#X obj 129 87 table \$0_LightPosition 48; +#X obj 129 108 table \$0_BrickColor 48; +#X obj 129 128 table \$0_MortarColor 48; +#X obj 129 149 table \$0_BrickSize 32; +#X obj 128 169 table \$0_BrickPct 32; +#X restore 754 73 pd tables; +#X obj 223 443 list prepend \$0; +#X obj 396 298 cnv 15 90 40 empty empty empty 20 12 0 14 -204786 -66577 +0; +#X obj 396 348 cnv 15 90 40 empty empty empty 20 12 0 14 -204786 -66577 +0; +#X msg 408 310 attribute LightPosition \$1_LightPosition; +#N canvas 268 270 483 439 more 0; +#X text 66 43 syntax:; +#X text 67 95 adds an attribute to gemvertexbuffer; +#X text 67 127 if the attribute already exists in gemvertexbuffer \, +this message updates the attribute with the array data; +#X text 66 60 attribute <name> <array> <offset(optional)>; +#X text 66 281 attribute tables are interleaved only; +#X text 64 177 if the vert or frag files are changed \, the attributes +in gemvertexbuffer can be reset with a "reset_attributes" msg and re-added +; +#X text 65 236 there is no limit for the amount of attributes that +can be added; +#X text 66 321 in order to set 'uniform' type variables once per vertex +or geo \, they must be changed to attribute/varying type in the vert +and frag files; +#X restore 407 359 pd more; +#X obj 164 646 t a; +#X obj 301 663 print vb; +#X msg 246 176 bang; +#X msg 168 207 open ../data/brick.vert; +#X msg 195 234 open ../data/brick.frag; +#N canvas 1 51 450 300 modulelist 0; +#X obj 81 44 inlet; +#X obj 248 55 inlet; +#X obj 81 172 outlet; +#X obj 81 66 t b f; +#X obj 81 128 pack 0 0 0; +#X obj 81 150 route 0; +#X obj 81 98 del 0; +#X connect 0 0 3 0; +#X connect 1 0 4 2; +#X connect 3 0 6 0; +#X connect 3 1 4 1; +#X connect 4 0 5 0; +#X connect 5 0 2 0; +#X connect 6 0 4 0; +#X restore 184 330 pd modulelist; +#X msg 272 416 bang; +#X connect 0 0 1 0; +#X connect 2 0 3 0; +#X connect 3 0 2 0; +#X connect 5 0 35 0; +#X connect 6 0 7 0; +#X connect 6 1 47 1; +#X connect 7 0 9 0; +#X connect 7 1 47 0; +#X connect 8 0 29 0; +#X connect 9 0 10 0; +#X connect 9 1 30 0; +#X connect 11 0 6 0; +#X connect 12 0 13 0; +#X connect 13 0 42 0; +#X connect 14 0 9 0; +#X connect 15 0 7 0; +#X connect 16 0 6 0; +#X connect 18 0 42 0; +#X connect 20 0 42 0; +#X connect 21 0 42 0; +#X connect 23 0 24 0; +#X connect 24 0 42 0; +#X connect 25 0 42 0; +#X connect 26 0 27 0; +#X connect 27 0 42 0; +#X connect 29 0 45 0; +#X connect 29 1 46 0; +#X connect 30 0 37 0; +#X connect 30 1 18 0; +#X connect 35 0 9 0; +#X connect 35 1 34 0; +#X connect 37 0 25 0; +#X connect 42 0 10 0; +#X connect 42 0 43 0; +#X connect 44 0 29 0; +#X connect 45 0 6 0; +#X connect 46 0 7 0; +#X connect 47 0 5 0; +#X connect 48 0 37 0; diff --git a/Gem/examples/data/brick.frag b/Gem/examples/data/brick.frag new file mode 100644 index 0000000..53e4f1b --- /dev/null +++ b/Gem/examples/data/brick.frag @@ -0,0 +1,24 @@ +varying vec3 BrickColor_f, MortarColor_f; +varying vec2 BrickSize_f, BrickPct_f; + +varying vec2 MCposition; +varying float LightIntensity; + + +void main() +{ + vec3 color; + vec2 position, useBrick; + position = MCposition / BrickSize_f; + + if (fract(position.y * 0.5) > 0.5) + position.x += 0.5; + + position = fract(position); + + useBrick = step(position, BrickPct_f); + + color = mix(MortarColor_f, BrickColor_f, useBrick.x * useBrick.y); + color *= LightIntensity; + gl_FragColor = vec4(color, 1.0); +}
\ No newline at end of file diff --git a/Gem/examples/data/brick.vert b/Gem/examples/data/brick.vert new file mode 100644 index 0000000..1a54a8b --- /dev/null +++ b/Gem/examples/data/brick.vert @@ -0,0 +1,43 @@ +attribute vec3 LightPosition; +attribute vec3 BrickColor, MortarColor; +attribute vec2 BrickSize, BrickPct; + +varying vec3 BrickColor_f, MortarColor_f; +varying vec2 BrickSize_f, BrickPct_f; + + +const float SpecularContribution = 0.3; +const float DiffuseContribution = 1.0 - SpecularContribution; + +varying float LightIntensity; +varying vec2 MCposition; + +void main() +{ + // conversions + BrickColor_f = BrickColor; + MortarColor_f = MortarColor; + BrickSize_f = BrickSize; + BrickPct_f = BrickPct; + // + + vec3 ecPosition = vec3(gl_ModelViewMatrix * gl_Vertex); + vec3 tnorm = normalize(gl_NormalMatrix * gl_Normal); + vec3 lightVec = normalize(LightPosition - ecPosition); + vec3 reflectVec = reflect(-lightVec, tnorm); + vec3 viewVec = normalize(-ecPosition); + float diffuse = max(dot(lightVec, tnorm), 0.0); + float spec = 0.0; + + if (diffuse > 0.0) + { + spec = max(dot(reflectVec, viewVec), 0.0); + spec = pow(spec, 16.0); + } + + LightIntensity = DiffuseContribution * diffuse + + SpecularContribution * spec; + + MCposition = gl_Vertex.xy; + gl_Position = ftransform(); +} |