Jump to content

Improving Bent Normal shader


kensonuken

Recommended Posts

I found a Bent normal shader but when I render using this I get an output as if that its reflecting the object near to it? Can anybdody tell me what might have went wrong with this.. or is this the right approach to render World Space Bent Normals ?

//////////////////////////////////////////////////////////////////////////////////////////////

color vector2color(vector v) {

return ((color v) + 1) / 2;

}

surface occlusion_dmap (float doBendNormal = 1; output varying color outOcc = 0;)

{

normal Nn = faceforward( normalize(N), I );

float occlSum = 0;

vector dirSum = 0;

float dotSum = 0;

illuminance( P, Nn, PI/2 )

{

vector Ln = normalize( L );

float NdotL = Nn . Ln;

float shad = 0;

lightsource( "__inShadow", shad );

float occl = NdotL * (1 - shad);

occlSum += occl;

dirSum += Ln * occl;

dotSum += NdotL;

}

if ( dotSum > 0 )

{

occlSum /= dotSum;

dirSum /= dotSum;

}

if (doBendNormal != 0) {

vector bend = dirSum - Nn;

Ci = vector2color(bend);

} else {

Ci = occlSum;

}

Oi = 1;

outOcc = occlSum;

}

////////////////////////////////////////////////////////////////////////////////////

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...