{"id":3806,"date":"2015-04-25T00:20:27","date_gmt":"2015-04-24T21:20:27","guid":{"rendered":"http:\/\/unitycoder.com\/blog\/?p=3806"},"modified":"2015-04-25T00:20:27","modified_gmt":"2015-04-24T21:20:27","slug":"creating-car-mirror-with-rendertexture","status":"publish","type":"post","link":"https:\/\/unitycoder.com\/blog\/2015\/04\/25\/creating-car-mirror-with-rendertexture\/","title":{"rendered":"Creating car mirror with rendertexture"},"content":{"rendered":"<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"3813\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2015\/04\/25\/creating-car-mirror-with-rendertexture\/rendertexture_mirror-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2015\/04\/rendertexture_mirror1.jpg?fit=681%2C446&amp;ssl=1\" data-orig-size=\"681,446\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"rendertexture_mirror\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2015\/04\/rendertexture_mirror1.jpg?fit=681%2C446&amp;ssl=1\" class=\"alignnone wp-image-3813 size-full\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2015\/04\/rendertexture_mirror1.jpg?resize=681%2C446\" alt=\"\" width=\"681\" height=\"446\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2015\/04\/rendertexture_mirror1.jpg?w=681&amp;ssl=1 681w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2015\/04\/rendertexture_mirror1.jpg?resize=300%2C196&amp;ssl=1 300w\" sizes=\"auto, (max-width: 681px) 100vw, 681px\" \/><\/p>\n<p>Creating simple car mirror using rendertextures.<\/p>\n<p><strong>HOW TO<\/strong><br \/>\n&#8211; Right click at Project window, Create \/ RenderTexture<br \/>\n&#8211; Rename &#8220;New Render Texture&#8221; into something else, like &#8220;MirrorRT&#8221;<br \/>\n&#8211; Drag &amp; Drop &#8220;MirrorRT&#8221; into 3D object (preferably some flat object) at scene view (it automatically creates Materials\/folder and &#8220;MirrorRT&#8221; material there and assigns to the object)<br \/>\n&#8211; Right click at Hierarchy window, Create \/ Camera<br \/>\n&#8211; Rename &#8220;Camera&#8221; into something else, like &#8220;CameraMirror&#8221;<br \/>\n&#8211; Position &#8220;CameraMirror&#8221; into that 3D mirror object and rotate it so it looks toward the mirrored view direction<br \/>\n&#8211; Make &#8220;CameraMirror&#8221; the child of 3D mirror object, so that it follows it<br \/>\n&#8211; Disable [ ] GUILayer and [ ] AudioListener components from &#8220;CameraMirror&#8221;<br \/>\n&#8211; Optional: Adjust Clipping Plane Near values for both cameras to 0.01 or so (if your model gets gets clipped near camera)<br \/>\n&#8211; Select rendertexture file from Project window and Drag &amp; Drop it into &#8220;CameraMirror&#8221; TargetTexture field<br \/>\n&#8211; Hit play!<\/p>\n<p><strong>EXTRAS<\/strong><br \/>\n&#8211; Select &#8220;MirrorRT&#8221; from Project window to adjust render texture resolution &amp; settings<br \/>\n<img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"3812\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2015\/04\/25\/creating-car-mirror-with-rendertexture\/rendertexture_settings\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2015\/04\/rendertexture_settings.jpg?fit=359%2C212&amp;ssl=1\" data-orig-size=\"359,212\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"rendertexture_settings\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2015\/04\/rendertexture_settings.jpg?fit=359%2C212&amp;ssl=1\" class=\"alignnone size-full wp-image-3812\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2015\/04\/rendertexture_settings.jpg?resize=359%2C212\" alt=\"rendertexture_settings\" width=\"359\" height=\"212\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2015\/04\/rendertexture_settings.jpg?w=359&amp;ssl=1 359w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2015\/04\/rendertexture_settings.jpg?resize=300%2C177&amp;ssl=1 300w\" sizes=\"auto, (max-width: 359px) 100vw, 359px\" \/><\/p>\n<p>&#8212;<\/p>\n<p><strong>Resources:<\/strong><br \/>\n&#8211; I used this free car model : <a href=\"http:\/\/www.turbosquid.com\/FullPreview\/Index.cfm\/ID\/717576\" target=\"_blank\">http:\/\/www.turbosquid.com\/FullPreview\/Index.cfm\/ID\/717576<\/a><br \/>\n(had problem with the mirror mesh UV mapping, so made small script to temporarily fix it : <a href=\"https:\/\/gist.github.com\/unitycoder\/993f7b3d46469a792715\" target=\"_blank\">PlanarUVMap.cs<\/a>, attach it to the mesh that needs fixing)<br \/>\n&#8211; RenderTexture manual : <a href=\"http:\/\/docs.unity3d.com\/Manual\/class-RenderTexture.html\" target=\"_blank\">http:\/\/docs.unity3d.com\/Manual\/class-RenderTexture.html<\/a><\/p>\n<p>&#8212;<\/p>\n<p><strong>Image#1:<\/strong> Broken &amp; fixed UV map (later also mirrored UV map horizontally)<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"3808\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2015\/04\/25\/creating-car-mirror-with-rendertexture\/fix_uvmap_1\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2015\/04\/fix_uvmap_1.jpg?fit=680%2C340&amp;ssl=1\" data-orig-size=\"680,340\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"fix_uvmap_1\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2015\/04\/fix_uvmap_1.jpg?fit=680%2C340&amp;ssl=1\" class=\"alignnone size-full wp-image-3808\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2015\/04\/fix_uvmap_1.jpg?resize=680%2C340\" alt=\"fix_uvmap_1\" width=\"680\" height=\"340\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2015\/04\/fix_uvmap_1.jpg?w=680&amp;ssl=1 680w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2015\/04\/fix_uvmap_1.jpg?resize=300%2C150&amp;ssl=1 300w\" sizes=\"auto, (max-width: 680px) 100vw, 680px\" \/><\/p>\n<p>&#8212;<\/p>\n<p><strong>Image#2:<\/strong> Posioning &#8220;CameraMirror&#8221; into mirror (on this 3D model &#8220;Chrome_20&#8221; is the mirror mesh and camera is set as child of it)<br \/>\n<img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"3811\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2015\/04\/25\/creating-car-mirror-with-rendertexture\/mirror_camera_position\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2015\/04\/mirror_camera_position.jpg?fit=679%2C554&amp;ssl=1\" data-orig-size=\"679,554\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"mirror_camera_position\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2015\/04\/mirror_camera_position.jpg?fit=679%2C554&amp;ssl=1\" class=\"alignnone size-full wp-image-3811\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2015\/04\/mirror_camera_position.jpg?resize=679%2C554\" alt=\"mirror_camera_position\" width=\"679\" height=\"554\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2015\/04\/mirror_camera_position.jpg?w=679&amp;ssl=1 679w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2015\/04\/mirror_camera_position.jpg?resize=300%2C245&amp;ssl=1 300w\" sizes=\"auto, (max-width: 679px) 100vw, 679px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Creating simple car mirror using rendertextures. HOW TO &#8211; Right click at Project window, Create \/ RenderTexture &#8211; Rename &#8220;New Render Texture&#8221; into something else, like &#8220;MirrorRT&#8221; &#8211; Drag &amp; Drop &#8220;MirrorRT&#8221; into 3D object (preferably some flat object) at scene view (it automatically creates [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3810,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[420,1,3],"tags":[735,734,383,145],"class_list":["post-3806","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","category-uncategorized","category-unity3d","tag-mirror","tag-rendertexture","tag-tutorial","tag-uv"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2015\/04\/rendertexture_mirror.jpg?fit=680%2C503&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/p1KTaT-Zo","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/3806","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/comments?post=3806"}],"version-history":[{"count":2,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/3806\/revisions"}],"predecessor-version":[{"id":3814,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/3806\/revisions\/3814"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media\/3810"}],"wp:attachment":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media?parent=3806"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/categories?post=3806"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/tags?post=3806"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}