William Schilthuis Special Reflective Material  

Visual.Effects.Artist

 

Download files here:

RenderMonkey Source File:

- wgsRflx.rfx

HLSL Source:

- wgsReflx_vs11.hlsl

- wgsReflx_ps20.hlsl


Reel / Blog / About

Reflective Safety Material. I set out two goals for this project:
-development of a real-time shader using HLSL, High Level Shading Language
-development of a pipeline to integrate a custom shader into a game engine.

Developing the pipe line was a secondary goal I set out for because I was so excited about making a realtime shader. I Decided to create separate webapage because of the length of this topic.

Major challenges included learning an entire new language and toolset for shader development, and learning the game engine workflow and software. I've documented the entire process. Athough I could not refine evry part of the pipeline, I accomplished my goals in a very limited time frame.

Update: I discovered in Real-time Rendering, that this property is called "Retro-Reflectivity" and was able to find much moreinformation from there. (diagram). In this website I have simply called the property "special reflectivity"

Shader Development:

   ATI RenderMonkey

   Cutter + Pixar Renderman

Game Development:

   Valve Source SDK

   Microsoft Visual Studio

   Microsoft DirectX SDK

 

If you're going to make a shader, first of all: understand what's happening

I want to create the type of special reflectivity seen in street signs, road paint, safety clothing, etc... I'll describe the specific characteristics below.

 

First, I looked into several US Patents for "reflective" stuff:

  - Faceted Metal Reflector

  - Faceted 3D surface

  - Metal Reflector

  - Bike Reflector

Unfortunatley, most of these are "macro" faceted and based on specific angles of internal geometry. Facets generally give the same appearance from a distance, but what I'm looking for is the microscopic reflectivity. The above listed "Metal Reflector" works this way, but doesn't describe the specifc nature of the relfection, just how its made.

 

Next I went out to get my own photo reference:

I used an off camera flash and documented falloff of reflectance over different angles. The reflector below has facets, but exhibits the same reflectivity attributes I'm looking for. If this shader was to be observed very close-up, a Normal map could be used for the reflectivity to add internal facets.

 

Here are my observations about the surface:

The observable feature is similar to specular, but reflects back towards the light because of uniform microscopic particles or facets (if only I had a microscope)!

Safety First!

 

 

Early in development, I used Cutter and Renderman to develop a prelimnary RSL shader, because of my familiarity with RSL.

 

I spent time learning HLSL development with RenderMonkey. A great place to start is with this book. Rather than document setting up an environment for HLSL dev, I've included the RenderMonkey file which includes all the source code and controls.

 

NVIDIA's FX Composer is a great alternative tool, and I would reccomend it equally.

 

To cut things short, here's the main function of the shader:

// Special Reflectivity
float4 rflxBRDF = pow(max(0, dot(LightV,HalfVect+0.03)), dot(32,LightV) );
// here we can clamp the effect, so we see color
rflxBRDF = clamp(rflxBRDF,0,5.5);
// filter the inner material color
rflxBRDF *= rflxColor;

So the core of regular Specularity is this:

pow( clamp(0,1, dot(VertNorm, HalfVect)),128);

And the core of my custom reflectivity is this:

pow( max(0, dot(LightV,HalfVect+0.03)), dot(32,LightV) );

 

In development I worked by adding an Ambient, Diffuse, and Specular component first. Then, I duplicated the Specular and modified it to my needs.

You can download a commented RenderMonkey (rfx) file HERE as reference. As an excercise I have separate passes for Ambient, Diffuse, Specular, Amb+Diff+Spec, Rflx, Amb+Diff+Spec+Rflx.

This shader could easily be integrated with existing shaders or driven by textures. Below is a video of only a few adjustments:

Note: In the time I had, I definitley accomplished what I set out to do. However, this shader is in a draft stage of development, and I would still like to make the following improvements:

---Calculate lighting per-pixel rather than per-vertex.

---Add better artist control, there are a few hard-coded values that should be artist controlable.

---Include ability to map refelctive properties with textures

Source Engine Workflow- Detailed HERE

In the future, I'd like to document how to use ATI RenderMonkey or NVIDIA FX Composer to develop shaders for the source engine directly. This involves setting up an environment and makign use of include/header files. I've made some progress here, but not enough to publish.

 

Developing shaders for real time is an amazing difference, it's a lot easier for me as an artist to see when and where my math is wrong and it's really exciting to have somethign interactive. Utilizing the Source Engine was tough from the ground up, but I chose to work with it because its implementation of custom shaders is very powerfull. I have experience with Epic's Unreal Engine and it's very artist friendly, but not very clean for implementing custom HLSL. That said, I'm an artist who loves physics, so I pretty much enjoy all of this!

Updated: June 16, 2011