Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by DanJC · Mar 21, 2013 at 03:56 AM · camerascenerendersurface

How can I render a scene to a surface

Two cameras in different levels. Within camera B's view you can see a plane. On that plane I want to render what camera A can see.

I'm not asking for code specifics, but really just pointers in the right direction/what to look for. If there are particular functions that help with specifically this, mentioning those would be appreciated. Cheers.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by DanJC · Apr 25, 2013 at 07:49 AM

Just going to provide a working non-Unity-Pro solution for anyone else that comes across this.

It's true that you can't use RenderTexture() without Pro, but you don't need it. What you can do instead is use a shader with a ColorMask of 0.

Create 2 cameras, and chuck an object in the view of Camera 2 and another object in the view of Camera 1. On Camera 2's object place a material that has the following shader, and then render first Camera 1, then Camera 2. To do this, simply go to the Inspector and set Camera 1´s Depth to 1, and Camera 2´s Depth to 2.

Camera 2's render will completely cover that of the Camera 1, except for where the object is, creating a functioning hole in the air that you can look through to see what's in the view of Camera 1.

alt text

Shader "DepthMask" { SubShader { ColorMask 0 // Masks the object with no rendering to all colour channels Pass {} // Render the object, which in this case means disabling } }

Thanks to Tenebraus for pointing this out.


2013-04-25 image 005.png (275.7 kB)
Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image jjxtra · Apr 15, 2015 at 01:34 AM 0
Share

Is there a download link for this project?

avatar image Zarenityx · Apr 15, 2015 at 09:53 AM 0
Share

@jjxtra I recommend switching to unity 5. The free version has rendertextures. If you want to finish your project in 4, then see the posts below for step-by-step instructions (I dont have an example project). Unity 5 is amazing though and if you want real rendertextures without the side-effects of this workaround, upgrade.

avatar image
-2

Answer by Staakman · Aug 04, 2013 at 09:04 PM

I'm very sorry, but I can't get this to work in Unity 4.0

Can someone please elaborate on this?

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image DanJC · Aug 05, 2013 at 01:26 PM 0
Share

I have been having some issues with this too since I created this post. I did neglect to say that I have Camera 1 set to Skybox, and Camera 2 set to Don't Clear. (Depth Only also works on Camera 2.) However, I have definitely used this technique with a skybox on both cameras. It was running perfectly, portals were behaving exactly as expected both ways. Since upgrading to Unity 4.2, something has gone wrong. I don't think it's Unity as the scene I posted above is still working, but rather, that it's just a large coincidence that not one of my backups using 2 skyboxes has this effect working now. I think I've messed up, but haven't worked out what yet. I'm still a beginner with this too.

These are the instructions I think SHOULD work. But right now, for me they don't. I still have a scene with the effect working, but I can't seem to be able to replicate it. $$anonymous$$aybe someone can say what's wrong in these instructions:

  1. Create a scene with 2 cameras.

  2. Call one of them CA$$anonymous$$ERA 1 and set its depth to 1.

  3. Call the other CA$$anonymous$$ERA 2 and set its depth to 2.

  4. Put a cube in a place where CA$$anonymous$$ERA 1 can see it.

  5. Put a sphere in a place where CA$$anonymous$$ERA 2 can see it.

  6. In the project panel, make a new shader. Leave its name as the default "NewShader".

  7. Double-click that shader and once your code editor has opened, replace its contents with this line: Shader "NewShader" { SubShader { Color$$anonymous$$ask 0 Pass {} }}.

  8. Save it.

  9. Back in Unity, in the project panel, make a new material.

  10. Drag the shader onto that material.

  11. Drag that material onto the sphere.

  12. Press Play.

One final note, I did find that when shaders aren't functioning as you expect, sometimes it fixes the problem if you select the "Reimport" option on the material that a shader is applied to. I had to do this just now in fact, for that scene shown above in that older post.

avatar image Staakman · Aug 06, 2013 at 09:57 AM 0
Share

Can you email the scene to staakman@gmail.com ( maybe if it's big through http://www.wetransfer.com )? Would love to check what's going wrong. Thanks in advance.

avatar image DanJC · Aug 07, 2013 at 03:40 PM 0
Share

Checking the scene about to send it to you, I noticed strange behaviour. Simply scaling an object was making the effect switch between functional and non-functional.

So perhaps this is a Unity bug after all, and it might have something to do with this thread:

http://forum.unity3d.com/threads/192467-Unity-4-2-submesh-draw-order

avatar image gardnedn · Jun 06, 2014 at 05:26 PM 0
Share

I would also appreciate if you could email me the scene as well. If either you or staakman could send it to gardnedn@miamioh.edu that would be very helpful. Thanks again!

avatar image
0

Answer by liszto · Mar 21, 2013 at 12:22 PM

I think this can help you to do what you want :

http://blog.almostlogical.com/2009/12/11/render-to-texture-unity3d/

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image DanJC · Mar 21, 2013 at 08:29 PM 0
Share

Thanks. Totally bummed that you have to have Pro to use it. :(

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

14 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

(CLOSED) Plane Failing to Render When Camera is Switched Until Scene is Reloaded?! 0 Answers

Camera not showing in scene view 0 Answers

default setting scene area 1 Answer

Detailed render for far away objects? 1 Answer

Capture a (screen shot) scene shot with alpha 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges