Recent developments have focused mostly on improving the architecture of the system and utilities for playing around with a scene, without much focus on improving how things look. Specifically, the way a star looks has been bothering me for some time. It simply didn’t look like a star at all.
With some relatively small changes, it’s possible to make it look a lot nicer, which you can see in
the image below.
Compare that to how it originally looked.
The most important changes for this result have been:
Removing the height map from the sphere
Creating a separate shader for stars
Increasing the glow effect
Adding texture to the star’s surface
I’m still no Procedural Content Generation expert, but I’m starting to get the feeling that I understand OpenGL shaders well enough to work toward specific ideas in my mind. Before I always had to look up how to solve very specific problems instead of playing around with shader concepts myself. It’s nice to see that playing around is improving my skills.
Now, let’s discuss in a bit more detail how this result was achieved.
Extract height map from sphere generation
This is a super obvious one. There is a single implementation to generate a sphere, which was used to generate spheres. Those spheres were used as a basis for the planets and the stars. Unfortunately, when playing around with heightmaps on planets, I did that straight in the sphere-generation code. As a result, the stars also had a height map applied, which had a bit of an odd look to it.
In the new version, the height function is extracted and can be provided as input to the Sphere class. I’m not 100% happy with this implementation, because to me it feels like spheres shouldn’t even really have the concept of a height map, but at least for now, this is sufficient.
Separate shader for sun
This is again a super obvious one. There was a single low-poly shader that was used for planets and stars. The shader included code for lighting, which doesn’t make any sense for a star (where would the light even come from?). With this change, stars look much brighter and look like a source of light.
The code for the shader will be shown in the next section because the noise function is defined in the shader as well.
Adding texture to the star
The original star was completely texture-less, which looks boring. Adding some texture, suddenly makes it look a lot more realistic. One downside though, is the fact that this texture doesn’t match well with the low-poly style. I’ll have to look into this a bit more to get the styles matching.
The texture isn’t implemented as an actual OpenGL texture, but rather as a noise-function inside the shader.
You can see that the Vertex Shader passes the original position of the vertex to the fragment shader. The noise must be based on the original position because otherwise, the texture will not seem to stay in place when rotating the star for example.
Realistic star colour
The colour of a star is a function of its temperature, which can be seen in the image below.
The actual change to the glow effect itself was to increase the offset, basically increasing the radius. More importantly, effects have now been moved to the component-based system, finalising the transition. Effects were the last type of components that had to be refactored.
Next steps
Although this already looks a lot better, there is one big improvement that I want to look into,
which is the bloom effect.