// Software pixel shader generated by Wild Magic.
//
// var float3 kWorldNormal  $vin.TEXCOORD0
// var float3 kEyeDirection $vin.TEXCOORD1
// var float4 kPixelColor   $vout.COLOR

#include "Wm4SoftRenderer.h"
#include "Wm4ColorRGBA.h"
#include "Wm4Vector3.h"

namespace Wm4
{

ColorRGBA p_Fresnel (const float*, SoftSampler**, const float* afInPixel)
{
    // Get the input items.
    const Vector3f& rkWorldNormal = *(const Vector3f*)&afInPixel[0];
    const Vector3f& rkEyeDirection = *(const Vector3f*)&afInPixel[3];

    // *** program ***

    // Calculate the Fresnel factor.
    float fFresnel = 1.0f + rkWorldNormal.Dot(rkEyeDirection);
    fFresnel = fFresnel*fFresnel;

    return ColorRGBA(fFresnel,fFresnel,fFresnel,1.0f);
}

WM4_IMPLEMENT_PPROGRAM(Fresnel);
WM4_REGISTER_PPROGRAM(Fresnel);

}
