//-----------------------------------------------------------------------------
// ps14_CubeBumpReflect.sha
// 
// A list of a whole class of shaders which interpolate the tangent to world
// space matrix and use that to transform the normal map into the environment
// map's space for doing per pixel reflections and refractions. 
//
// One added bit in these shaders is the fudge factor used to compensate for
// the fact that the reflection or refraction vectors are not originated from
// the center of an infinately big environment map.
//
//    Chris Brennan - ATI Research, Inc. - 2001
//-----------------------------------------------------------------------------

matrix mW;      // World matrix
matrix mWVP;    // World*View*Projection matrix
matrix mWrt;    // Inverse Transpose World Rotation matrix
matrix mWVt;    // Inverse Transpose World*View matrix
vector pOV;     // Object space viewer position
vector cnst;
vector cHlf;

texture tBase;
texture tGloss;
texture tCube;
texture tDiffuseCube;
texture tNormal;
texture tNormalizer;

DWord dwCubeMipFilter = 2; // None = 0, Point = 1, Linear = 2

vertexshader vTexTangentmatrixViewLight = 
	decl
	{
		stream 0;
		float    v0[3];  // Position
		D3DCOLOR v3;     // Normal
		float    v7[2];  // Tex coord 0
		D3DCOLOR v8;     // Binormal
		D3DCOLOR v9;     // Tangent
	}
	asm
	{
    ; Sample vertex shader which outputs a 3x3 orthogonal transform which 
    ; takes you from world space to tangent space.  The result is stored in 
    ; output tex coords 1,2,and 3. Tex coord 4 stores a view vector which 
    ; can be used in a reflect operation.
    ; 
    ; Tex coordinate 5 stores a scaled version of the centroid to vertex
    ; vector that is used as a correction factor for environment mapping.
    ;
    ; This sample expects the incoming vertex data to be set up as follows:
    ;
    ; v0     - Vertex Position
    ; v3	 - Vertex Normal
    ; v7	 - Vertex 2D Bumpmap Texture Coords
    ; v8	 - Vertex Tangent (normalized assumed to be positive v direction for tangent space)
    ; v9	 - Vertex Tangent (normalized assumed to be positive u direction for tangent space)
    ; This sample expects the constant store to be set up in the following manner:
    ;
    ; c1       - Color of material
    ; c12..c15 - World Matrix
    ; c16..c19 - Composite World-View-Projection Matrix
    ; c20..c23 - Env Transform Matrix  (object to world or view coord transform 
    ;            (depends on type of env mapping you want to do) )
    ; c28      - ModelSpace Camera Position
    ; c95      - 0, .5, 1, 2
    vs.1.0
    def c94, 0.1f, 0.33f, 0.20f, 0.18f  ; Scalar for cube map adjustment 
                                        ; = roughly 1/Radius of environment map.

    ; OutPos = ObjSpacePos * Composite World-View-Projection Matrix
    m4x4   oPos, v0, c16
    mov    oT0.xy, v7		; passthrough texcoord 0 for bump map addressing

    ;derive per vertex eye vector using camera position   
    add		r8, c28, -v0	   ; view direction
    m3x3	r9, r8, c20        ; transform view vector from object space to env space
    dp3	    r11.x, r9, r9	   ; magnitude^2
    rsq	    r11.y, r11.x	   ; 1/mag
    mul     oT4.xyz, r9, r11.y ; normalize

    ;Expand from compressed D3DCOLOR to -1 to 1 range.
    mad  r3, v3, c95.wwwz, -c95.zzzx ; Normal = (v3*2.0)-1.0
    mad  r7, v8, c95.wwwz, -c95.zzzx ; TangentU = (v8*2.0)-1.0
    mad  r8, v9, c95.wwwz, -c95.zzzx ; TangentV = (v9*2.0)-1.0

    ; upper 3x3 of world matrix by upper tangent space transposed
    dp3		oT1.x, c20, r7
    dp3		oT1.y, c20, r8
    dp3		oT1.z, c20, r3

    dp3		oT2.x, c21, r7
    dp3		oT2.y, c21, r8
    dp3		oT2.z, c21, r3

    dp3		oT3.x, c22, r7
    dp3		oT3.y, c22, r8
    dp3		oT3.z, c22, r3

    ; Calculate a adjustment amount to account for cube map center not being at this object's centroid.
    m3x3 r0, v0, c12
    mul oT5, r0, c94.w
    };

