- Home /
Question regarding the blob shadow projector shader
Hey guys,
So i'm playing around with a space scene in Unity, and there is a planet in the distance from the player. For scaled realism, the planet is massive and is 11000 Unity units away from the player.
The problem is the shadowing. I have made a GameObject which contains a custom skybox (so that I can manipulate its rotation i'm not using Unity's skybox solution) and a point-light acting as the sun. The player and the planet in the distance stay at the same rotation while the GameObject containing the skybox and sun rotate around the player to make it appear like the player is orbiting with the planet.
So, the problem is when the light rotates around to the far-side of the planet (the opposite side that the player is on). Without shadows, the light from the sun shines through the planet and still hits the player's ship. Ideally, because the planet is blocking the light from the sun at this point, the player should be in complete darkness + natural light.
Initially I tried casting a shadow from the planet, but because of distances this is too costly, so I've been setting up a system using a projector. The projector rotates inside the origin of the planet in directly the opposite relative forward direction from the sun. I've set it up to ignore the planet's layer and the custom skybox layer. On the face of it, this works brilliantly, however there is a slight problem.
When the projector projects onto the player's ship when the sun is on the other side of the planet, the player ship turns completely black and I can no longer visually effect the ship. For example, if I place a light down next to the ship, the light has no effect on the ship when the projector is projecting onto it.
I am a complete noob when it comes to shaders, would anyone be able to tell me what changes I need to make to the Projector/Multiply shader so that it doesn't completely override the ship visually and things like lights can still effect the ship?
Many thanks in advance.