• Create Account

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

107
Like
1Likes
Like

Posted 29 January 2014 - 04:46 AM

Hi all,

My name is Vladeta Stojanovic and I'm currently working as a research assistant in visualisation and modelling at Abertay University (where I studied the undergrad Computer Games Technology). When not working on work related projects, I work on my own game prototypes and like to experiment with different rendering methods. In terms of shader programming, I'm very much influenced by the "cheap and easy" demo scene way of writting shader effects

While messing around yesterday I came up with this shader (I decided to call it the "Spectral Accumulation Shader"). I discovered this somewhat by accident, as I originally wanted to write a simple Lambert diffuse shader and mess around with it (using some Blinn shading variations).

Below is a screenshot of the shader used on standard testing models (Utah teapot, skull and the Stanford dragon):

And here is the HLSL code (compiled using shader model 3.0 and tested in XNA 4.0):

float4 _SpectralAccumShader(float3 _normal, float3 _eyeVector, float3 _vertexPosition, int occSteps, int spectralBands, float highlight_value)
{
float4 outColor = float4(0, 0, 0, 0);

float3 lambert = saturate(dot(_normal, _eyeVector)); //switch eyeVector to lightPosition if using static light

float3 halfway = normalize(lambert + eyeVector);

float3 spectralMap = halfway - _normal;

float3 depthMap = _vertexPosition / 100.0f;

float occDistance = length(normalize(depthMap));
float specDistance = length(normalize(spectralMap));

for (int i = 0; i < occSteps; i++)
{
occDistance += dot(_normal, depthMap);
specDistance += dot(_normal, spectralMap);
}

occDistance /= occSteps;
specDistance /= occSteps;

float3 diffuseResult = float3(occDistance + specDistance, occDistance + specDistance, occDistance + specDistance);

float3 spectralResult = diffuseResult;

//Accumulate the colour spectrum
for (int j = 0; j < spectralBands; j++)
{
//spectralResult *= cross(diffuseResult, spectralMap); //object space
spectralResult *= cross(spectralMap, diffuseResult); //world space
}

outColor = saturate(float4((diffuseResult * highlight_value) * spectralResult, 1.0f));

return outColor;
}


I would like to get some feedback from the graphics experts on here if possible. You can feel free to use this shader in your own applications, as I would really like to see if other people can find good use for this technique.

On a side note, I guess you can say that this is a cheap approximation of the Thin Film Interference shader presented in this article. I was recently also working on a ambient occlusion shader using the Optix API, thus this influenced me the idea of "banding" or accumulating different surface colour values.

You can also check out more of my work on my website/portfolio

Edited by vlad_s, 29 January 2014 - 04:53 AM.

290
Like
0Likes
Like

Posted 30 January 2014 - 12:07 PM

pretty cool, seems perfect for shading metalsurfaces in dark zones with lights.

Peace and love, now I understand really what it means! Guardian Angels exist! Thanks!

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.