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
2
Question by moonhalo · Nov 11, 2014 at 05:37 AM · camerashadow

How to share shadow between two cameras

Hi~

There are two cameras in the scene, one is named "Terrain camera" and the another is named "Character camera".

Terrain camera renders terrains and Character camera renders unit models.

After I generate a scene, I can see the terrain and character models, but the character's shadow does not cast in terrain.

To reproduce:

  1. Make a fresh project.

  2. Add a directional light, set to hard shadows(soft shadow also possible).

  3. Add Plan and set layer as "Terrain"

  4. Add Cube and set layer as "Terrain"

  5. Add Sphere and set layer as "Unit"

  6. Set properties of "Main Camera"
    • Culling Mask : "Terrain" ( render plane ans cube )

    • Depth : -1 ( render before character camera )

    • Rendering Path : Forward

  7. Add camera and set properties :
    • Culling Mask : "Unit" ( render sphere )

    • Depth : 1 ( render after main camera )

    • Rendering Path : Forward

  8. Finally make the two camera have same position.

If you run the game, the cube cast shadow to the plane, because they have same layer id. But, sphere does not cast shadow to the plane and cube.

I don't know why... but because the camera has its own shadow data? If so, can I make the two camera share same shadow data (= maybe shadow map texture?).

Also, I have to make the shadow data with objects that does not have same layer id. Does Unity have some functions for this?

or any other alternative?

alt text

alt text

Thank you.

unity_shadow_01.png (14.7 kB)
unity_shadow_02.png (27.5 kB)
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

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by NateJC · Jul 29, 2016 at 04:44 PM

I figured out a workable solution for my case:

1) Make a parent game object that has the collider & rigid body

2) Now add two nested children to it, each with the same Mesh + Mesh Renderer components

3) Name one of them "View" and the other "Shadow Only"

4) For the View object, use these settings:

View Settings

5) For the Shadow Only object, use these settings:

Shadow Only Settings

6) Now apply all physics & animations to the parent object, and everything else should work naturally!


view-settings.png (42.6 kB)
shadow-only-settings.png (43.6 kB)
Comment
Add comment · 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

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

What can cause shadow slicing while moving camera? 1 Answer

How to set SceneView culling mask programmatically? 1 Answer

How to get Directional Light Shadows to render through an Orthographic Camera? 1 Answer

Shadows from culled objects 0 Answers

What is causing the Abs(dist - shadowRadius ) error? 1 Answer


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