Shard Posted December 7, 2009 Share Posted December 7, 2009 Hey everyone. I'm moving on to the next part of my World class which is the Day-Night Cycle. Now I've seen quite a few videos and have a small idea, I haven't seen a tutorial for it or sample code. What I'm guessing I will have to do is create a directional light and rotate it as the day passes, but I'm not sure what to do at night. I'm also unsure about how to create the sun and the moon in the sky to make it look realistic. Also I've tried to make my directional light rotate in code but none of the shadows moved at all so I'm not sure whats up with that. //Creation code PositionEntity(this->sunLight, Vec3(0,1,0)); RotateEntity(this->sunLight,Vec3(10)); //Update code RotateEntity(this->sunLight,Vec3(60),1); Any tips or words of advice before I begin? How do you all implement the day-night cycles? Quote Programmer/Engineer/Student www.reikumar.com 2.6 GHz Intel Core Duo - nVidia GeForce 8600 GT - Windows 7 64-bit - 4 Gigs RAM C++ - Visual Studio Express - Dark GDK - Leadwerks SDK Link to comment Share on other sites More sharing options...
Canardia Posted December 7, 2009 Share Posted December 7, 2009 Use TurnEntity to turn an entity. RotateEntity is only used to set a static angle to entities. Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Rick Posted December 7, 2009 Share Posted December 7, 2009 I wonder how a somewhat realistic approach would look. Make a sun & moon model and place it in the sky. Then rotate them around the "world". Quote Link to comment Share on other sites More sharing options...
NoOdle Posted December 7, 2009 Share Posted December 7, 2009 I wonder how a somewhat realistic approach would look. Make a sun & moon model and place it in the sky. Then rotate them around the "world". This is how myself and Eternal Crisis did it. Each planet would have its own directional light which you point at the camera or player. You would parent the planets and their lights to the camera or player and then rotate them. Based on either their height distance from sea level (which is what I did) or their angle, you can then fade one light out, and the other one in. Timing is crucial because at the moment 2 directional lights doesnt work, so you have to make the transition one after another. The light colour can also change depending on height or angle, along with fog color. I also changed the skybox colour as well with different values to that of the fog to simulate the difference you get with horizons during sunset and sunrise. I had great amounts of fun writing my day/night, look forward to seeing yours! Quote Link to comment Share on other sites More sharing options...
Flexman Posted December 7, 2009 Share Posted December 7, 2009 To be realistic you need to move the world around the sun ( little joke - of course it looks the same, people see what their knowledge tells them they are seeing ) I'm impressed by earlier efforts to make day-night cycles. I think they used a colour table for the time of day and set the sun entity (directional light) and ambient colour to some factor. Other points I noted: The directional light should fade to nothing before reaching the horizon as shadows are not that strong in low light conditions. Ambient light takes over from directional light at sunset (and vice versa at sunrise). Some used a fading skybox to show stars. Pre-computed light scattering colours would be faster. I did some work on planet atmospheric shells and calculating the light scattered through them many years ago, think it was called Rayleigh scattering. (edit) I just found a useful link GameDev - Atmospheric Scattering 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...
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.