pixelshader ps14_Cube_Bump_Diff_Reflect = asm
{
    ps.1.4

    texld   r0, t0              ; Look up normal map.
    texcrd  r1.rgb, t4          ; Eye vector
    texcrd  r4.rgb, t1          ; 1st row of environment matrix
    texcrd  r2.rgb, t2          ; 2st row of environment matrix
    texcrd  r3.rgb, t3          ; 3rd row of environment matrix
    texcrd  r5.rgb, t5          ; Cube map position adjustment

    dp3     r4.r, r4, r0_bx2        ; 1st row of matrix multiply
    dp3     r4.g, r2, r0_bx2        ; 2nd row of matrix multiply
    dp3     r4.b, r3, r0_bx2        ; 3rd row of matrix multiply
    dp3_x2  r3.rgb, r4, r1          ; 2(N.Eye)
    mul     r3.rgb, r4, r3          ; 2N(N.Eye)
    dp3     r2.rgb, r4, r4          ; N.N
    mad     r2.rgb, -r1, r2, r3     ; 2N(N.Eye) - Eye(N.N) 
    add     r2.rgb, r2, r5          ; Adjust for cube map center

    phase

    texld   r2, r2              ; Sample cubic reflection map
    texld   r3, t0              ; Sample base map
    texld   r4, r4              ; Sample cubic diffuse map
    texld   r5, t0              ; Sample gloss map

    mul     r1.rgb, r5, r2       ; Specular = Gloss*Reflection
    mad     r0.rgb, r3, r4_x2, r1   ; Base*Diffuse + Specular
    +mov    r0.a, r3
};

String ps14_Cube_Bump_Diff_Reflect_desc = "PS 1.4 - Cubic Environment Bumped Diffuse and Independently Colored Reflections";

technique ps14_Cube_Bump_Diff_Reflect
{
    pass P0 
    {
        VertexShaderConstant[12] = <mW>;    // World
        VertexShaderConstant[16] = <mWVP>;  // World*View*Proj Matrix
        VertexShaderConstant[20] = <mWrt>;  // World Rotation Inv Transpose used for Eye vector transform
        VertexShaderConstant[28] = <pOV>;   // Object space Viewer position
        VertexShaderConstant[95] = <cnst>;
        VertexShader = <vTexTangentmatrixViewLight>;

        Texture[0]   = <tNormal>;
        MagFilter[0] = Linear;
        MinFilter[0] = Linear;
        MipFilter[0] = Linear;

        Texture[1]   = <tNormalizer>;
        AddressU[1]  = Clamp;
        AddressV[1]  = Clamp;
        MagFilter[1] = Linear;
        MinFilter[1] = Linear;
        MipFilter[1] = Point;

        Texture[2]   = <tCube>;
        AddressU[2]  = Clamp;
        AddressV[2]  = Clamp;
        MagFilter[2] = Linear;
        MinFilter[2] = Linear;
        MipFilter[2] = <dwCubeMipFilter>;

        Texture[3]   = <tBase>;
        AddressU[3]  = Wrap;
        AddressV[3]  = Wrap;
        MagFilter[3] = Linear;
        MinFilter[3] = Linear;
        MipFilter[2] = Linear;

        Texture[4]   = <tDiffuseCube>;
        AddressU[4]  = Clamp;
        AddressV[4]  = Clamp;
        MagFilter[4] = Linear;
        MinFilter[4] = Linear;
        MipFilter[4] = <dwCubeMipFilter>;

        Texture[5]   = <tGloss>;
        AddressU[5]  = Wrap;
        AddressV[5]  = Wrap;
        MagFilter[5] = Linear;
        MinFilter[5] = Linear;
        MipFilter[5] = Linear;

        PixelShader  = <ps14_Cube_Bump_Diff_Reflect>;
    }
}

