2
\$\begingroup\$

I have a top down view of the interior of a house. I want to put a cover on the top so light from outside can't come in and I get more realistic lighting inside but transparent so I can still see inside. No clue how to achieve this in Unity. Any help would be appreciated. Ideally I'd just be able to use Unity's built in cube to make this.

\$\endgroup\$
3
\$\begingroup\$

Two methods exist for this. The easier one is to just set the object's shadow casting mode to Shadows Only. I didn't know there was a Shadows Only mode and only learned of this today too, thanks to DMGregory.

enter image description here

The other method is more convoluted, but it can be used for other things as well. Here's the rest of my answer:

Create a custom render layer. Quote from the Layers Manual page of Unity.

The first step is to create a new layer, which we can then assign to a GameObject. To create a new layer, open the Edit menu and select Project Settings->Tags and Layers.

enter image description here

Put the object on top of the house, then change its render layer to the custom one.

enter image description here

Now, select your camera and change its rendered layers so that it doesn't render that object.

enter image description here

Images taken from the Layers manual page of Unity.

\$\endgroup\$
  • \$\begingroup\$ Interesting. So this will treat lighting like it's there but the camera just won't visually show it? \$\endgroup\$ – user441521 Nov 14 '17 at 13:31
  • \$\begingroup\$ @user441521 It should, in theory, do that too. I haven't tested it because I don't have access to Unity. Please, do test it and come back with results. If this doesn't fix the problem, I'll take a look at it when I get home, since it has taken my interest. \$\endgroup\$ – John Hamilton Nov 14 '17 at 13:32
  • 1
    \$\begingroup\$ Note that you can also just take your roof object and set its ShadowCastingMode to "Shadows only" so it blocks light coming into the house but does not render in the colour pass. \$\endgroup\$ – DMGregory Nov 14 '17 at 13:32
  • \$\begingroup\$ @DMGregory make that an answer man, that seems much shorter (and easier) and more suited to the question at hand. \$\endgroup\$ – John Hamilton Nov 14 '17 at 13:33
  • \$\begingroup\$ @DMGregory That would treat light internally to the house correctly too? Meaning it wouldn't leak out and it would bounce off the ceiling? \$\endgroup\$ – user441521 Nov 14 '17 at 13:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.