5
\$\begingroup\$

I want to create a space simulation, but I'm facing some difficulties when I try to create a realistic sun.

Currently, I've a simple Point Light inside a sphere. But for some reasons, no matter the intensity and the attenuation radius of this light, the other objects in the scene (the planets, for instance) aren't lit any more if their centre are separated by more than 1.5 kilometres approximatively.

Lit planet Unlit planet (Top) Lit planet, 1.4 km away from the sun.
(Bottom) Unlit planet, 1.5 km away from the sun.

Do you know what can cause this phenomenon? Is there a way to bypass it? If not, how can I create a realistic sun light in a large space simulation?

\$\endgroup\$
  • \$\begingroup\$ The 1.5km mark probably comes from your fallof function (something like 1 / r² where r is the distance between light and geometry). That function will hit pretty much 0 at some point and no matter how high the intesity it`ll be dark. Try to modify your falloff to something that doesn´t go down as quickly. maybe (1 / 0.001*r ) or whatever. you gotta experiment a bit. \$\endgroup\$ – Luis W Jul 13 '15 at 15:56
  • \$\begingroup\$ @LuisW Sadly, I've already try that. The limit between the two zones is hard: at some point, the planet is lit up ; one centimetre farther, it's unlit. \$\endgroup\$ – Blackhole Jul 13 '15 at 15:58
  • 1
    \$\begingroup\$ Apparently your simulation is too large. You need to think about ways to create the simulation on a smaller scale. Something similar to the way Kerbal Space Program does it. (They broke it up into a 1/6000 scale scene and a 1/1 scale scene mixed together). \$\endgroup\$ – MichaelHouse Jul 13 '15 at 16:16
  • \$\begingroup\$ @Byte56 Okay, it's look like that's the problem, indeed. Scaling down the sun, the planet and the distance between them by a constant factor has solved it. Now, I have to find the perfect factor, but that's another story. Anyway, if you want to make an answer from your comment, I'll be happy to give you some rep! \$\endgroup\$ – Blackhole Jul 13 '15 at 17:00
  • \$\begingroup\$ Well, it doesn't actually answer the question you've asked. It's more a of an alternative solution. I'd suggest you create an answer talking about how you solved the problem. \$\endgroup\$ – MichaelHouse Jul 13 '15 at 17:03
2
\$\begingroup\$

It is definitely the size of your scene and the culling of light that is causing your light to 'disappear' from the planet at that distance. There were a lot of suggestions that are good and answer your question of bypassing it.

Another one would be to actually tweak the shaders in UE4 to accomodate lighting such a large simulation space as suggested by a UE4 staffer:

"If you actually need planets or objects to render with the correct light angle that are far enough away from you to get a different light direction, you'd have to do some shader tweaks. Thankfully, round objects like planets will usually look good without casting shadows just using an NdotL lighting term." - RaynB "Creating a massive point-light, has anyone tackled the issues with this?" (forums.unrealengine.com)

One that I have also heard of is the potential of using Light Propagation Volumes that are built into the UE4 engine... but it seemed like a concern that such a large space could still prove to be problematic.

Another suggestion would be to just turn off the Inverse Square Fall-off of your light to see if that works in your un-scaled simulation.

"...have you tried disabling exponential light falloff? You may have to expand the light properties a bit to see that option. Then the radius and exponent values should be literal and you can get as much light as you need. You might have quality issues with dynamic shadows in that situation however." - RyanB

If you are making a single player game with only one sun (they cannot travel between solar systems) the suggestion of rotating the angle of your Directional Light based on the player's position between the sun and view is another way to go about it.

"Pointlights are not really intended to work as a sunlight for a huge scene, >directional lights were created to solve many of the problems you will get by doing that. What I would probably do is use a directional light but use the level blueprint to rotate the directional light according to the player's orientation around the sun."-RyanB

Personally, If you want 1:1 scale simulations and need the lighting to work for that, I would suggest altering the culling of the UE4 shaders for this. Just remember that this may have a performance impact.

If you are intimidated by modifying your shaders or creating an new one for your specific needs, and have access to the forums, I suggest giving this a good read: https://forums.unrealengine.com/showthread.php?27766-Odessey-Creating-my-own-G-Buffer-in-UE4&highlight=custom+depth+buffer+shader even though it is just about a custom G-Buffer, it will help teach you about writing and binding your own shaders for pointlights.

Or you could find the code that clamps your culling distance and edit that.

If scaling your world, keep in mind that if you are using PhysX, the mass of the object is calculated from the size and you may run into issues if micro-scaling.

\$\endgroup\$
0
\$\begingroup\$

You should remove the fall off because the sun from a planets point of view is a directional light and does not have fall off.

If it was me I would just use a directional light instead of a point light, I guess if you want to fly around the sun then one could use 6 directional or a point light with no fall off.

Also I have a limit set for may lighting because I don't need it to go all the way to farclip so maybe you need to make the size of the light biger?

\$\endgroup\$

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.