pixelshader ps14_Cube_Bump_Diff_Refract = asm
{
    ps.1.4

    def     c0, 0.9f, 0.0f, 0.0f, 0.0f
    texld   r0, t0              ; Look up normal map.
    texcrd  r1.rgb, t4          ; Eye vector
    texcrd  r4.rgb, t1          ; t row of environment matrix
    texcrd  r2.rgb, t2          ; 21sst row of environment matrix
    texcrd  r3.rgb, t3          ; 3rd row of environment matrix
    texcrd  r5.rgb, t5          ; Cube map position adjustment

    dp3     r4.r, r4, r0_bx2        ; 1st row of matrix multiply
    dp3     r4.g, r2, r0_bx2        ; 2nd row of matrix multiply
    dp3     r4.b, r3, r0_bx2        ; 3rd row of matrix multiply
    lrp     r2.rgb, c0.r, -r1, -r4  ; Refract by c0 = index of refraction fudge factor
    add     r2.rgb, r5, r2          ; Adjust for cube map center

    phase

    texld   r2, r2              ; Sample cubic reflection map
    texld   r3, t0              ; Sample base map
    texld   r4, r4              ; Sample cubic diffuse map
    texld   r5, t0              ; Sample gloss map

    mul     r1.rgb, r5, r2          ; Specular = Gloss*Reflection
    mad     r0.rgb, r3, r4_x2, r1   ; Base*Diffuse + Specular
   +mov     r0.a, r3
};

String ps14_Cube_Bump_Diff_Refract_desc = "PS 1.4 - Cubic Environment Diffuse Light and Tinted Refractions";

technique ps14_Cube_Bump_Diff_Refract
{
    pass P0 
    {
        VertexShaderConstant[12] = <mW>;    // World
        VertexShaderConstant[16] = <mWVP>;  // World*View*Proj Matrix
        VertexShaderConstant[20] = <mWrt>;  // World Rotation Inv Transpose used for Eye vector transform
        VertexShaderConstant[28] = <pOV>;   // Object space Viewer position
        VertexShaderConstant[95] = <cnst>;
        VertexShader = <vTexTangentmatrixViewLight>;

        Texture[0]   = <tNormal>;
        MagFilter[0] = Linear;
        MinFilter[0] = Linear;
        MipFilter[0] = Linear;

        Texture[1]   = <tNormalizer>;
        AddressU[1]  = Clamp;
        AddressV[1]  = Clamp;
        MagFilter[1] = Linear;
        MinFilter[1] = Linear;
        MipFilter[1] = Linear;

        Texture[2]   = <tCube>;
        AddressU[2]  = Clamp;
        AddressV[2]  = Clamp;
        MagFilter[2] = Linear;
        MinFilter[2] = Linear;
        MipFilter[2] = <dwCubeMipFilter>;

        Texture[3]   = <tBase>;
        AddressU[3]  = Wrap;
        AddressV[3]  = Wrap;
        MagFilter[3] = Linear;
        MinFilter[3] = Linear;
        MipFilter[2] = Linear;

        Texture[4]   = <tDiffuseCube>;
        AddressU[4]  = Clamp;
        AddressV[4]  = Clamp;
        MagFilter[4] = Linear;
        MinFilter[4] = Linear;
        MipFilter[4] = <dwCubeMipFilter>;

        Texture[5]   = <tGloss>;
        AddressU[5]  = Wrap;
        AddressV[5]  = Wrap;
        MagFilter[5] = Linear;
        MinFilter[5] = Linear;
        MipFilter[5] = Linear;

        PixelShader  = <ps14_Cube_Bump_Diff_Refract>;
    }
}

pixelshader ps14_Cube_Bump_Diffuse = asm
{
    ps.1.4

    texld   r0, t0             ; Look up normal map.
    texcrd  r4.rgb, t1         ; 1st row of environment matrix
    texcrd  r2.rgb, t2         ; 2st row of environment matrix
    texcrd  r3.rgb, t3         ; 3rd row of environment matrix

    dp3     r4.r, r4, r0_bx2   ; 1st row of matrix multiply
    dp3     r4.g, r2, r0_bx2   ; 2nd row of matrix multiply
    dp3     r4.b, r3, r0_bx2   ; 3rd row of matrix multiply

    phase

    texld   r3, t0             ; Sample base map
    texld   r4, r4             ; Sample Diffuse Cube Map

    mul     r0.rgb, r3, r4_x2  ; Base*Diffuse
    +mov    r0.a, r3
};

String ps14_Cube_Bump_Diffuse_desc = "PS 1.4 - Cubic Environment Diffuse Light component";

