The last progress I posted that included screenshots was when I added textures. That was a few months ago. While I have not had much to report since then, I have been no lazy bum. There were many advancements, but I wanted to wait until I had shadows before I posted anything major.
I am pleased to present you with some eye candy.
So what are you seeing here?
- My own variant of percentage-closer soft shadows.
- Anisotropic mipmap filtering.
- Kaiser mipmap filters.
- Linear-space color blending.
- Sorted render queues.
- Normal mapping.
- Hemisphere lighting.
- Automatic offline conversion from bump maps to normal maps (the Spitfire’s normal mapping was originally a bump map).
- Fresnel translucency. Notice how the glass becomes less see-through at steep angles away from the camera in the last image.
- Phong shading.
- Model instances.
- Concept of a game world and a scene manager.
- Input handlers (mouse and keyboard).
- A camera (was previously just some hard-coded matrices).
- Automatic resizing of textures that do not meet the requirements of the hardware (non-square, too big, etc.) using high-quality Kaiser filters. I imagine most of my time was spent on the image filterer, which also supports many other kinds of filters.
- Resource sharing. Duplicate textures not allowed!
- Frustum culling.
Although there was a lot of set-up, I only spent a day on the actual shadow-mapping algorithm, which is my own variant of PCSS. Hard to tell from the pictures but they do get harder nearer to the source. So there is still a lot of work to do to make them pretty, but I think they look good enough for an update post.
Once I get the default shadows looking nicer and faster, I will implement a new form of shadows that I have invented to handle multiple layers of colored shadows. When that is complete I will release a white paper explaining how it works. It isn’t much extra work on top of existing colored shadow-mapping algorithms, and it can be applied to all of them, so I am expecting to see it used widely in future game engines.
A word about my fresnel effect shown in all images, but most noticeable in the last image. A correct fresnel implementation can be found here: http://www.cse.ohio-state.edu/~kerwin/refraction.html
That is quite a long equation! I created a simpler approximation that yields decent results (see last image) that is much more efficient. My equation simply reduces to this:
_vOutColor.w *= (((1.0f / abs( dot( vViewPosToEye.xyz, vNormalizedNormal ) )) - 1.0f) * 0.25f) + 1.0f;
_vOutColor.w = min( _vOutColor.w, 1.0f );
0.25 is the fresnel term, which I temporarily hardcoded but will make it adjustable soon. You can use this to create more efficient approximations of fresnel terms in your own code.
L. Spiro