Jump to content

Rougue shadow issues with the Day Night system


Pixel Perfect
 Share

Recommended Posts

I've been playing with klepto2's day night system (very nice it is too) but spent some time last night modifying the code to try and get round this issue I'm having with the sun still casting shadows when the directional light is below the terrain which just looks weird.

 

I noticed this years ago when playing with a simple day night system myself. The terrain does not appear to cast shadows if the light is shone from beneath it meaning that any shadow casting objects on the terrain still do!

 

I've had some good success by introducing a dual intensity system, one for the sky (left as it was) and a new one that kills the directional light intesity when below the horizon. Just wondered if I'm missing a setting somewhere that would prevent this in the first place?

Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++

Link to comment
Share on other sites

What I do is calculate ambient and sun light values every lighting update (which is configurable to every frame or every 5 seconds). This happens regardless of the visibility of the sun or moon.

 

The directional light representing the sun is turned it off when the sun is masked by the terrain. To prevent shadows from suddenly vanishing what I do is attenuate the sun entity (a d-light) intensity *before* it dips below the horizon, and in the morning it's attenuated until it's a few degrees above the horizon.

 

When the sun d-light is hidden the sun colour is still blended with the calculated ambient light colour to achieve a smooth lighting transition. It works even if the colours are not natural.

 

 

As a quick thought (I've never tried this) put a flipped plane under the terrain to cast a shadow?

6600 2.4G / GTX 460 280.26 / 4GB Windows 7

Author: GROME Terrain Modeling for Unity, UDK, Ogre3D from PackT

Tricubic Studios Ltd. ~ Combat Helo

Link to comment
Share on other sites

To prevent shadows from suddenly vanishing what I do is attenuate the sun entity (a d-light) intensity *before* it dips below the horizon, and in the morning it's attenuated until it's a few degrees above the horizon.

Thanks Flex, thats pretty much what I did in klepto2's code and it seems to work well enough, although the simple flipped plane is a quick solution too!

Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...