technique ps14_Cube_Bump_Diffuse
{
    pass P0 
    {
        VertexShaderConstant[12] = <mW>;    // World
        VertexShaderConstant[16] = <mWVP>;  // World*View*Proj Matrix
        VertexShaderConstant[20] = <mWrt>;  // World Rotation Inv Transpose used for Eye vector transform
        VertexShaderConstant[28] = <pOV>;   // Object space Viewer position
        VertexShaderConstant[95] = <cnst>;
        VertexShader = <vTexTangentmatrixViewLight>;

        Texture[0]   = <tNormal>;
        MagFilter[0] = Linear;
        MinFilter[0] = Linear;
        MipFilter[0] = Linear;

        Texture[3]   = <tBase>;
        AddressU[3]  = Wrap;
        AddressV[3]  = Wrap;
        MagFilter[3] = Linear;
        MinFilter[3] = Linear;
        MipFilter[3] = Linear;

        Texture[4]   = <tDiffuseCube>;
        AddressU[4]  = Clamp;
        AddressV[4]  = Clamp;
        MagFilter[4] = Linear;
        MinFilter[4] = Linear;
        MipFilter[4] = <dwCubeMipFilter>;

        PixelShader  = <ps14_Cube_Bump_Diffuse>;
    }
}

pixelshader ps14_Cube_Bump_Reflect = asm
{
    ps.1.4

    texld  r0, t0              ; Look up normal map.
    texcrd r1.rgb, t4          ; Eye vector through normalizer cube map
    texcrd r4.rgb, t1          ; 1st row of environment matrix
    texcrd r2.rgb, t2          ; 2st row of environment matrix
    texcrd r3.rgb, t3          ; 3rd row of environment matrix
    texcrd r5.rgb, t5          ; Cube map position adjustment

    dp3    r4.r, r4, r0_bx2        ; 1st row of matrix multiply
    dp3    r4.g, r2, r0_bx2        ; 2nd row of matrix multiply
    dp3    r4.b, r3, r0_bx2        ; 3rd row of matrix multiply
    dp3_x2 r3.rgb, r4, r1          ; 2(N.Eye)
    mul    r3.rgb, r4, r3          ; 2N(N.Eye)
    dp3    r2.rgb, r4, r4          ; N.N
    mad    r2.rgb, -r1, r2, r3     ; 2N(N.Eye) - Eye(N.N) 
    add    r2.rgb, r2, r5          ; Adjust for cube map center

    phase

    texld  r2, r2              ; Sample cubic reflection map
    texld  r5, t0              ; Sample gloss map

    mul    r0, r5, r2      ; Specular = Gloss*Reflection
};

String ps14_Cube_Bump_Reflect_desc = "PS 1.4 - Cubic Environment Reflection component";

technique ps14_Cube_Bump_Reflect
{
    pass P0 
    {
        VertexShaderConstant[12] = <mW>;    // World
        VertexShaderConstant[16] = <mWVP>;  // World*View*Proj Matrix
        VertexShaderConstant[20] = <mWrt>;  // World Rotation Inv Transpose used for Eye vector transform
        VertexShaderConstant[28] = <pOV>;   // Object space Viewer position
        VertexShaderConstant[95] = <cnst>;
        VertexShader = <vTexTangentmatrixViewLight>;

        Texture[0]   = <tNormal>;
        MagFilter[0] = Linear;
        MinFilter[0] = Linear;
        MipFilter[0] = Linear;

        Texture[1]   = <tNormalizer>;
        AddressU[1]  = Clamp;
        AddressV[1]  = Clamp;
        MagFilter[1] = Linear;
        MinFilter[1] = Linear;
        MipFilter[1] = Point;

        Texture[2]   = <tCube>;
        AddressU[2]  = Clamp;
        AddressV[2]  = Clamp;
        MagFilter[2] = Linear;
        MinFilter[2] = Linear;
        MipFilter[2] = <dwCubeMipFilter>;

        Texture[3]   = <tBase>;
        AddressU[3]  = Wrap;
        AddressV[3]  = Wrap;
        MagFilter[3] = Linear;
        MinFilter[3] = Linear;
        MipFilter[3] = Linear;

        Texture[5]   = <tGloss>;
        AddressU[5]  = Wrap;
        AddressV[5]  = Wrap;
        MagFilter[5] = Linear;
        MinFilter[5] = Linear;
        MipFilter[5] = Linear;

        PixelShader  = <ps14_Cube_Bump_Reflect>;
    }
}

