Dynamic Function Linking Graph for Shaders
December 16, 2015

For many modern engines, the shear quantity of different configuration options for shaders can start to be a major burden. Many compile-time options can end up increasing the number of compiled shaders exponentially. It can get to the point where the shaders data image can make up a large segment of download time, and compile time can be a major hassle during development.

For example, a pixel shader for forward lit scene elements will often need to be specialized to suit the number and types of lights nearby. If we have a few different types of lights, the number of combinations can become very quickly unmanageable.

But we really need a lot of compile time options! They are very useful.

Dynamic linking methods in D3D

What we really need is a way to do dynamic linking of shaders -- so that we can construct the particular shader we need at runtime.

D3D provides a few different methods for dynamic shader linking. The one simple method involves "classes" and "interfaces."

Classes and interfaces

In the shader code, we can define an interface like this:

interface ILightResolver
    float3 Resolve(
        GBufferValues sample,
        LightSampleExtra sampleExtra,
        LightDesc light,
        float3 worldPosition,
        float3 directionToEye,
        LightScreenDest screenDest);

Rectangle Light diffuse vs 3DS Max
December 11, 2015

Just a quick note on rectangle light diffuse. In XLE, rectangle lights are slightly different from the default rectangle lights in 3DS Max.

XLE lights 3DS Max lights (Quicksilver renderer)

Working some improvements to rectangle lights
December 09, 2015

Post updated on 2015-12-10

This is just some notes about some ideas I've been playing with lately. I've been thinking about some improvements to the specular highlights for rectangle lights!

The current implementation is based on the method by Michal Drobot in GPU Pro 5. I'm not going to repeat the description here (I'll only give a few details) -- but I recommend buying the book and having a look! It's quite a good method, and interesting read. Drobot describes a very practical method for diffuse and specular for rectangle and disc lights.

However, at extreme angles, the specular reflection of rectangle lights can sometimes show some distortion.

Here is a comparison:

Original Method New Method

What to do first
December 04, 2015

So, you've just downloaded XLE, and you're wondering what to do first? Here's a suggestion for the first 10 minutes:

Startup the level editor

Select the Level Editor as the startup project:

You should use the Debug/x64 or Release/x64 configuration. Though XLE works in both 32 bit and 64 bits modes, normal usage for the level editor should be in 64 bits mode.

If you have trouble compiling, see the Getting Started Compiling page.

Start up this application, and you should see a large 3D window and various other windows about.

The level editor is based on a great project from Sony WWS SonyWWSLevelEditor. It has been modified to work with XLE, and some XLE specific behaviour has been added. I think this is a great example of the Open Source concept working for games developers.

Creating an object

Area Lights with Physically Based Rendering
December 02, 2015

XLE now support a few area light types: sphere, tube & rectangle (with disc and maybe some other shapes coming soon). Maybe in a future post I'll go into some details about the implementation (actually, it's quite interesting!). But this post is about something different: this post is about why they are important.

I'm finding that it makes a huge difference. So much so that not only do we want to support area lights -- we also want to outlaw non-area lights. Point light sources are now the enemy!

PBR Concept

The biggest buzzword at the moment is Physically Based Renderering (or PBR, or sometimes Physically Based Shading). But what does that mean, really? Partially it means sampling values from the real world. But really it's just a container under which we're placing many related concepts.

One of these "sub-concepts" of PBR is the idea that a single material should work in many different lighting environments.

In the past, artists often tweaked the material settings for objects to suit the lighting environment they are in. This is a problem because it means that if the object moves into another lighting environment, the material settings must be tweaked to match.

This happen in both movies and games. In games, it's particularly a problem for games with a day/night cycle. In games where time is changing, the lighting environment is also always changing. Previously this means that extreme lighting settings (sunsets, etc) had to be more subtle than real-life. What we want is materials that look correct in all possible lighting environments.

Specular highlight size

There's a simple way to think about this. Let's consider the size of a specular highlight.

Here are 5 spheres rendered in Blender with Cook Torrence lighting.