// Geometric Tools, Inc.
// http://www.geometrictools.com
// Copyright (c) 1998-2005.  All Rights Reserved
//
// The Wild Magic Library (WM3) source code is supplied under the terms of
// the license agreement
//     http://www.geometrictools.com/License/WildMagic3License.pdf
// and may not be copied or disclosed except in accordance with the terms
// of that agreement.

#include "Wm3FresnelPShader.h"
using namespace Wm3;

WM3_IMPLEMENT_RTTI(Wm3,FresnelPShader,PixelShader);
WM3_IMPLEMENT_STREAM(FresnelPShader);
WM3_IMPLEMENT_DEFAULT_STREAM(FresnelPShader,PixelShader);
WM3_IMPLEMENT_DEFAULT_NAME_ID(FresnelPShader,PixelShader);

//----------------------------------------------------------------------------
FresnelPShader::FresnelPShader ()
{
    // shader program (load the type of the current renderer)
    m_acProgram = ms_aacProgram[Renderer::GetType()];
}
//----------------------------------------------------------------------------
FresnelPShader::~FresnelPShader ()
{
}
//----------------------------------------------------------------------------
const char* FresnelPShader::ms_aacProgram[Renderer::RT_QUANTITY] =
{
"!!ARBfp1.0\n"
"# ARB_fragment_program generated by NVIDIA Cg compiler\n"
"# cgc version 1.1.0003, build date Mar  4 2003  12:32:10\n"
"# command line args: -q -profile arbfp1 -entry pmain\n"
"#vendor NVIDIA Corporation\n"
"#version 1.0.02\n"
"#profile arbfp1\n"
"#program pmain\n"
"#var float3 iLighting : $vin.COLOR : COLOR : 0 : 1\n"
"#var float3 iNormal : $vin.TEXCOORD0 : TEXCOORD0 : 1 : 1\n"
"#var float3 iEyeDir : $vin.TEXCOORD1 : TEXCOORD1 : 2 : 1\n"
"#var float3 oColor : $vout.COLOR : COLOR : 3 : 1\n"
"PARAM c0 = {1, 2, 0, 0};\n"
"TEMP R0;\n"
"TEMP R1;\n"
"MAD R0.xyz, c0.y, fragment.texcoord[0], -c0.x;\n"
"MAD R1.xyz, c0.y, fragment.texcoord[1], -c0.x;\n"
"DP3 R0.x, R0, R1;\n"
"ADD R0.x, c0.x, R0.x;\n"
"MUL R0.x, R0.x, R0.x;\n"
"MOV result.color.xyz, R0.x;\n"
"END\n"
"# 6 instructions, 2 R-regs, 0 H-regs.\n"
"# End of program\n"
,
"// Pixel Shader 1.1 generated by NVIDIA Cg compiler\n"
"// cgc version 1.1.0003, build date Mar  4 2003  12:32:10\n"
"// command line args: -q -profile ps_1_1 -entry pmain -profileopts dcls -strict\n"
"//vendor NVIDIA Corporation\n"
"//version 1.0.02\n"
"//profile ps_1_1\n"
"//program pmain\n"
"//var float3 iLighting : $vin.COLOR : COLOR : 0 : 1\n"
"//var float3 iNormal : $vin.TEXCOORD0 : TEXCOORD0 : 1 : 1\n"
"//var float3 iEyeDir : $vin.TEXCOORD1 : TEXCOORD1 : 2 : 1\n"
"//var float3 oColor : $vout.COLOR : COLOR : 3 : 1\n"
"ps.1.1\n"
"def c0, 0.000000, 0.000000, 0.000000, 0.000000\n"
"def c1, -1.000000, -1.000000, -1.000000, 0.000000\n"
"def c2, 0.000000, 0.000000, 1.000000, 0.000000\n"
"texcoord t0\n"
"texcoord t1\n"
"mov_x2 t0.rgb, t0\n"
"mov_x2 t1.rgb, t1\n"
"add t0.rgb, t0, c1\n"
"add t1.rgb, t1, c1\n"
"dp3 t0.rgb, t0, t1\n"
"add t0.a, c2.b, t0.b\n"
"mul r0.rgb, t0.a, t0.a\n"
"+ mov r0.a, c0.b\n"
"// 9 instructions\n"
"// End of program\n"
};