pixelshader ps14_Cube_Bump_Diff_Fresnel_Reflect = asm
{
    ps.1.4

    texld  r0, t0              ; Look up normal map.
    texcrd r1.rgb, t4          ; Eye vector through normalizer cube map
    texcrd r4.rgb, t1          ; 1st row of environment matrix
    texcrd r2.rgb, t2          ; 2st row of environment matrix
    texcrd r3.rgb, t3          ; 3rd row of environment matrix
    texcrd r5.rgb, t5          ; Cube map position adjustment

    dp3     r4.r, r4, r0_bx2        ; 1st row of matrix multiply
    dp3     r4.g, r2, r0_bx2        ; 2nd row of matrix multiply
    dp3     r4.b, r3, r0_bx2        ; 3rd row of matrix multiply
    dp3     r0.rgb, r4, r1          ; (N.Eye)
    mad     r3.rgb, r4_x2, r0, r5   ; 2N(N.Eye) + adjustment for position not being at center of cube map
    dp3     r2.rgb, r4, r4          ; N.N
    mad     r2.rgb, -r1, r2, r3     ; 2N(N.Eye) - Eye(N.N) 
    mov_sat r0.rgb, 1-r0            ; Pass through 1-(N.Eye) for fresnal calculation

    phase

    ; texcrd r0, r0            ; N.Eye used for fresnel calculation
    texld  r2, r2              ; Sample cubic reflection map
    texld  r3, t0              ; Sample base map
    texld  r4, r4              ; Sample cubic diffuse map
    texld  r5, t0              ; Sample gloss map

    mul     r1.rgb, r5, r2          ; Specular = Gloss*Reflection
    +mul    r0.a, r0.b, r0.b        ; ^2
    mul     r0.rgb, r1, r0.b        ; Specular * Fresnel
    mad     r0.rgb, r3, r4_x2, r0   ; Base*Diffuse + Specular
};

String ps14_Cube_Bump_Diff_Fresnel_Reflect_desc = "PS 1.4 - Cubic Environment Bumped Diffuse and Tinted Reflections with per pixel Fresnel Term";

technique ps14_Cube_Bump_Diff_Fresnel_Reflect
{
    pass P0 
    {
        VertexShaderConstant[12] = <mW>;    // World
        VertexShaderConstant[16] = <mWVP>;  // World*View*Proj Matrix
        VertexShaderConstant[20] = <mWrt>;  // World Rotation Inv Transpose used for Eye vector transform
        VertexShaderConstant[28] = <pOV>;   // Object space Viewer position
        VertexShaderConstant[95] = <cnst>;
        VertexShader = <vTexTangentmatrixViewLight>;

        Texture[0]   = <tNormal>;
        MagFilter[0] = Linear;
        MinFilter[0] = Linear;
        MipFilter[0] = Linear;

        Texture[1]   = <tNormalizer>;
        AddressU[1]  = Clamp;
        AddressV[1]  = Clamp;
        MagFilter[1] = Linear;
        MinFilter[1] = Linear;
        MipFilter[1] = Point;

        Texture[2]   = <tCube>;
        AddressU[2]  = Clamp;
        AddressV[2]  = Clamp;
        MagFilter[2] = Linear;
        MinFilter[2] = Linear;
        MipFilter[2] = <dwCubeMipFilter>;

        Texture[3]   = <tBase>;
        AddressU[3]  = Wrap;
        AddressV[3]  = Wrap;
        MagFilter[3] = Linear;
        MinFilter[3] = Linear;
        MipFilter[2] = Linear;

        Texture[4]   = <tDiffuseCube>;
        AddressU[4]  = Clamp;
        AddressV[4]  = Clamp;
        MagFilter[4] = Linear;
        MinFilter[4] = Linear;
        MipFilter[4] = <dwCubeMipFilter>;

        Texture[5]   = <tGloss>;
        AddressU[5]  = Wrap;
        AddressV[5]  = Wrap;
        MagFilter[5] = Linear;
        MinFilter[5] = Linear;
        MipFilter[5] = Linear;

        PixelShader  = <ps14_Cube_Bump_Diff_Fresnel_Reflect>;
    }
}

pixelshader ps14_Cube_Bump_Fresnel = asm
{
    ps.1.4

    texld  r0, t0              ; Look up normal map.
    texcrd r1.rgb, t4          ; Eye vector through normalizer cube map
    texcrd r4.rgb, t1          ; 1st row of environment matrix
    texcrd r2.rgb, t2          ; 2st row of environment matrix
    texcrd r3.rgb, t3          ; 3rd row of environment matrix

    dp3     r4.r, r4, r0_bx2   ; 1st row of matrix multiply
    dp3     r4.g, r2, r0_bx2   ; 2nd row of matrix multiply
    dp3     r4.b, r3, r0_bx2   ; 3rd row of matrix multiply
    dp3     r5, r4, r1         ; (N.Eye)
    mov     r0, 1-r5
    mul     r0, r0, r0
};

