<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1252">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-text-html" lang="x-western"> Hy Cyrille,<br>
<br>
thank you again for your quick reply!!<br>
Good idea, I also replied to the Gem list! (I'm not registered at
the pd list...)<br>
(Sorry, if someone might be annoyed about my attachments...)<br>
<br>
Attached you can find my progress so far but I have to mention
that my scripts are still "under construction" - and not only the
parameters far from optimized.... ;-)<br>
<br>
My example consists of:<br>
- rift_list.pd -> is the pd patch to be started, follow
the instructions on top of the file<br>
- riftshader.pd is used for the distortion parameters, when using
the shaders:<br>
- r4.frag/r4.vert are the shader files<br>
- test.jpg is just any test file which will be distorted<br>
<br>
I'm not using gemframebuffers in my patch. Currently I am simply
loading 2 times the same image and processing the barrel
distortions on each half of the image, left and right.<br>
But as I described below, our actual world does not consist of one
image but of many objects (spheres, cubes, lines,...) within a big
sphere, and the user can rotate his head inside the sphere.
((tracking will not be done with Oculus Rift tracker))<br>
-> theoretically, my perfect solution would be to apply the
distortion to "the entire stereo gemwin" somehow!? ;-)<br>
<br>
Following the idea of your patch and introducing gemframebuffers,
do you think I can realize it that way:<br>
- every object needs to be rendered twice instead of once, and in
a framebuffer, sent to the abstraction "gemhead_rift"<br>
- the barrel distortion is applied in the abstraction
"gemhead_rift", the parameters depending on left or right<br>
- instead of using "stereo", I create a wider window and add
X-axis-translation<br>
<br>
Do you think it should work that way?<br>
<br>
Br, Michael<br>
<br>
<div class="moz-cite-prefix">-------- Original-Nachricht --------<br>
Betreff: Re: [GEM-dev] Oculus Rift distortion/support<br>
Von: Cyrille Henry <a class="moz-txt-link-rfc2396E"
href="mailto:ch@chnry.net"><ch@chnry.net></a><br>
An: Michael Mihocic <a class="moz-txt-link-rfc2396E"
href="mailto:michael.mihocic@oeaw.ac.at"><michael.mihocic@oeaw.ac.at></a>,
pd-liste List <a class="moz-txt-link-rfc2396E"
href="mailto:PD-list@iem.at"><PD-list@iem.at></a><br>
Datum: 27.10.2013 15:59<br>
</div>
<blockquote cite="mid:526D2A5B.6020101@chnry.net" type="cite">hello
Michael, <br>
<br>
i copy this mail to pd list, since it is of generic interest. <br>
<br>
<br>
but first : did anyone have a working example of oculus rift in
GEM? <br>
<br>
Rendering on stereo is a nice idea, but as you noticed, in order
to "sumarized" all the object it's easier to render in a
framebuffer then distord this resulting image. <br>
<br>
Ideally, you would use stereo parametter to render in a
framebuffer, then render the framebuffer through a shader in the
main windows (whitout stereo). <br>
but i dont thing you can do that in Gem. <br>
<br>
<br>
Here is how i would do it. <br>
2 framebuffer, and an abstraction that render primitive in the 2
framebuffer. <br>
then render this 2 framebuffer in the main windows with a
shader, or merge this 2 FB in a 3d one and render this last FB
with the shader. <br>
<br>
some things need to be adjusted (angle of view of the virtual
cam / eyes distance /framebuffer size, etc). <br>
and the shader has to be added... <br>
<br>
Cheers <br>
c <br>
<br>
Le 26/10/2013 17:58, Michael Mihocic a écrit : <br>
<blockquote type="cite">Hi Cyrille, <br>
<br>
I am still working on the Oculus Rift implementation and I
finally managed to get some basic knowledge with shaders.
However, now I know how to use shaders in Gem and on my
Windows OS and I already played around with simple barrrel
distortion examples... Thank you again for your previous
support!! <br>
<br>
You proposed a solution (your Email below) how to implement
the barrel distortion to our virtual world: <br>
/"1st : left eye view without distortion, rendered in a frame
buffer // <br>
//2nd : right eye view (no distortion / framebuffer) // <br>
//3rd : using the 2 previous texture and a shader, render the
final image"/ <br>
<br>
I'm still having some questions: <br>
1.) Our current world is using the gemwin "stereo" parameter
to create 2 images (-> actually it is one Gem window, but
we adjusted resolution and size to fit it to our old HMD and
each eye can see only half of the image; see attachement). <br>
I'm wondering if it possible to use just ONE shader to render
the entire image in one step?? But I'm not sure if this is
possible with texturing?? <br>
If not: Will I still be able to use the "stereo" parameter in
gemwin?? <br>
<br>
2.) As you can see in my screenshot: our world consists of
many objects (cubes, lines, fadecrosses, spheres, ...). How
can I summarize those objects, before processing them? Do I
need to use a gemframebuffer for every single object?? <br>
<br>
My plan is to finish in 1(-2) months. If everything is
working, I will provide the example patch & shaders to the
pd/Gem community. <br>
<br>
Best regards, Michael <br>
<br>
<br>
Our current view: <br>
<br>
<br>
Desired Rift distortion: <br>
<br>
<br>
<br>
<br>
-------- Original-Nachricht -------- <br>
Betreff: Re: [GEM-dev] Oculus Rift distortion/support <br>
Von: Cyrille Henry <a class="moz-txt-link-rfc2396E"
href="mailto:ch@chnry.net"><ch@chnry.net></a> <br>
An: Michael Mihocic <a class="moz-txt-link-rfc2396E"
href="mailto:michael.mihocic@oeaw.ac.at"><michael.mihocic@oeaw.ac.at></a>
<br>
Kopie (CC): <a class="moz-txt-link-abbreviated"
href="mailto:gem-dev@iem.at">gem-dev@iem.at</a> <br>
Datum: 25.07.2013 12:17 <br>
<blockquote type="cite">hello, <br>
<br>
one have to use shader in order create the image distortion.
<br>
<br>
i think oculus should provide standard shader that you have
to insert in your rendering process. <br>
<br>
the only problem is that you have to do 2 rendering : one
for each eye. <br>
The best solution is to do a 3 pass rendering : <br>
1st : left eye view without distortion, rendered in a frame
buffer <br>
2nd : right eye view (no distortion / framebuffer) <br>
3rd : using the 2 previous texture and a shader, render the
final image <br>
<br>
cheers <br>
c <br>
<br>
<br>
Le 25/07/2013 12:04, Michael Mihocic a écrit : <br>
<blockquote type="cite">Dear list, <br>
<br>
we are using GEM with a head-mounted-display to present a
virtual world to subjects performing acoustic localization
experiments. <br>
<br>
Now we plan to switch from our current HMD to Oculus Rift
(an upcoming virtual reality head-mounted display).
Therefore we need to modify our image and add (asymetric)
barrel distortion to the represented image. (The image
distortion is compensated by the lenses in Oculus Rift.) <br>
<br>
My questions now: <br>
- Is there an easy solution to implement barrel distortion
to the rendered window in GEM? <br>
- Does anybody of you already have some experience with
GEM together with Oculus Rift? <br>
<br>
Since attachments should be avoided in this list, I do not
send any example pictures of the distortion or our current
presented world. If you are interested you can either
contact me and I can send you some screenshots, or you can
google for example images/videos of Oculus Rift
distortion. <br>
<br>
Thanks in advance and best regards, Michael <br>
<br>
</blockquote>
</blockquote>
<br>
-- <br>
Michael Mihocic <br>
Psychoacoustics & Experimental Audiology <br>
Acoustics Research Institute <a class="moz-txt-link-rfc2396E"
href="http://www.kfs.oeaw.ac.at/"><http://www.kfs.oeaw.ac.at/></a>
<br>
Austrian Academy Of Sciences <a class="moz-txt-link-rfc2396E"
href="http://www.oeaw.ac.at/"><http://www.oeaw.ac.at/></a>
<br>
Wohllebengasse 12-14 / 1 <br>
A-1040 Vienna, Austria <br>
Tel: +43 (1) 51581 2515 (Office) <br>
Tel: +43 (1) 51581 2525 (Lab) <br>
Fax: +43 (1) 51581 2530 <br>
<a class="moz-txt-link-abbreviated"
href="mailto:michael.mihocic@oeaw.ac.at">michael.mihocic@oeaw.ac.at</a>
<a class="moz-txt-link-rfc2396E"
href="mailto:michael.mihocic@oeaw.ac.at"><mailto:michael.mihocic@oeaw.ac.at></a>
<br>
</blockquote>
<br>
</blockquote>
<br>
<div class="moz-signature">-- <br>
Michael Mihocic<br>
Psychoacoustics & Experimental Audiology<br>
<a href="http://www.kfs.oeaw.ac.at/">Acoustics Research
Institute</a><br>
<a href="http://www.oeaw.ac.at/">Austrian Academy Of Sciences</a><br>
Wohllebengasse 12-14 / 1<br>
A-1040 Vienna, Austria<br>
Tel: +43 (1) 51581 2515 (Office)<br>
Tel: +43 (1) 51581 2525 (Lab)<br>
Fax: +43 (1) 51581 2530<br>
<a href="mailto:michael.mihocic@oeaw.ac.at">michael.mihocic@oeaw.ac.at</a><br>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"><legend
class="mimeAttachmentHeaderName">rift_list.pd</legend></fieldset>
<br>
<div class="moz-text-plain" wrap="true" graphical-quote="true"
style="font-family: -moz-fixed; font-size: 14px;" lang="x-western">
<pre wrap="">#N canvas 201 333 988 542 10;
#X obj 48 105 gemhead;
#N canvas 87 154 359 202 Gem.init 0;
#X obj 118 46 loadbang;
#X msg 118 81 reset;
#X obj 118 113 outlet;
#X connect 0 0 1 0;
#X connect 1 0 2 0;
#X restore 65 16 pd Gem.init;
#N canvas 340 107 682 322 gemwin 0;
#X obj 102 122 tgl 15 0 \$0-gemstart \$0-gemstart empty 17 7 0 10 -262144
-1 -1 0 1;
#X obj 102 161 r \$0-gemstart;
#X obj 102 182 select 1 0;
#X msg 102 214 create \, 1;
#X msg 177 215 destroy;
#X obj 102 239 t a;
#X obj 318 54 inlet;
#X obj 318 255 gemwin;
#X obj 318 100 t a a;
#X obj 318 287 outlet;
#X obj 350 128 route create destroy;
#X obj 350 150 t b;
#X msg 350 172 1;
#X obj 390 150 t b;
#X msg 390 172 0;
#X obj 350 195 t f;
#X msg 350 219 set \$1;
#X text 118 122 rendering;
#X connect 1 0 2 0;
#X connect 2 0 3 0;
#X connect 2 1 4 0;
#X connect 3 0 5 0;
#X connect 4 0 5 0;
#X connect 5 0 8 0;
#X connect 6 0 8 0;
#X connect 7 0 9 0;
#X connect 8 0 7 0;
#X connect 8 1 10 0;
#X connect 10 0 11 0;
#X connect 10 1 13 0;
#X connect 11 0 12 0;
#X connect 12 0 15 0;
#X connect 13 0 14 0;
#X connect 14 0 15 0;
#X connect 15 0 16 0;
#X connect 16 0 0 0;
#X coords 0 -1 1 1 85 40 1 100 100;
#X restore 48 46 pd gemwin;
#X obj 47 454 pix_texture;
#X obj 47 486 square 1;
#N canvas 612 313 979 621 riftshader 0;
#X obj 36 488 glsl_program;
#X obj 110 276 pack 0 0;
#X obj 131 256 t b f;
#X obj 127 211 change;
#X obj 109 92 change;
#X msg 110 302 link \$1 \$2;
#X floatatom 131 237 2 0 0 0 ID - -;
#X floatatom 109 115 2 0 0 0 ID - -;
#X obj 128 323 print linking;
#X obj 37 73 glsl_vertex;
#X obj 37 191 glsl_fragment;
#X text 137 50 <- load shader;
#X floatatom 152 493 0 0 0 0 - - -;
#X msg 51 52 open r4.vert;
#X msg 47 141 open r4.frag;
#X obj 37 11 inlet;
#X obj 425 38 inlet;
#X msg 268 324 Scale 0.175 0.175;
#X floatatom 801 364 5 0 0 0 - - -;
#X msg 669 364 ScreenCenter \$1 0.5;
#X obj 639 536 print;
#X floatatom 801 396 5 0 0 0 - - -;
#X msg 671 394 LensCenter \$1 0.5;
#X msg 669 474 Scale \$1 \$1;
#X floatatom 797 455 5 0 0 0 - - -;
#X floatatom 796 483 5 0 0 0 - - -;
#X msg 668 502 ScaleIn \$1 \$1;
#X obj 839 396 pow 2;
#X floatatom 885 398 5 0 0 0 - - -;
#X obj 845 363 pow 2;
#X floatatom 891 365 5 0 0 0 - - -;
#X msg 723 529 HmdWarpParam 1 1.7 0.7 15;
#X msg 270 284 HmdWarpParam 1 0.22 0.24 0;
#X msg 288 364 ScaleIn 4 4;
#X msg 623 121 Scale 0.25 0.5;
#X msg 625 150 ScaleIn 4 2;
#X msg 270 216 ScreenCenter 0.25 0.5;
#X msg 420 215 ScreenCenter 0.75 0.5;
#X msg 271 246 LensCenter 0.26 0.5;
#X msg 420 246 LensCenter 0.74 0.5;
#X obj 36 535 outlet;
#X obj 269 151 t b b b b b;
#X obj 475 121 print;
#X obj 276 25 inlet;
#X obj 339 20 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
-1;
#X obj 264 59 t b b;
#X obj 254 113 del 200;
#X obj 397 148 print;
#X obj 212 151 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144
-1 -1;
#X connect 0 0 40 0;
#X connect 0 1 12 0;
#X connect 1 0 5 0;
#X connect 2 0 1 0;
#X connect 2 1 1 1;
#X connect 3 0 6 0;
#X connect 4 0 7 0;
#X connect 5 0 0 0;
#X connect 5 0 8 0;
#X connect 5 0 48 0;
#X connect 6 0 2 0;
#X connect 7 0 1 0;
#X connect 9 0 10 0;
#X connect 9 1 4 0;
#X connect 10 0 0 0;
#X connect 10 1 3 0;
#X connect 13 0 9 0;
#X connect 14 0 10 0;
#X connect 15 0 9 0;
#X connect 16 0 0 0;
#X connect 16 0 42 0;
#X connect 17 0 0 0;
#X connect 18 0 19 0;
#X connect 19 0 20 0;
#X connect 21 0 22 0;
#X connect 23 0 20 0;
#X connect 24 0 23 0;
#X connect 25 0 26 0;
#X connect 26 0 20 0;
#X connect 27 0 21 0;
#X connect 28 0 27 0;
#X connect 29 0 18 0;
#X connect 30 0 29 0;
#X connect 32 0 0 0;
#X connect 33 0 0 0;
#X connect 36 0 0 0;
#X connect 38 0 0 0;
#X connect 41 0 36 0;
#X connect 41 1 38 0;
#X connect 41 2 32 0;
#X connect 41 3 17 0;
#X connect 41 4 33 0;
#X connect 43 0 45 0;
#X connect 44 0 45 0;
#X connect 45 1 13 0;
#X connect 45 1 14 0;
#X connect 46 0 41 0;
#X connect 46 0 47 0;
#X connect 48 0 46 0;
#X restore 48 171 pd riftshader;
#X msg 213 229 ScreenCenter 0.75 0.5;
#X msg 212 253 LensCenter 0.74 0.5;
#X msg 64 230 ScreenCenter 0.25 0.5;
#X msg 64 252 LensCenter 0.26 0.5;
#X obj 270 95 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
-1;
#X obj 301 97 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
-1;
#X text 263 76 left;
#X text 293 74 right;
#X obj 125 115 loadbang;
#X obj 200 116 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144
-1 -1;
#X text 276 54 Left;
#X obj 75 361 translateXYZ 0 0 -4;
#N canvas 370 126 407 295 init 0;
#X obj 106 175 outlet;
#X msg 125 89 type FLOAT;
#X obj 124 68 loadbang;
#X msg 146 109 dimen 1024 1024;
#X msg 211 147 rectangle 0;
#X connect 1 0 0 0;
#X connect 2 0 1 0;
#X connect 2 0 3 0;
#X connect 2 0 4 0;
#X connect 3 0 0 0;
#X connect 4 0 0 0;
#X restore 191 308 pd init;
#X msg 88 297 texunit 1;
#X obj 75 339 gemframebuffer;
#X obj 433 102 gemhead;
#X obj 432 451 pix_texture;
#X obj 432 483 square 1;
#N canvas 612 313 979 621 riftshader 0;
#X obj 36 488 glsl_program;
#X obj 110 276 pack 0 0;
#X obj 131 256 t b f;
#X obj 127 211 change;
#X obj 109 92 change;
#X msg 110 302 link \$1 \$2;
#X floatatom 131 237 2 0 0 0 ID - -;
#X floatatom 109 115 2 0 0 0 ID - -;
#X obj 128 323 print linking;
#X obj 37 73 glsl_vertex;
#X obj 37 191 glsl_fragment;
#X text 137 50 <- load shader;
#X floatatom 152 493 0 0 0 0 - - -;
#X msg 51 52 open r4.vert;
#X msg 47 141 open r4.frag;
#X obj 37 11 inlet;
#X obj 425 38 inlet;
#X msg 268 324 Scale 0.175 0.175;
#X floatatom 801 364 5 0 0 0 - - -;
#X msg 669 364 ScreenCenter \$1 0.5;
#X obj 639 536 print;
#X floatatom 801 396 5 0 0 0 - - -;
#X msg 671 394 LensCenter \$1 0.5;
#X msg 669 474 Scale \$1 \$1;
#X floatatom 797 455 5 0 0 0 - - -;
#X floatatom 796 483 5 0 0 0 - - -;
#X msg 668 502 ScaleIn \$1 \$1;
#X obj 839 396 pow 2;
#X floatatom 885 398 5 0 0 0 - - -;
#X obj 845 363 pow 2;
#X floatatom 891 365 5 0 0 0 - - -;
#X msg 723 529 HmdWarpParam 1 1.7 0.7 15;
#X msg 270 284 HmdWarpParam 1 0.22 0.24 0;
#X msg 288 364 ScaleIn 4 4;
#X msg 623 121 Scale 0.25 0.5;
#X msg 625 150 ScaleIn 4 2;
#X msg 270 216 ScreenCenter 0.25 0.5;
#X msg 420 215 ScreenCenter 0.75 0.5;
#X msg 271 246 LensCenter 0.26 0.5;
#X msg 420 246 LensCenter 0.74 0.5;
#X obj 36 535 outlet;
#X obj 269 151 t b b b b b;
#X obj 475 121 print;
#X obj 276 25 inlet;
#X obj 339 20 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
-1;
#X obj 264 59 t b b;
#X obj 254 113 del 200;
#X obj 397 148 print;
#X obj 212 151 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144
-1 -1;
#X connect 0 0 40 0;
#X connect 0 1 12 0;
#X connect 1 0 5 0;
#X connect 2 0 1 0;
#X connect 2 1 1 1;
#X connect 3 0 6 0;
#X connect 4 0 7 0;
#X connect 5 0 0 0;
#X connect 5 0 8 0;
#X connect 5 0 48 0;
#X connect 6 0 2 0;
#X connect 7 0 1 0;
#X connect 9 0 10 0;
#X connect 9 1 4 0;
#X connect 10 0 0 0;
#X connect 10 1 3 0;
#X connect 13 0 9 0;
#X connect 14 0 10 0;
#X connect 15 0 9 0;
#X connect 16 0 0 0;
#X connect 16 0 42 0;
#X connect 17 0 0 0;
#X connect 18 0 19 0;
#X connect 19 0 20 0;
#X connect 21 0 22 0;
#X connect 23 0 20 0;
#X connect 24 0 23 0;
#X connect 25 0 26 0;
#X connect 26 0 20 0;
#X connect 27 0 21 0;
#X connect 28 0 27 0;
#X connect 29 0 18 0;
#X connect 30 0 29 0;
#X connect 32 0 0 0;
#X connect 33 0 0 0;
#X connect 36 0 0 0;
#X connect 38 0 0 0;
#X connect 41 0 36 0;
#X connect 41 1 38 0;
#X connect 41 2 32 0;
#X connect 41 3 17 0;
#X connect 41 4 33 0;
#X connect 43 0 45 0;
#X connect 44 0 45 0;
#X connect 45 1 13 0;
#X connect 45 1 14 0;
#X connect 46 0 41 0;
#X connect 46 0 47 0;
#X connect 48 0 46 0;
#X restore 433 168 pd riftshader;
#X msg 598 226 ScreenCenter 0.75 0.5;
#X msg 597 250 LensCenter 0.74 0.5;
#X msg 449 227 ScreenCenter 0.25 0.5;
#X msg 449 249 LensCenter 0.26 0.5;
#X obj 649 84 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
-1;
#X obj 680 86 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
-1;
#X text 642 65 left;
#X text 672 63 right;
#X obj 510 112 loadbang;
#X obj 585 113 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144
-1 -1;
#X obj 460 358 translateXYZ 0 0 -4;
#N canvas 370 126 407 295 init 0;
#X obj 106 175 outlet;
#X msg 125 89 type FLOAT;
#X obj 124 68 loadbang;
#X msg 146 109 dimen 1024 1024;
#X msg 211 147 rectangle 0;
#X connect 1 0 0 0;
#X connect 2 0 1 0;
#X connect 2 0 3 0;
#X connect 2 0 4 0;
#X connect 3 0 0 0;
#X connect 4 0 0 0;
#X restore 576 305 pd init;
#X msg 473 294 texunit 1;
#X obj 460 336 gemframebuffer;
#X text 647 43 right;
#X text 179 9 1 start rendering 2 left: click on "left" 3 right: click
on "right";
#X obj 48 427 pix_image test.jpg;
#X obj 433 424 pix_image test.jpg;
#X connect 0 0 5 0;
#X connect 1 0 2 0;
#X connect 3 0 4 0;
#X connect 5 0 41 0;
#X connect 6 0 5 2;
#X connect 7 0 5 2;
#X connect 8 0 5 2;
#X connect 9 0 5 2;
#X connect 10 0 8 0;
#X connect 10 0 9 0;
#X connect 11 0 6 0;
#X connect 11 0 7 0;
#X connect 14 0 5 1;
#X connect 14 0 19 0;
#X connect 15 0 5 1;
#X connect 19 0 20 0;
#X connect 20 0 17 0;
#X connect 21 0 24 0;
#X connect 22 0 23 0;
#X connect 24 0 42 0;
#X connect 25 0 24 2;
#X connect 26 0 24 2;
#X connect 27 0 24 2;
#X connect 28 0 24 2;
#X connect 29 0 27 0;
#X connect 29 0 28 0;
#X connect 30 0 25 0;
#X connect 30 0 26 0;
#X connect 33 0 24 1;
#X connect 33 0 37 0;
#X connect 34 0 24 1;
#X connect 37 0 38 0;
#X connect 38 0 35 0;
#X connect 41 0 3 0;
#X connect 42 0 22 0;
</pre>
</div>
<br>
<fieldset class="mimeAttachmentHeader"><legend
class="mimeAttachmentHeaderName">riftshader.pd</legend></fieldset>
<br>
<div class="moz-text-plain" wrap="true" graphical-quote="true"
style="font-family: -moz-fixed; font-size: 14px;" lang="x-western">
<pre wrap="">#N canvas 573 83 1074 782 10;
#X obj 46 498 glsl_program;
#X obj 120 286 pack 0 0;
#X obj 141 266 t b f;
#X obj 137 221 change;
#X obj 119 102 change;
#X msg 120 312 link \$1 \$2;
#X floatatom 141 247 2 0 0 0 ID - -;
#X floatatom 119 125 2 0 0 0 ID - -;
#X obj 138 333 print linking;
#X obj 47 83 glsl_vertex;
#X obj 47 201 glsl_fragment;
#X text 147 60 <- load shader;
#X floatatom 162 503 0 0 0 0 - - -;
#X msg 61 62 open r4.vert;
#X msg 57 151 open r4.frag;
#X obj 47 21 inlet;
#X obj 435 48 inlet;
#X msg 278 334 Scale 0.175 0.175;
#X floatatom 510 481 5 0 0 0 - - -;
#X msg 378 481 ScreenCenter \$1 0.5;
#X obj 348 653 print;
#X floatatom 510 513 5 0 0 0 - - -;
#X msg 380 511 LensCenter \$1 0.5;
#X msg 378 591 Scale \$1 \$1;
#X floatatom 506 572 5 0 0 0 - - -;
#X floatatom 505 600 5 0 0 0 - - -;
#X msg 377 619 ScaleIn \$1 \$1;
#X obj 548 513 pow 2;
#X floatatom 594 515 5 0 0 0 - - -;
#X obj 554 480 pow 2;
#X floatatom 600 482 5 0 0 0 - - -;
#X msg 432 646 HmdWarpParam 1 1.7 0.7 15;
#X msg 280 294 HmdWarpParam 1 0.22 0.24 0;
#X msg 298 374 ScaleIn 4 4;
#X msg 280 226 ScreenCenter 0.25 0.5;
#X msg 281 256 LensCenter 0.26 0.5;
#X obj 46 545 outlet;
#X obj 279 161 t b b b b b;
#X obj 485 131 print;
#X obj 286 35 inlet;
#X obj 349 30 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
-1;
#X obj 274 69 t b b;
#X obj 264 123 del 200;
#X obj 407 158 print;
#X obj 222 161 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144
-1 -1;
#X floatatom 681 323 5 0 0 0 - - -;
#X floatatom 718 323 5 0 0 0 - - -;
#X obj 577 341 pack 0 0;
#X msg 498 342 Scale \$1 \$2;
#X obj 633 341 t b f;
#X floatatom 682 365 5 0 0 0 - - -;
#X floatatom 724 365 5 0 0 0 - - -;
#X obj 583 380 pack 0 0;
#X obj 639 380 t b f;
#X msg 492 381 ScaleIn \$1 \$2;
#X floatatom 683 205 5 0 0 0 - - -;
#X floatatom 720 205 5 0 0 0 - - -;
#X obj 579 223 pack 0 0;
#X obj 635 223 t b f;
#X msg 456 223 ScreenCenter \$1 \$2;
#X floatatom 687 239 5 0 0 0 - - -;
#X floatatom 724 239 5 0 0 0 - - -;
#X obj 583 257 pack 0 0;
#X obj 639 257 t b f;
#X msg 460 257 LensCenter \$1 \$2;
#X floatatom 858 213 5 0 0 0 - - -;
#X floatatom 895 213 5 0 0 0 - - -;
#X obj 892 239 t b f;
#X obj 667 298 pack 0 0 0 0;
#X msg 471 299 HmdWarpParam \$1 \$2 \$3 \$4;
#X floatatom 936 213 5 0 0 0 - - -;
#X obj 933 239 t b f;
#X floatatom 978 214 5 0 0 0 - - -;
#X obj 975 240 t b f;
#X msg 765 103 0.5;
#X msg 614 75 0.25;
#X msg 621 146 0.26;
#X msg 862 158 1;
#X msg 901 160 0.22;
#X msg 942 162 0.24;
#X msg 985 162 0;
#X obj 802 30 loadbang;
#X msg 847 303 0.175;
#X msg 882 357 4;
#X msg 769 482 0.08;
#X msg 812 482 0.23;
#X msg 858 483 4.42;
#X obj 924 444 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144
-1 -1;
#X msg 774 527 0.58;
#X msg 819 526 0.51;
#X obj 933 520 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144
-1 -1;
#X text 948 454 left;
#X text 954 525 right;
#X connect 0 0 36 0;
#X connect 0 1 12 0;
#X connect 1 0 5 0;
#X connect 2 0 1 0;
#X connect 2 1 1 1;
#X connect 3 0 6 0;
#X connect 4 0 7 0;
#X connect 5 0 0 0;
#X connect 5 0 8 0;
#X connect 5 0 44 0;
#X connect 6 0 2 0;
#X connect 7 0 1 0;
#X connect 9 0 10 0;
#X connect 9 1 4 0;
#X connect 10 0 0 0;
#X connect 10 1 3 0;
#X connect 13 0 9 0;
#X connect 14 0 10 0;
#X connect 15 0 9 0;
#X connect 16 0 0 0;
#X connect 16 0 38 0;
#X connect 17 0 0 0;
#X connect 18 0 19 0;
#X connect 19 0 20 0;
#X connect 21 0 22 0;
#X connect 23 0 20 0;
#X connect 24 0 23 0;
#X connect 25 0 26 0;
#X connect 26 0 20 0;
#X connect 27 0 21 0;
#X connect 28 0 27 0;
#X connect 29 0 18 0;
#X connect 30 0 29 0;
#X connect 32 0 0 0;
#X connect 33 0 0 0;
#X connect 34 0 0 0;
#X connect 35 0 0 0;
#X connect 37 0 34 0;
#X connect 37 1 35 0;
#X connect 37 2 32 0;
#X connect 37 3 17 0;
#X connect 37 4 33 0;
#X connect 39 0 41 0;
#X connect 40 0 41 0;
#X connect 41 1 13 0;
#X connect 41 1 14 0;
#X connect 42 0 37 0;
#X connect 42 0 43 0;
#X connect 44 0 42 0;
#X connect 45 0 47 0;
#X connect 46 0 49 0;
#X connect 47 0 48 0;
#X connect 48 0 0 0;
#X connect 49 0 47 0;
#X connect 49 1 47 1;
#X connect 50 0 52 0;
#X connect 51 0 53 0;
#X connect 52 0 54 0;
#X connect 53 0 52 0;
#X connect 53 1 52 1;
#X connect 54 0 0 0;
#X connect 55 0 57 0;
#X connect 56 0 58 0;
#X connect 57 0 59 0;
#X connect 58 0 57 0;
#X connect 58 1 57 1;
#X connect 59 0 0 0;
#X connect 60 0 62 0;
#X connect 61 0 63 0;
#X connect 62 0 64 0;
#X connect 63 0 62 0;
#X connect 63 1 62 1;
#X connect 64 0 0 0;
#X connect 65 0 68 0;
#X connect 66 0 67 0;
#X connect 67 0 68 0;
#X connect 67 1 68 1;
#X connect 68 0 69 0;
#X connect 69 0 0 0;
#X connect 70 0 71 0;
#X connect 71 0 68 0;
#X connect 71 1 68 2;
#X connect 72 0 73 0;
#X connect 73 0 68 0;
#X connect 73 1 68 3;
#X connect 74 0 56 0;
#X connect 74 0 61 0;
#X connect 75 0 55 0;
#X connect 76 0 60 0;
#X connect 77 0 65 0;
#X connect 78 0 66 0;
#X connect 79 0 70 0;
#X connect 80 0 72 0;
#X connect 81 0 77 0;
#X connect 81 0 78 0;
#X connect 81 0 79 0;
#X connect 81 0 80 0;
#X connect 81 0 74 0;
#X connect 81 0 75 0;
#X connect 81 0 76 0;
#X connect 81 0 82 0;
#X connect 81 0 83 0;
#X connect 82 0 45 0;
#X connect 82 0 46 0;
#X connect 83 0 51 0;
#X connect 83 0 50 0;
#X connect 84 0 55 0;
#X connect 85 0 60 0;
#X connect 86 0 50 0;
#X connect 87 0 84 0;
#X connect 87 0 85 0;
#X connect 87 0 86 0;
#X connect 88 0 55 0;
#X connect 89 0 60 0;
#X connect 90 0 86 0;
#X connect 90 0 88 0;
#X connect 90 0 89 0;
</pre>
</div>
<br>
<fieldset class="mimeAttachmentHeader"><legend
class="mimeAttachmentHeaderName">r4.vert</legend></fieldset>
<br>
<div class="moz-text-plain" wrap="true" graphical-quote="true"
style="font-family: -moz-fixed; font-size: 14px;" lang="x-western">
<pre wrap="">varying vec2 vTex;
void main() {
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_Position = gl_Vertex;
// texIn = gl_MultiTexCoord0.xy;
vTex = gl_MultiTexCoord0.xy;
}</pre>
</div>
<br>
<fieldset class="mimeAttachmentHeader"><legend
class="mimeAttachmentHeaderName">test.jpg</legend></fieldset>
<br>
<center><img class="moz-attached-image" shrinktofit="yes"
src="cid:part14.00010807.05020906@oeaw.ac.at"></center>
<p><br>
</p>
<fieldset class="mimeAttachmentHeader"><legend
class="mimeAttachmentHeaderName">r4.frag</legend></fieldset>
<br>
<div class="moz-text-plain" wrap="true" graphical-quote="true"
style="font-family: -moz-fixed; font-size: 14px;" lang="x-western">
<pre wrap="">#define PROCESSING_TEXTURE_SHADER
uniform sampler2D texture;
varying vec4 vertTexCoord;
varying vec2 vTex;
uniform vec2 LensCenter;
uniform vec2 ScreenCenter;
uniform vec2 Scale;
uniform vec2 ScaleIn;
uniform vec4 HmdWarpParam;
vec2 HmdWarp(vec2 texIn)
{
vec2 theta = (texIn - LensCenter) * ScaleIn;
float rSq = theta.x * theta.x + theta.y * theta.y;
vec2 theta1 = theta * (HmdWarpParam.x + HmdWarpParam.y * rSq + HmdWarpParam.z * rSq * rSq + HmdWarpParam.w * rSq * rSq * rSq);
return LensCenter + Scale * theta1;
}
void main()
{
vec2 tc = HmdWarp(vTex); //gl_TexCoord[0].xy);
if (any(notEqual(clamp(tc, ScreenCenter-vec2(0.25,0.5), ScreenCenter+vec2(0.25, 0.5)) - tc, vec2(0.0, 0.0))))
discard; // gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); // ODER: discard;
else
gl_FragColor = texture2D(texture, tc);
}</pre>
</div>
</body>
</html>