stalgiag / p5.xr

a library that helps turn p5.js sketches into immersive experiences using WebXR
GNU Lesser General Public License v2.1
117 stars 25 forks source link

Equirectangular sketch #129

Open JuanIrache opened 3 years ago

JuanIrache commented 3 years ago

Hi, thanks for the super interesting library.

This is not a bug or feature request, rather a question that relates to this library tangentially. So I appreciate any pointers you may have, but feel free to close this if you don't.

I'm trying to draw p5 elements on top of a canvas that has a VR (equirectangular) image as a background. I'm not sure if your library has explored how p5 shapes have to be transformed when projected in a 360 space, or if this is handled separately by some other module. Of course if I use the standard p5 methods, shapes look fine on screen but are warped when viewed in VR. Would you know where I can find information on the topic? Is this a problem you have faced?

Really appreciated.

stalgiag commented 3 years ago

Hi! If I understand correctly you have an equirectangular image that you are using for a background and you are drawing p5 elements on top of it. The image itself is likely already warped for equirectangular perspective but the p5 elements are not so there is disonnance in their relative perspectives. Is this correct?

If so would it be possible to use the equirectangular texture as the background while drawing the p5 elements on a second layer as graphics object textures on a quad or plane? This way the perspective of the geometry will be applied to the rendering of the p5 elements.

This is definitely not my domain but definitely will experiment with it as I work on this library this summer.

JuanIrache commented 3 years ago

Yes. That's it.

I have thought about rendering each element to a hidden graphics, applying any geometric transformations there (I don't know how to do this step, maybe with a separate library?) and then drawing the result to the main canvas.

I don't understand how you intend to apply the geometric perspective to the rendering of the elements, but if you think there's a way, great!

Thanks