log in

Other programming


Normal-Mapped, Reflectivity-Mapped Material Shader (HLSL)

I created this shader to allow the rendering engine to simulate a surface that has variable reflectivity, e.g. a dirt road with puddles of reflective water. The effect also incorporates a bump map to simulate surface roughness and texture. Mathe-matically, the shader first achieves diffuse lighting through taking the dot product of the surface normal with the vector of the incoming light (Lambert's cosine law). It then samples the environment light using the calculated reflection vector. The diffuse lighting and environment sample are then interpolated together based on the reflectivity map.

Final result
Closer view
The diffuse (color) map
The 'bump' map. Adds 3D depth illusion.
The reflectivity map

Download example program with shaders included.
(Extract before running)


Prefiltered Material Shader (HLSL)

I created this shader to allow a rendering engine to simulate a surface that is diffuse-lighted by an infinite number of light sources in an environment (by default no more than 8 light sources may act upon a given material's diffuse reflection). The technique uses an effect derived from precomputed radiance transfer (PRT), a technique in which a global illumination environment is filtered before rendering time, allowing for fast realtime performance. The technique uses Monte Carlo integration to obtain the integral of the incoming light environment function for each point. The result is extremely accurate diffuse lighting, based on infinitely many points. The method is relatively fast, although in the example the precomputing takes place each frame, leading to slower performance.

Real-time prefiltering on sphere.
Prefiltering on a bird model, showing effect from the ground.
Technique for Monte Carlo integration ? multiplicative, rotated spheres are layered.
Effect with bump mapping.



Download example program with shaders included.
(Extract before running)


High-Dynamic-Range (HDR) View Shader (HLSL)

I created this shader to allow the rendering engine to simulate high-dynamic-range (HDR) photography. The aim of HDR is to mimic the effect of our eyes adjusting to different ranges of light, so that there is always contrast in the image we see. This shader maximizes the input range of color. First it blends the grayscale version of the scene using a guassian blur to obtain the maximum and minimum, then it color-maps the input scene to fit between the maximum and minimum. As a result, at least one black pixel and one white pixel is always visible.

Download example program with shaders included.
(Extract before running)