[GEM-dev] Fwd: Re: Oculus Rift distortion/support

Michael Mihocic michael.mihocic at oeaw.ac.at
Sun Oct 27 18:51:33 CET 2013


Hy Cyrille,

thank you again for your quick reply!!
Good idea, I also replied to the Gem list! (I'm not registered at the pd 
list...)
(Sorry, if someone might be annoyed about my attachments...)

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.... ;-)

My example consists of:
- rift_list.pd        -> is the pd patch to be started, follow the 
instructions on top of the file
- riftshader.pd is used for the distortion parameters, when using the 
shaders:
- r4.frag/r4.vert are the shader files
- test.jpg is just any test file which will be distorted

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.
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))
-> theoretically, my perfect solution would be to apply the distortion 
to "the entire stereo gemwin" somehow!? ;-)

Following the idea of your patch and introducing gemframebuffers, do you 
think I can realize it that way:
- every object needs to be rendered twice instead of once, and in a 
framebuffer, sent to the abstraction "gemhead_rift"
- the barrel distortion is applied in the abstraction "gemhead_rift", 
the parameters depending on left or right
- instead of using "stereo", I create a wider window and add 
X-axis-translation

Do you think it should work that way?

Br, Michael

-------- Original-Nachricht --------
Betreff: Re: [GEM-dev] Oculus Rift distortion/support
Von: Cyrille Henry <ch at chnry.net>
An: Michael Mihocic <michael.mihocic at oeaw.ac.at>, pd-liste List 
<PD-list at iem.at>
Datum: 27.10.2013 15:59
> hello Michael,
>
> i copy this mail to pd list, since it is of generic interest.
>
>
> but first : did anyone have a working example of oculus rift in GEM?
>
> 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.
>
> Ideally, you would use stereo parametter to render in a framebuffer, 
> then render the framebuffer through a shader in the main windows 
> (whitout stereo).
> but i dont thing you can do that in Gem.
>
>
> Here is how i would do it.
> 2 framebuffer, and an abstraction that render primitive in the 2 
> framebuffer.
> 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.
>
> some things need to be adjusted (angle of view of the virtual cam / 
> eyes distance /framebuffer size, etc).
> and the shader has to be added...
>
> Cheers
> c
>
> Le 26/10/2013 17:58, Michael Mihocic a écrit :
>> Hi Cyrille,
>>
>> 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!!
>>
>> You proposed a solution (your Email below) how to implement the 
>> barrel distortion to our virtual world:
>> /"1st : left eye view without distortion, rendered in a frame buffer //
>> //2nd : right eye view (no distortion / framebuffer) //
>> //3rd : using the 2 previous texture and a shader, render the final 
>> image"/
>>
>> I'm still having some questions:
>> 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).
>> 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??
>> If not: Will I still be able to use the "stereo" parameter in gemwin??
>>
>> 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??
>>
>> 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.
>>
>> Best regards, Michael
>>
>>
>> Our current view:
>>
>>
>> Desired Rift distortion:
>>
>>
>>
>>
>> -------- Original-Nachricht --------
>> Betreff: Re: [GEM-dev] Oculus Rift distortion/support
>> Von: Cyrille Henry <ch at chnry.net>
>> An: Michael Mihocic <michael.mihocic at oeaw.ac.at>
>> Kopie (CC): gem-dev at iem.at
>> Datum: 25.07.2013 12:17
>>> hello,
>>>
>>> one have to use shader in order create the image distortion.
>>>
>>> i think oculus should provide standard shader that you have to 
>>> insert in your rendering process.
>>>
>>> the only problem is that you have to do 2 rendering : one for each eye.
>>> The best solution is to do a 3 pass rendering :
>>> 1st : left eye view without distortion, rendered in a frame buffer
>>> 2nd : right eye view (no distortion / framebuffer)
>>> 3rd : using the 2 previous texture and a shader, render the final image
>>>
>>> cheers
>>> c
>>>
>>>
>>> Le 25/07/2013 12:04, Michael Mihocic a écrit :
>>>> Dear list,
>>>>
>>>> we are using GEM with a head-mounted-display to present a virtual 
>>>> world to subjects performing acoustic localization experiments.
>>>>
>>>> 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.)
>>>>
>>>> My questions now:
>>>> - Is there an easy solution to implement barrel distortion to the 
>>>> rendered window in GEM?
>>>> - Does anybody of you already have some experience with GEM 
>>>> together with Oculus Rift?
>>>>
>>>> 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.
>>>>
>>>> Thanks in advance and best regards, Michael
>>>>
>>
>> -- 
>> Michael Mihocic
>> Psychoacoustics & Experimental Audiology
>> Acoustics Research Institute <http://www.kfs.oeaw.ac.at/>
>> Austrian Academy Of Sciences <http://www.oeaw.ac.at/>
>> Wohllebengasse 12-14 / 1
>> A-1040 Vienna, Austria
>> Tel: +43 (1) 51581 2515 (Office)
>> Tel: +43 (1) 51581 2525 (Lab)
>> Fax: +43 (1) 51581 2530
>> michael.mihocic at oeaw.ac.at <mailto:michael.mihocic at oeaw.ac.at>
>

-- 
Michael Mihocic
Psychoacoustics & Experimental Audiology
Acoustics Research Institute <http://www.kfs.oeaw.ac.at/>
Austrian Academy Of Sciences <http://www.oeaw.ac.at/>
Wohllebengasse 12-14 / 1
A-1040 Vienna, Austria
Tel: +43 (1) 51581 2515 (Office)
Tel: +43 (1) 51581 2525 (Lab)
Fax: +43 (1) 51581 2530
michael.mihocic at oeaw.ac.at <mailto:michael.mihocic at oeaw.ac.at>

rift_list.pd


#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;


riftshader.pd


#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;


r4.vert


varying vec2 vTex;
void main() {
    gl_TexCoord[0] = gl_MultiTexCoord0;
    gl_Position = gl_Vertex;
//   texIn = gl_MultiTexCoord0.xy;
vTex = gl_MultiTexCoord0.xy;
}


test.jpg



r4.frag


#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);
}

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/gem-dev/attachments/20131027/d04e1e07/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/jpeg
Size: 54200 bytes
Desc: not available
URL: <http://lists.puredata.info/pipermail/gem-dev/attachments/20131027/d04e1e07/attachment-0001.jpeg>
-------------- next part --------------
#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;

-------------- next part --------------
#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;

-------------- next part --------------
varying vec2 vTex;
void main() {
   gl_TexCoord[0] = gl_MultiTexCoord0;
   gl_Position = gl_Vertex;
//   texIn = gl_MultiTexCoord0.xy;
vTex = gl_MultiTexCoord0.xy;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.jpg
Type: image/jpeg
Size: 54200 bytes
Desc: not available
URL: <http://lists.puredata.info/pipermail/gem-dev/attachments/20131027/d04e1e07/attachment-0001.jpg>
-------------- next part --------------
#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);
}


More information about the GEM-dev mailing list