• Register
Post news RSS Homebrew Vehicle Sandbox: Let's Talk Physics #1

Physics plays a critical part in not only Homebrew but game design as well. Here in Copybugpaste HQ we love physics so we are starting a new series of posts called "Let's Talk Physics." In Let's Talk Physics #1 we will be talking about our reworked/dynamic skybox as it relates to scattering and fog.

Posted by on

Let's Talk Physics #1- Scattering & Fog

Homebrew will have a reworked/dynamic skybox and therefore we'd like to talk about scattering and fog. A ''precise" mathematical description of this was published by Sir Rayleigh who was probably inspired by Maxwell's discoveries and from what's known as the “aerial (atmospheric) perspective effect”. From this last effect it is known that scattering influences the appearance of objects, think landscapes; the objects that are the farthest will appear more blueish because their colors are replaced by the colors of the atmosphere as distance increases. This knowledge is helpful to create a greater sense of scale in games as humans rely on it to evaluate the distance between objects.

Many types of scattering exist, but the two main ones are:

  • Rayleigh: responsible for blue/red sky (small molecules, scatters most at shorter wavelengths)
  • Mie: adds a grey tint to the sky and is responsible for a white halo around the sun, grey-white looking clouds, pollution haze (bigger molecules like dust/pollutants, strongly forward directional, less wavelength dependent)

The following image shows that Rayleigh is dominant at the top and because it prefers shorter wavelengths the sky will be bluest when the sun is at its highest (noon); more blue light passes through the atmosphere.

When the sun is at its lowest, Mie scattering is dominant and we get a white glare around the sun; the incoming light has to travel a longer distance and more light is scattered away from you and this results in a more orange/red looking sky.


(image: R. Nave - HyperPhysics)

This realism however comes at a high computational cost, but thankfully people like Tomoyuka Nishita developed algorithms for precise rendering methods that run entirely on the GPU making things like accurate atmospheric scattering possible. For a more technical/mathematical understanding on how these methods are implemented in a GPU shader Nvidia’s GPU GEMS 2 – CHAPTER 16 which we found really helpful in our research Http.developer.nvidia.com is certainly worth reading.

For our sky we use Time of Day which allows us to have per-pixel quality which means that the sky dome calculates parts of the atmosphere for every pixel instead of every vertex. This is great because it leads to higher quality and allows us to have much higher contrasts.

In our quest to find a balance between aesthetics and physical based accuracy we developed a custom fog solution so that we have more volume and a greater sense of scale (think "aerial perspective”). It'll also allow us to have a smooth transition (fading) between above and below water level whereas in the old Homebrew this isn’t the case and the intensities are fixed.

There’s still work to be done, but eventually we also want to have clean transition (fading) between the sky and fog. This is crucial for Homebrew because if we were to look at an earth-like planet from nearby it appears blue and the boundary near the shadow is more reddish (“sunset”). As the color varies in function of the view direction and the position of the light source we have to ensure a smooth transition between different colors to ensure that we don’t lose the aspect of realism when entering an atmosphere.

(Without Fog)


(With Fog)


We hope you enjoyed our first "Let's Talk Physics" post and look forward to your comments and feedback.


Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.