Mark Sachs (ksleet) wrote,
Mark Sachs
ksleet

  • Mood:
  • Music:

"Victor Hugo once got so mad he threw a baseball through a dog"

OK, that went pretty good. I prized all the hardcoded stuff out of the shader and made the system more flexible, so I can now just pass ranges of altitudes and colors for different climate zones in and quickly create different types of planets, as well as defining different "channels" of colors that can be passed down in the first place (currently, I have one channel for the altitude, and one channel for a simple climate zone that changes between the pole and the equator.) So here's the standard terrestrial:



Here's a Moon:



Here's a kind of half-hearted Mars sort of thing:



So that's fine. There are some other little tweaks I want to add; for example, I could have the pixel shader check the drawn point's distance from certain locations, and change the color if it's within the distance. That would let me draw (a limited number of) circular surface features, such as craters. I also want to re-implement the rather nifty scheme I had for drawing clouds on Jovian planets using the old raytracer, where the 2D fractal was used to distort the 1D fractal and create nifty roiling cloud bands.

The primary annoyance of all this, if you're curious, is the fact that loops in a pixel shader appear to be stupidly slow. So for example:

for (int i = 0; i < numThings; ++i)
  if (someCondition(i))
    doSomething(i);

is orders of magnitude slower than:

if (someCondition(0))
  doSomething(0);
if (someCondition(1))
  doSomething(1); (etc.)

Which was surprising, as I thought it was the conditionals themselves that were supposed to be slow. Annoyingly, this means that instead of calling in and saying "there are 3 climate zones with 5 altitudes each" I have to hard-code the maximum numbers of zones and altitudes I'll ever use. (Or else create multiple shaders for different numbers, which is the usual technique used in commercial games.)

Ah well. That's all a sideshow, anyway. What I really need to do to move forward is think of how I want to actually generate these planets -- not so much "how do I decide what kinds of planets to make," though that is a fascinating question, but more just the tedious bureaucracy of making it happen and dividing up the code that generates different worlds. There isn't a code path for constructing different planets in each solar system right now, although the program does at least generate a star of the appropriate color and size so that's the logical place to start.
Tags: programming
Subscribe
  • Post a new comment

    Error

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 4 comments