Jump to content

Flip a viewport to create a rear-view mirror


Joakim
 Share

Recommended Posts

Hi

I am making a small car game in which I have different camera views. When viewing from within the vehicle I display two viewports showing the view of two rearward-facing cameras.

Does anyone know if it is possible to flip the view of from these cameras (or flipping the viewports) to mimic the behavior of a mirror?

Thank you!

Link to comment
Share on other sites

  • 5 months later...

Hi again! I would like to give this subject some closure.

I tried this approach again, and this time I got it to work! I was able to extend your example by adding a "screen" which renders a mirrored camera view.
See the text marked with "ADDED". The result is shown when the camera is rotated.
http://www.babylonjs-playground.com/#145AGC#8

The solution was simply to set the "uScale" to -1, and not to forget to call the "render" function in the "registerBeforeRender" event.

When implementing this in my game I ran in to a problem. The "activeCamera" on the texture was always the scene's active camera. It turned out I had to upgrade from 2.2 to 2.3 to fix this issue.

After that, I ran in to some new, unrelated problems; my way of moving the "driver's" camera does no longer work in 2.3 - I will have to work on that =)

Link to comment
Share on other sites

Coooooool!  Hi J, welcome to the forum!   Hey, do you "need" to use mirrors?  RenderTargetTexture might be more powerful than you think.

http://www.babylonjs-playground.com/#1WROZH#6

Is there anything in that goofy playground... that could help your cause?  Why use mirrors when we can duct-tape a camera to the back of our helmet?  :D Talk again soon.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...