Jump to content

Real Mirror

Recommended Posts

Hello guys,


I'm trying to do some mirrors, and in my first try I used a Camera render target.

Camera render target looks like a good solution for security cameras and such, but as a mirror not so much :/




Anyone know how I could do a mirror, like the one in the video? I mean reflect stuff based the angle that you look at it.



Share this post

Link to post

Why don't you just rotate the camera depending on player position?


Hello and thank you for your suggestion, I will do some tests.

Maybe we can use some shader or probes to do the same?

Share this post

Link to post

The probes aren't dynamic, so you won't be able to see the player. The SSLR shader won't work because the back of the player will be culled in a third person game and hidden in a first-person game. Basically, you can't use that shader for anything that's not currently displayed on camera.

Share this post

Link to post

Yep, you've basically got to position and rotate the camera opposite of the player eye, across the plane.




I haven't done this, but our water reflections work the same way. Now with water reflection on a vertical plane, I scale the camera by 1,-1,1 so the image is inverted. You might have to experiment with this, or maybe just drawing the image backwards on the mirror surface will work.


Finally, you will need a clipping plane across the mirror surface, so the reflection doesn't include objects behind the mirror. You can transform the plane of the mirror to camera space (Transform::Plane()) and send this to your mirror shader, then set the super-secret GraphicsDriver clipplane member to this:

graphicsdriver->clipplane[0] = plane;


This plane will then be uploaded to every shader.


This requires C++, so the pro edition is needed. It's not really supported right now, but it is possible to implement and if you get anywhere with it I'm happy to do what I can on my end to make it easier. A reusable mirror plane prefab would be a pretty cool addition to the Workshop.

Share this post

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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.

  • Create New...