Apr
25
2015

Creating car mirror with rendertexture

Creating simple car mirror using rendertextures.

HOW TO
– Right click at Project window, Create / RenderTexture
– Rename “New Render Texture” into something else, like “MirrorRT”
– Drag & Drop “MirrorRT” into 3D object (preferably some flat object) at scene view (it automatically creates Materials/folder and “MirrorRT” material there and assigns to the object)
– Right click at Hierarchy window, Create / Camera
– Rename “Camera” into something else, like “CameraMirror”
– Position “CameraMirror” into that 3D mirror object and rotate it so it looks toward the mirrored view direction
– Make “CameraMirror” the child of 3D mirror object, so that it follows it
– Disable [ ] GUILayer and [ ] AudioListener components from “CameraMirror”
– Optional: Adjust Clipping Plane Near values for both cameras to 0.01 or so (if your model gets gets clipped near camera)
– Select rendertexture file from Project window and Drag & Drop it into “CameraMirror” TargetTexture field
– Hit play!

EXTRAS
– Select “MirrorRT” from Project window to adjust render texture resolution & settings
rendertexture_settings

Resources:
– I used this free car model : http://www.turbosquid.com/FullPreview/Index.cfm/ID/717576
(had problem with the mirror mesh UV mapping, so made small script to temporarily fix it : PlanarUVMap.cs, attach it to the mesh that needs fixing)
– RenderTexture manual : http://docs.unity3d.com/Manual/class-RenderTexture.html

Image#1: Broken & fixed UV map (later also mirrored UV map horizontally)

fix_uvmap_1

Image#2: Posioning “CameraMirror” into mirror (on this 3D model “Chrome_20” is the mirror mesh and camera is set as child of it)
mirror_camera_position


8 Comments + Add Comment

  • Hey Bro Can I ask you a question?

  • http://hizliresim.com/ZD8nOV

    I’m trying to do here, but I failed as a mirror.

  • thats not how a mirror works. this is how a notebook webcam works.

    to simulate a mirror you need to adjust your camera based on the position of the main camera

    • yeah good catch! have to update this scene later.

Leave a comment to Soraphis

Connect

Twitter View LinkedIn profile Youtube Youtube Join Discord Twitch

UnityLauncherPro

Get UnityLauncherPRO and work faster with Unity Projects!
*free unity hub alternative

@unitycoder_com

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.