// 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 "Wm3RefractionPShader.h"
using namespace Wm3;

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

//----------------------------------------------------------------------------
RefractionPShader::RefractionPShader ()
{
    // shader program (load the type of the current renderer)
    m_acProgram = ms_aacProgram[Renderer::GetType()];
}
//----------------------------------------------------------------------------
RefractionPShader::~RefractionPShader ()
{
}
//----------------------------------------------------------------------------
const char* RefractionPShader::ms_aacProgram[Renderer::RT_QUANTITY] =
{
"!!ARBfp1.0\n"
"# ARB_fragment_program generated by NVIDIA Cg compiler\n"
"# cgc version 1.1.0003, build date Jul  7 2003  11:55:19\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"
"#semantic pmain.EnvMap0\n"
"#semantic pmain.EnvMap1\n"
"#var float4 iReflectFactor : $vin.COLOR : COLOR : 0 : 1\n"
"#var float2 iRefractVec : $vin.TEXCOORD0 : TEXCOORD0 : 1 : 1\n"
"#var float2 iReflectVec : $vin.TEXCOORD1 : TEXCOORD1 : 2 : 1\n"
"#var float4 oColor : $vout.COLOR : COLOR : 3 : 1\n"
"#var sampler2D EnvMap0 :  : texunit 0 : 4 : 1\n"
"#var sampler2D EnvMap1 :  : texunit 1 : 5 : 1\n"
"TEMP R0;\n"
"TEMP R1;\n"
"TEX R0, fragment.texcoord[1], texture[1], 2D;\n"
"TEX R1, fragment.texcoord[0], texture[0], 2D;\n"
"ADD R0, R0, -R1;\n"
"MAD result.color, fragment.color.primary.x, R0, R1;\n"
"END\n"
"# 4 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 Jul  7 2003  11:55:19\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"
"//semantic pmain.EnvMap0\n"
"//semantic pmain.EnvMap1\n"
"//var float4 iReflectFactor : $vin.COLOR : COLOR : 0 : 1\n"
"//var float2 iRefractVec : $vin.TEXCOORD0 : TEXCOORD0 : 1 : 1\n"
"//var float2 iReflectVec : $vin.TEXCOORD1 : TEXCOORD1 : 2 : 1\n"
"//var float4 oColor : $vout.COLOR : COLOR : 3 : 1\n"
"//var sampler2D EnvMap0 :  : texunit 0 : 4 : 1\n"
"//var sampler2D EnvMap1 :  : texunit 1 : 5 : 1\n"
"ps.1.1\n"
"def c0, 1.000000, 0.000000, 0.000000, 0.000000\n"
"tex t0\n"
"tex t1\n"
"dp3 t2.rgb, c0, v0\n"
"dp3 t3.rgb, c0, v0\n"
"+ mov_sat t2.a, t2.b\n"
"mul r0.rgb, t1, t3\n"
"+ mul r1.a, t1.a, t3.b\n"
"mad r0.rgb, 1-t2.a, t0, r0\n"
"+ mad r0.a, 1-t2.a, t0.a, r1\n"
"// 6 instructions\n"
"// End of program\n"
};



