I have been terrible at updating this blog, but with the holiday season over I hope to spend more time keeping it current. I have several things to cover in this post, let me start off with:
Asteroid Belts
What good is a solar system without an asteroid belt or planetary rings? It's not. So therefore I've decided I need them. At the moment I'm just using randomly scaled spheres for asteroids, but soon I will be procedurally generating something a little more realistic. The rings themselves use the same underlying code as the planet. A ring model is created and the patches are subdivided based on a metric. (In this case, distance to the camera). At each subdivision, asteroids are created that are proportional to the size and density of the patch. The asteroids are then distributed within the patch based on density, and Normally distributed 'vertically' from the patch. The density is determined by a randomly generated 1D texture that is smeared across the ring model. This is the same texture that is used at long-distance to give the appearance of rings.
Craters
After I made asteroid belts and asteroids, I thought about impact craters. Planets without atmospheres don't get a lot of protection from stray rocks whizzing around space, and tend to get bruised up. I modified Voronoi noise to only return values for cells that had a 'color' greater than a given threshold. Then, using the distance of a point to the cell center, we can build a reasonable approximation of a crater. It's not perfect, but its good enough for the time being.
Ships/Models
I finally got around to 'implementing' a model loader so that I can load in some human generated content if I need to. I chose the OBJ format because, well, I found an open-source loader for it online. It integrated into my code very easily and I was up and running with some free models I got off TurboSquid.
That's all for now. I have some more things to write about Atmospheric Scattering but that will have to wait for another time.
The Tempest
My attempt at a simple game using all procedurally generated content.
Saturday 7 January 2012
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.
If any mathematicians out there want to verify or refute this, I would love to have a more concrete opinion of it.
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
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!
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!
Subscribe to:
Posts (Atom)