Ray Tracing – Materials

This iteration of the C#/XNA ray tracing project includes more realistic modeling of materials. Specifically, I’ve implemented Fresnel Reflections, and diffuse and specular lighting with microfacet models Oren-Nayar and Cook-Torrance respectively.

These settings are included in the Xml scene definition as in the following example:

 

<sphere name=”Sun”
center=”0, 0, 0″
radius=”40″
color=”Gold”
diffuse=”1.0″
reflectance=”1.0″
refractiveIndex=”0.617″
absorptionCoefficient=”2.63″
isConductor=”true”
cookTorranceSteepness=”0.1″
orenNayarRoughness=”0.3″
microfacetDistribution=”Beckman”/>

The cookTorranceSteepness and orenNayarRoughness values describe the same concept — the degree to which the microfacet normals differ from the surface normal. I’ve separated them so that these values can be modified independently. The microfacetDistribution value indicates the model used for distributing the microfacets around the half-angle (the angle between the incident light and the viewer — this applies to the Cook-Torrance model — and the value returned, from the specified distribution, is the fraction of microfacets with normal pointing along the direction of the half-angle). I’ve implemented Beckmann’s and Blinn’s distribution models.

The diffuse value is still valid (and the specular is derived from this value 1-diffuse) and acts as a coefficient to the corresponding reflectance model.

Here are a few screenshots:

 

 

The first image is of a purely diffuse surface without fresnel reflection or microfacets. The second is the same object with fresnel reflection and using Oren-Nayar’s diffuse reflection model with a microfacet roughness of 1.0. Note, that it’s this roughness that causes the flat shape (a commonly used example is the full moon). The third image is a semi-diffuse surface with a specular component, and the last are comparisons of a scene with and without microfacet modeling.

Here’s the updated source code . I believe the implementation is accurate, but if anyone spots a problem please let me know.

Paul

5 Comments so far

  1. ziggy on May 30th, 2007

    Wow! Very nice. This is coming along quite nicely.

  2. mysdn on February 1st, 2008

    nice example, how can we get models to ray trace
    rather than simple shapes would be my question?

  3. Paul on February 1st, 2008

    To render models, modify the actors element in the scene configuration file. For example:


    actor name="Loopy"
    model="Content\\Models\\Loopy"
    position="0, -50, 0"
    orientation="90, 0, 0"
    scale="1.0"
    movementVelocity="0.0"
    color="Red"
    diffuse="1.0"
    reflectance="0.0"
    refractiveIndex="0.0"
    tag=""
    />

    Have a look at the source code for more details on the config file and actor rendering.

    Paul

  4. cutez on February 2nd, 2009

    is it possible to compile the source code if i’m not install bespoke software? i’ve got the problem to debug this application..

  5. Paul on February 2nd, 2009

    You don’t need any other Bespoke Software components to compile the ray tracing package (e.g. the 3DUI XNA Framework). However, you do require XNA Game Studio 1.0. Do you have this installed? If you only have XNA Game Studio 2.0, or 3.0, you should be able to easily convert the RayTracing package to use these updated XNA releases.

    Paul

Leave a reply