String ps14_Cube_Bump_Fresnel_desc = "PS 1.4 - Per Pixel Fresnel Term";

technique ps14_Cube_Bump_Fresnel
{
    pass P0 
    {
        VertexShaderConstant[12] = <mW>;    // World
        VertexShaderConstant[16] = <mWVP>;  // World*View*Proj Matrix
        VertexShaderConstant[20] = <mWrt>;  // World Rotation Inv Transpose used for Eye vector transform
        VertexShaderConstant[28] = <pOV>;   // Object space Viewer position
        VertexShaderConstant[95] = <cnst>;
        VertexShader = <vTexTangentmatrixViewLight>;

        Texture[0]   = <tNormal>;
        MagFilter[0] = Linear;
        MinFilter[0] = Linear;
        MipFilter[0] = Linear;

        Texture[1]   = <tNormalizer>;
        AddressU[1]  = Clamp;
        AddressV[1]  = Clamp;
        MagFilter[1] = Linear;
        MinFilter[1] = Linear;
        MipFilter[1] = Point;

        PixelShader  = <ps14_Cube_Bump_Fresnel>;
    }
}

pixelshader ps14_Cube_Bump_Fresnel_Reflect = asm
{
    ps.1.4

    texld  r0, t0              ; Look up normal map.
    texcrd r1.rgb, t4          ; Eye vector through normalizer cube map
    texcrd r4.rgb, t1          ; 1st row of environment matrix
    texcrd r2.rgb, t2          ; 2st row of environment matrix
    texcrd r3.rgb, t3          ; 3rd row of environment matrix
    texcrd r5.rgb, t5          ; Cube map position adjustment

    dp3     r4.r, r4, r0_bx2        ; 1st row of matrix multiply
    dp3     r4.g, r2, r0_bx2        ; 2nd row of matrix multiply
    dp3     r4.b, r3, r0_bx2        ; 3rd row of matrix multiply
    dp3     r0.rgb, r4, r1          ; (N.Eye)
    mad     r3.rgb, r4_x2, r0, r5   ; 2N(N.Eye) + adjustment for position not being at center of cube map
    dp3     r2.rgb, r4, r4          ; N.N
    mad     r2.rgb, -r1, r2, r3     ; 2N(N.Eye) - Eye(N.N) 
    mov_sat r0.rgb, 1-r0            ; Pass through 1-(N.Eye) for fresnal calculation

    phase

    ; texcrd r0, r0            ; N.Eye used for fresnel calculation
    texld  r2, r2              ; Sample cubic reflection map
    texld  r5, t0              ; Sample gloss map

    mul     r1.rgb, r5, r2          ; Specular = Gloss*Reflection
    +mul    r0.a, r0.b, r0.b        ; ^2
    mul     r0.rgb, r1, r0.b        ; Specular * Fresnel
};

String ps14_Cube_Bump_Fresnel_Reflect_desc = "PS 1.4 - Cubic Environment Bumped Tinted Reflections with per pixel Fresnel Term";

technique ps14_Cube_Bump_Fresnel_Reflect
{
    pass P0 
    {
        VertexShaderConstant[12] = <mW>;    // World
        VertexShaderConstant[16] = <mWVP>;  // World*View*Proj Matrix
        VertexShaderConstant[20] = <mWrt>;  // World Rotation Inv Transpose used for Eye vector transform
        VertexShaderConstant[28] = <pOV>;   // Object space Viewer position
        VertexShaderConstant[95] = <cnst>;
        VertexShader = <vTexTangentmatrixViewLight>;

        Texture[0]   = <tNormal>;
        MagFilter[0] = Linear;
        MinFilter[0] = Linear;
        MipFilter[0] = Linear;

        Texture[1]   = <tNormalizer>;
        AddressU[1]  = Clamp;
        AddressV[1]  = Clamp;
        MagFilter[1] = Linear;
        MinFilter[1] = Linear;
        MipFilter[1] = Point;

        Texture[2]   = <tCube>;
        AddressU[2]  = Clamp;
        AddressV[2]  = Clamp;
        MagFilter[2] = Linear;
        MinFilter[2] = Linear;
        MipFilter[2] = <dwCubeMipFilter>;

        Texture[5]   = <tGloss>;
        AddressU[5]  = Wrap;
        AddressV[5]  = Wrap;
        MagFilter[5] = Linear;
        MinFilter[5] = Linear;
        MipFilter[5] = Linear;

        PixelShader  = <ps14_Cube_Bump_Fresnel_Reflect>;
    }
}

