Nebula has been missing something for a very long time. When I started working with Nebula something like 3 years ago, we had simple UV-animated alpha planes which were supposed to look like water. And for the time being, they looked really good.

However, today a simple uv-animated alpha plane won’t quite cut it. Instead, we need something fancier, incorporating refraction, reflection and specular highlighting. I have been doing exactly this for the past day. The result is beautiful and realistic-ish water (let’s face it, water in real life is rather boring). Picture time!



Reflection and specularity

Reflection and specularity


However, I’ve been a bit lazy with the reflections in our implementation. The GPU Gems article from Nvidia shows that we should render the scene from below the water plane in order to get correct reflections. Instead, I simply just cheat and use the already lit and rendered image as a reflection. This makes the reflections completely wrong, but it still looks good…

Sometime in the future, I might write a new frame shader which cheaply renders the objects being reflected without all the fancy stuff like SSS, HBAO and multiple light shading, so as to give decent-looking geometry for reflections. Although, for the time being, this serves nicely. I also have an alternative shader which uses an environment map to render the reflections using a pre-rendered environment map, which may look good when using water in small local areas where real-time reflections are easily overlooked.

The water is fully customizable, with reflection intensity, water color, deep water color and of course reflection map. The reflection map is supposed  to be a pre-rendered cube map of the scene, so that reflections can be done without rendering everything twice. One can select whether to cheat, or to use an environment map.

I’ve also written a billboard rendering system, which basically just lets us render textures to billboards which is very useful for the level editor and other such tools. This is a crude representation of how it can look:

Lights represented as billboards

Lights represented as billboards

With actual icons, we can neatly show billboards instead of geometry to represent such things as spotlights, pointlights, the global light, and any other such entities which can’t, or shouldn’t, be represented with geometry.

Next thing on the list is terrain rendering, so keep tuned!


// Gustav


Apart from fixing a couple of small problems, I’ve also implemented a fancy shader which lets us perform vertex displacement. This means we can get fancy-looking things as trees and grass. It also works with shadows, picking and of course the god ray thing. It’s really that big of a deal, every engine has it, but the point is that now we do too! Pretty picture incoming:




What you can also do of course, is to apply this shader on basically anything static! As such, we can get funny looking effects like this:




Which is of course terrifying.

We’ve found a funny bug which seems to relate to Windows/Qt/DirectX11. If we run the render device without any vertical synchronization applied, we get weird internal locks in Qt when we do anything. This seems to be because we run Qt on the main thread while the rendering, which in turn updates the window, runs in it’s own thread. The application doesn’t crash or anything, it’s just QRasterWindowSurface::flush() that freezes when trying to perform BitBlt. If we however enable vertical synchronization, Qt doesn’t lock and everything works nicely.

Crepuscular rays

New week, new assignments. This time, I’ve implemented crepuscular rays, or as the hipsters would say, ‘godrays’. As a side effect, I’ve also taken to implement a sun mechanism, which let’s us render a big color-radiating sphere. This allows us to create pretty outdoor environmental effects. We also lacked a proper sun, so the sun had to be a part of the skydome. This of course meant we couldn’t re-position the sun, or have fancy day-night cycles. Here’s a picture of the result:


The sun uses the color of the global light, and it’s position is also quite simply just the position where the global light should be. The only problem is that the global lights in Nebula has no position, but only a direction, so I had to device a method which always kept the sun away from the camera, but still far enough so that it would be visible. The way I solved this was by just taking the camera position, and then quite simply moved the light in the opposite of the global light direction times a scale factor which would denote how far away the sun would be. I also had to make it so that the sun was oriented towards the camera as well, but that’s trivial.

That’s it for me!


// Gustav