## Wednesday, 21 September 2011

### Out-Scattering integral solution.

Let me start off by saying I am a programmer, not a mathematician, so this is largely just me talking out of my ass but I did back it up with some screenshots. Onwards.

I've been going over the Atmospheric Scattering equations again, as written in GPU Gems 2.

If you look at the out-scattering equation, it is as follows:
Something about that integral just seemed like it should be solvable. So I've spent the past week thinking about it, and I finally figured it out. The -h/H0 term is the altitude of the point divided by the 'Scale Height' (the point in the atmosphere at which the density is considered 'constant' or 'average').

If we do our atmospheric scattering calculations assuming that the atmosphere is centered around the origin, then our value 'h' is just the magnitude of our sample point (S). So now we know how far the point is from the origin, and to turn that into an 'altitude' we just subtract the radius of the planet, (R). So now our expression is

exp(-(|S| - R)/H0)

We already know our points Pa and Pb, and thus we know their magnitudes and thus we can determine their altitudes, lets call them just A and B. We'll come back to this later.

So what that integral above is doing is accumulating the atmospheric density along the ray from Pa to Pb. Because this density function is only concerned with the altitude or magnitude of the points between, and the integral only really cares about the distance between Pa and Pb, which we will call N, we can mush this about to a nice 1 dimensional integral, where we just integrate along the distance of N, using it to parameterize our altitude.

let C = B - A , then our altitude at any point x between 0 and N is:

((A + (C*x/N)) - R)

drop that into our expression and we get:

exp(- ((A + (C*x/N)) - R) / H0)

then our integral becomes:

furthermore, we can scale the starting points Pa and Pb ahead of time, ie:

A = (A - R) / H0 and B = (B - R) / H0

so now we've simplified that integral to

Tada! Here's some screenshots of only out-scattering with this definite integral, and with the previous sampling method.

 This is the outscattering computed with the closed form solution.

 This is the same shot but using the previous sampling approximation method.

If any mathematicians out there want to verify or refute this, I would love to have a more concrete opinion of it.

## Monday, 25 July 2011

### Some more screens

Here's some shots in atmosphere:

Winding river
Some mountains:

The canyon at the bottom of the previous picture, looking towards the bottom right.
Some high-altitude terrace feature

## Sunday, 24 July 2011

### First!

Hello, and this is the first entry in what I hope to be many in my attempt to create some sort of something that will resemble a game or something at some point. To open, a screenshot!

This is a screen shot of a procedurally generated planet. Complete with Clouds and Atmospheric Scattering. You can see a bit of z-fighting with the clouds and the planet, but I hope to solve that problem in the near future.

Here's a wireframe view of the planet.
More to come!