Saturday 3 April 2010

Mapping sun and star effects

Saman has just done a nice 'noise' rendering system so we can do effects for the surface of the sun and stars. Using our noise system we can also do solar coronas (the atmosphear of the sun) this will let us do eclipses, which will be nice. We are using 4D noise, 3 dimensions are mapped onto the sphere of the star and the 4th is used to animate the noise over time. If you use the right color table to map the noise into you get a lava effect, but many other textures can be generated using noise like marble etc.

Here is a video of the surface effect without the corona



So this is the effects system for sunV1 in Earthsim2. We have no sunspots and no solar prominences, those are going to have to wait untill we return to the sun for sunV2, the next time we visit sun code. At that point we will be ready to make a bunch of star and sun docs. But for now we are aiming for simply looking at pretty stars that map to the real data we get from astronomers.

Mapping to the real world
OK so we have a cool effect, it looks pretty but we want to map it to something a bit more real. The effects system has lots of paramaters we can now set. These are just numbers that for example set the scale of the noise as well as how fast it animates etc. The next step is to decide how those numbers are decided from real astronmical data.

The simplest way to go is to base the mapping off the Hertzsprung Russell diagram (HR). This is a graph of star luminosity against color. Knowing the brightness of a star as well as its color will tell you alot of the things you care about for any star, using an HR diagram can really help you undestand stars. And luckily for earthsim all the astronomers spend all their time observing and documenting the bigghtness and colors of as many stars as they can.





In Earthsim all we need is the 3D position of the star, its luminosity and its color and the rest just falls out as below.

1. So the 3D position is just where we put the star in Earthsim.
2. We will use the spectral type to modify the color table for the lava effect so this makes the surface look the right sort of color
3. We will use the luminosty to set the brightness of the star from a distance.


Now how to get closeup. First we need to know how big the ball is for the star

Some maths comes in here so you can skip it

Maths start --------------------------------

I found a good summary article here:

http://cas.sdss.org/dr6/en/proj/advanced/hr/radius1.asp

But a quick summary is that from the Luminosty of a star you can use Boltzmann's law to work out the size of the star.

The Luminosity L = 4πR2σT4

This equation can be expressing in terms of solar units such that:


L/Lo = (R/Ro)2(T/To)4
where Lo, Ro and To are the luminosity, radius and surface temperature of the Sun.

Knowing that Stefan-Boltzmann's constant is 5.67x10-8 lets you calculate the luminosity of a star in units of watts (like a light bulb) if we know the radius of the star in meters and the temperature in kelvins. For example, the Sun is 6.96x108 meters in radius and has a surface temperature of 5780K. Therefore, its luminosity is 3.84x1026 watts.

On a log-log plot, the R squared term in the above equations is a straight line on an HR diagram. This means that on a HR diagram, a star's size is easy to read off once its luminosity and color are known.

Maths end -------------------------------

Great, so we have the color, and the size of the ball as well as its brightness/luminosity. We can draw the right sized ball at the right color and brightness now.

The FX
Now for some effects. We need setup a mapping of the parameters of the noise function we have to different types of stars. For simplicity we are going to setup effects parameters for the four corners of the HR diagram and linearly interpolate them for all stars across the diagram. For now we will manually setup parameters for each of the four corners of the HR digram as yet I have not manage to find any research on what other stars may actually look like, so its all hypothetical for now.. Feedback is welcome.

And that should do it.

For later we will design a dialog box that lets you drag a point across and image of the HR diagram and see the star change dynamically

No comments:

Post a Comment