• 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
0
Question by superpig · Oct 12, 2011 at 02:58 PM · shadow

Cast shadows but not render?

I'm trying to combine static light maps (my own system, not Beast + dual light maps) with dynamic lighting and shadows.

One thing I'm trying to figure out is how the shadows cast by my light mapped (static) geometry will fall on the characters. I want my static geometry to act as a shadow caster, but I don't want it to receive shadows from itself, because they're in the light map already. However, when I'm rendering the characters, I do want them to cast shadows on the environment.

What's the best way to get it so that my environment (casts shadows && !receives shadows) when I'm rendering characters, and (receives shadows && !casts shadows) when I'm rendering the environment? Can/does the shadow mapping even work in this way?

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
0

Answer by Santokes · Nov 02, 2011 at 11:02 PM

Hi Superpig,

First, to be clear, even if you get this working it won't ever be physically accurate since the light maps are static and shadow maps are dynamic. So let's say you get shadows working; the bounce lighting that is baked into the light maps won't look right when characters cast shadows on objects that have reflected light into the light maps. One would need a realtime global illumination system in place for that degree of realism.

Back to your scene. I don't know your visual target or what your camera perspective is, if it's zoomed out (like Diablo) then you might be able to just draw characters into the shadow maps, so that they cast shadows on objects. Objects wouldn't cast shadows on characters, but if the light maps are quality and the camera stays far away this might work.

Another option is to somehow get the shadow maps and light maps to play together. This is tricky since the light maps already have shadows baked into them by virtue of their nature. You could remove some key objects from the scene before baking the light maps, then tag them as dynamic shadow casters. Experiment with this.

Last suggestion: make two shadow maps, one for characters and one for the scene. The scene then gets dynamic shadows from characters, and characters from the scene (or scene + characters). This satisfies your conditions, and it only costs extra memory for the second RT and a second shadow pass. You could even optimize this by making a static shadow map for the scene and then combining that into the character shadow map (provided that the scene isn't destructable / no lights move)

Good luck, -Peter

p.s. Saw your altdevblogaday post on music. Awesome :)

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 superpig ♦♦ · Nov 03, 2011 at 12:34 AM 0
Share

The last suggestion is pretty much what I'm trying to do - two separate passes of the shadow pipeline, one for dynamic objects (receiving shadows from the scene) and one for the scene (receiving shadows from dynamic objects).

The problem is figuring out how to rig this in Unity - the only solution I can think of is something that involves turning on/off the shadow flags for hundreds of objects every frame, but I'm suspicious that there might be a better approach involving light culling flags or something.

avatar image Santokes · Nov 04, 2011 at 07:16 PM 0
Share

I'm new to Unity, and I don't know how you set up shadows (not manually, I assume?) but I just figured out how to render to an offscreen RT. Thus, I can gen my own shadow maps. A script attached to the camera can trigger the drawing- this script could easily do two renders, setting up different shadow maps for each.

So how to discri$$anonymous$$ate what objects draw into each RT? Unity has a layer system, which seem to be useful for this kind of thing. Or you could use flags.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Sprite is covered in shadow. 0 Answers

Realtime shadow + baked lightmap on iOS is big different from PC 0 Answers

[Beginner] Shadow not working in Roll-a-ball project 0 Answers

Unity5 Enlighten Shadows 1 Answer

Increasing point light resolution/alternatives 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