Pixel Perfect Posted September 9, 2012 Share Posted September 9, 2012 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? Quote 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 More sharing options...
Flexman Posted September 9, 2012 Share Posted September 9, 2012 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? Quote 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 More sharing options...
Pixel Perfect Posted September 9, 2012 Author Share Posted September 9, 2012 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! Quote 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 More sharing options...
Recommended Posts
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.