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

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

//----------------------------------------------------------------------------
IridescencePShader::IridescencePShader ()
{
    // shader program (load the type of the current renderer)
    m_acProgram = ms_aacProgram[Renderer::GetType()];
}
//----------------------------------------------------------------------------
IridescencePShader::~IridescencePShader ()
{
}
//----------------------------------------------------------------------------
const char* IridescencePShader::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.RealTex\n"
"#semantic pmain.GradientTex\n"
"#var float2 i_f2Tex : $vin.TEXCOORD0 : TEXCOORD0 : 0 : 1\n"
"#var float3 i_f3Normal : $vin.TEXCOORD1 : TEXCOORD1 : 1 : 1\n"
"#var float3 i_f3EyeDir : $vin.TEXCOORD2 : TEXCOORD2 : 2 : 1\n"
"#var float i_fIntFactor : $vin.TEXCOORD3 : TEXCOORD3 : 3 : 1\n"
"#var float3 o_f3Color : $vout.COLOR : COLOR : 4 : 1\n"
"#var sampler2D RealTex :  : texunit 0 : 5 : 1\n"
"#var sampler2D GradientTex :  : texunit 1 : 6 : 1\n"
"PARAM c0 = {0, 0, 0.00390625, 1};\n"
"PARAM c1 = {2, 0.5, 0, 0};\n"
"TEMP R0;\n"
"TEMP R1;\n"
"TEMP R2;\n"
"TEX R0.xyz, fragment.texcoord[0], texture[0], 2D;\n"
"ADD R1.xyz, fragment.texcoord[1], -c1.y;\n"
"MUL R1.xyz, c1.x, R1;\n"
"ADD R2.xyz, fragment.texcoord[2], -c1.y;\n"
"MUL R2.xyz, c1.x, R2;\n"
"DP3 R1.x, R1, R2;\n"
"ADD R1.x, c0.w, R1.x;\n"
"MAD R1.x, R1.x, R1.x, c0.z;\n"
"MOV_SAT R1.y, c0.y;\n"
"TEX R1.xyz, R1, texture[1], 2D;\n"
"ADD R1.xyz, R1, -R0;\n"
"MAD result.color.xyz, fragment.texcoord[3].x, R1, R0;\n"
"END\n"
"# 12 instructions, 3 R-regs, 0 H-regs.\n"
"# End of program\n"
,
"// DX9 Pixel Shader by NVIDIA Cg compiler\n"
"	ps_2_0\n"
"// cgc version 1.1.0003, build date Jul  7 2003  11:55:19\n"
"// command line args: -q -profile ps_2_0 -entry pmain -profileopts dcls -strict\n"
"//vendor NVIDIA Corporation\n"
"//version 1.0.02\n"
"//profile ps_2_0\n"
"//program pmain\n"
"//semantic pmain.RealTex\n"
"//semantic pmain.GradientTex\n"
"//var float2 i_f2Tex : $vin.TEXCOORD0 : TEXCOORD0 : 0 : 1\n"
"//var float3 i_f3Normal : $vin.TEXCOORD1 : TEXCOORD1 : 1 : 1\n"
"//var float3 i_f3EyeDir : $vin.TEXCOORD2 : TEXCOORD2 : 2 : 1\n"
"//var float i_fIntFactor : $vin.TEXCOORD3 : TEXCOORD3 : 3 : 1\n"
"//var float3 o_f3Color : $vout.COLOR : COLOR : 4 : 1\n"
"//var sampler2D RealTex :  : texunit 0 : 5 : 1\n"
"//var sampler2D GradientTex :  : texunit 1 : 6 : 1\n"
"	dcl_2d	s0\n"
"	dcl_2d	s1\n"
"	def	c0,	0.000000, 0.000000, 0.000000, 1.000000\n"
"	def	c1,	0.003906, 2.000000, 0.500000, 0.000000\n"
"	dcl	t0.xy\n"
"	dcl	t1.xyz\n"
"	dcl	t2.xyz\n"
"	dcl	t3.x\n"
"texld   r0, t0, s0\n"
"add     r1.xyz, t1, -c1.z\n"
"mul     r1.xyz, c1.y, r1\n"
"add     r2.xyz, t2, -c1.z\n"
"mul     r2.xyz, c1.y, r2\n"
"dp3     r1.x, r1, r2\n"
"add     r1.x, c0.w, r1.x\n"
"mad     r1.x, r1.x, r1.x, c1.x\n"
"mov_sat r1.y, c0.y\n"
"texld   r1, r1, s1\n"
"add     r1.xyz, r1, -r0\n"
"mad     r0.xyz, t3.x, r1, r0\n"
"mov     r1.w, c0.w\n"
"mov     r1.xyz, r0\n"
"mov     oC0, r1\n"
"// 15 instructions, 3 R-regs.\n"
"// End of program\n"
};



