2

I am trying to build a VR applications with portals into other worlds. These portals do however not have to be flat, they can be bent. Here https://www.youtube.com/watch?v=EpoKwEMtEWc is video from an early version.

Right now, the portals are 2D planes with camera textures which stretch and move according to the users position. For VR use, and to ease performance issues, I would like to define which area of the screen gets rendered by which camera. Sort of like a viewport in regular Unity, but not rectangular, and for VR with Windows Mixed Reality.

Is this somehow possible? Possibly even without Unity Pro?

berndibus
  • 95
  • 10
  • 2
    If you have a material on your main camera with each camera's rendertexture in it, you could [get the vertex's screen position in the vertex shader, pass it to the frag shader,](https://forum.unity.com/threads/how-to-get-position-of-current-pixel-in-screen-space-in-framgment-shader-function.219843/) and there, determine which texture to sample based on the current pixel's screen location. – Ruzihm Jun 04 '19 at 16:47
  • @Ruzihm This sound good, I am however not so experienced with shaders. If you could elaborate more on this in an answer, that would be great. – berndibus Jun 19 '19 at 04:53
  • Actually, doing it that way is probably not the best way. Encoding a way for the shader to know which parts of the screen correspond to which texture is not an easy task. A better way might be to procedurally generate meshes, instead of quads, and then you can do the same thing you're already doing. You could stick some empty gameobjects inside the knot and then use their position (projected to the same distance from the camera so it's flat) to place the vertices of the mesh. You'd need to somehow render the knot after the portals, so your portals don't appear *on top of* the knot.... – Ruzihm Jun 19 '19 at 16:24
  • The render textures are meshes, so that is the way I am doing it right now. The way with shaders sounds better I think – berndibus Jun 20 '19 at 17:22
  • I suppose I don't understand exactly what the problem is with what you're already doing. – Ruzihm Jun 20 '19 at 17:56

0 Answers0