Home       About Me       Contact       Downloads       Part 9    Part 11   

Part 10: Attempts at Art

January 26, 2011

Despite my intention to implement a large world that would page in bits of scenery as you move, I got distracted by all the comments on the last part, both on this site and over at Shamus Young's Twenty Sided Blog. I spent most of the week trying to come up with a better vision of how I wanted my world to look.

As I've said before, I'm artistically impaired, so this is difficult for me. The only even mildly artistic thing I've done since I was a kid coloring with crayons is photography. And even there, I've never developed any technique. My rule is just "Go to scenic places. Take lots of pictures. Keep the good ones."

vacation photo vacation photo vacation photo
vacation photo vacation photo vacation photo

What I had last week was pretty blah, even by my standards. This week, I tried to improve it with various suggestions from the comments.

Fig 1: Room for improvement
lots of worlds


A couple of people suggested that the stars were too big and bright. I've had that same impression since the beginning. The problem is the way I render the stars. I'm just splattering a patch of stars at random angles and positions. If I cut down the size of the patch, or use fewer patches, I don't get enough coverage and it starts to look like lots of rectangles:

Fig 2: Patchy stars
star patches

I fixed this by positioning the patches at regular intervals around the sky, and then randomly perturbing those positions a bit, as well as rotating and reflecting them. I also shrank the stars within the patch, to make them less big and bright. That evens out the star field. There are still a lot of stars! If for some reason you hated stars, you could edit the patch and knock out some of them.

Fig 3: Smaller stars, more evenly distributed
smaller stars


Shamus suggested a nebula to add color and orientation to the sky, like Eve Online. It turns out he was thinking of something like this:

Fig 4: Eve Online, nebula and sun
eve online

Before he sent me this image, I Googled for Eve Online screenshots and didn't find anything I liked. Instead, I went to the Astronomy Picture of the Day site and looked for nebula. I liked Orion, which looks like this:

Fig 5: Orion Nebula
orion nebula

That's what I tried to implement. Of course I used Perlin noise again, which is what I use for anything "natural" looking. Florian Bösch sent me to this PDF, which describes both Perlin and Simplex noise and gives an implementation. I already had a Perlin noise implementation, but it was taken off another site that I won't link, since it's horribly slow. This version is much faster.

Fig 6: Casting rays through noise
building a nebula
In the end, I need a texture (I used 1024 by 512) which is mapped onto the inside of a sphere enclosing the scene. I'm generating the sphere the obvious way -- as a bunch of rectangles arranged on latitude and longitude lines. (Let me know if there's a better way to generate a textured sphere!)

This causes a lot of wasted space in the texture, since like a Mercator projection, everything near the poles is distorted. It also means that I need a distorted texture to map. I can't just wrap one of these astronomy pictures onto a sphere (it would also show a seam where the right edge wrapped around to the left.)

I solved this in the usual brute force fashion. I sampled the simplex noise in a spherical pattern and mapped that back to a texture. I might have gotten away with just taking a single noise value at the surface of the sphere. However, I was thinking that this might not look good (though I didn't try it). After all, a real nebula is a structure in space, not a sphere.

So I actually cast rays from the center of the sphere, and added up all the noise I encountered along the ray (see Figure 6). To match the color scheme of my sun, I colored the low values brown, the medium values red and the high values yellow. After a lot of tweaking (this is version #12), I got a texture I liked the looks of.

Fig 7: My simplex noise nebula, mapped to a spherical texture.
simplex noise nebula

Putting this texture into the demo, along with the stars and sun (and a bit of broken Minecraft landscape) gives Figure 8.

Fig 8: The demo with nebula, stars and sun.
nebula with sun

By the way, I notice some of the comments say things like "if that is a sun" or call it a planet. It's a view of our sun in extreme ultraviolet, which shows all the spots and flares clearly. I kind of like this view and hope to animate it, so that flares and spots crawl slowly over the surface. Someday...

A smaller, whiter, more normal looking sun would look like this:

Fig 9: A normal sun.
normal sun


Some comments also pointed out that the asteroids in last week's effort are featureless and the lighting is barely noticeable. So I worked on that a bit too. I am still puzzling over how I want to generate the more complex asteroids I featured in Part 8, so for this effort I just used the simple height-mapped shape. I did give it a more interesting texture though.

Fig 10: A grey asteroid
grey rock
Fig 11: With astro-turf?
green rock

My red-orange nebula sort of dominates the color scheme here, and I find the green rock a bit jarring. I also still don't like the shape or coloring. I'm not sure what I'm going for here. Put a bunch of them in the sky and it looks like this:

Fig 12: Space Marbles?
space marbles

The Ring

The Figure 1 image has a ring of asteroids in it, but it's very hard to see, because your vantage point is within the ring. I was tempted to just give up on the idea of a ring, but I thought it would add some perspective to the whole scene if I could get it right. The only way that a view of the ring makes sense is if you are just a bit above it (your rock could be one of the high ones.)

I didn't do anything clever to make the ring. It has some noise arranged in a ring shaped texture, and that is just rendered on a big flat rectangle a bit below the eye point. The sun is drawn in the center. Here's the final version:

Fig 13: The Solar System
solar system

And of course there has to be a video. This was recorded with Fraps, not the ray tracer. The code does this in real time (no surprise, given the low triangle count of the asteroids at this point.)

What Next?

Since I have no artistic taste, I'm not sure what to make of this. Is it too garish? Too visually noisy? Too much like every other space game? You'll have to tell me.

I'm also not sure I could make this significantly better if I spent another week or two on it. I have ideas for what I could do, and I have some completely different world models I want to explore eventually. However, I think this is enough for now. I'm getting tired of running texture and color combinations over and over until something looks nice! It's time to get back into the real code.

I'm still open to any suggestions. If you are inclined to build your own versions of these images, download artwork.zip which has some of the textures I've used here. With an image editor or 3d rendering program, you could reproduce what I've done and make changes. If you have an image you like, you can upload it to a photo site and paste the URL into your Disqus comment. After a few minutes, it will produce a preview people can click on.

If you don't want to post your images in public, email me at

Home       About Me       Contact       Downloads       Part 9    Part 11   

blog comments powered by Disqus