Im in, Im actually working on Rez right now lawl
i am looking for people to help me find the character textures since there are about 70 rez files maybe i could get between 5-7 people to help me once i have selected people i will pm you details first come first serve thank you for your help and remember your doing mpgh a favor
Im in, Im actually working on Rez right now lawl
the REZ file for the charecters texture is RF002.REZ , its sooo long but you can try to play at the c++ code at the end of it which start at the address "031ae0b2"
and here is the code at the end of the rez file , try to play with that thing about shinning or the shadow , it may become a little handy
""GOOD LUCK""
================================================== ===================
texture g_txSrcTexture; // This texture will be loaded by the application
sampler2D texmap_sampler = sampler_state
{
Texture = <g_txSrcTexture>;
MinFilter = Point;
MagFilter = Point;
MipFilter = Point;
};
//-----------------------------------------------------------------------------
// Main
//-----------------------------------------------------------------------------
technique ProcessScreen
{
pass p0
{
Sampler[0] = <texmap_sampler>;
MipFilter[0] = POINT;
MinFilter[0] = POINT;
MagFilter[0] = POINT;
PixelShader =
asm
{
ps_1_1
def c0, 0.30, 0.59, 0.11, 1.0
tex t0
mov r0, t0
dp3 r0, r0, c0
};
}
}
technique Fallback
{
pass p0
{
}
}
//
// Fullscreen inverse color
//
//-----------------------------------------------------------------------------
// Effect File Variables
//-----------------------------------------------------------------------------
float4x4 worldMatrix;
float4x4 viewProjMatrix;
texture g_txSrcTexture; // This texture will be loaded by the application
float4 cColor = {1.0f,1.0f,1.0f,2.0f};
sampler Sampler = sampler_state
{
Texture = (g_txSrcTexture);
MipFilter = POINT;
MinFilter = POINT;
MagFilter = POINT;
};
//-----------------------------------------------------------------------------
// Vertex Definitions
//-----------------------------------------------------------------------------
struct VS_INPUT
{
float4 position : POSITION;
float4 color : COLOR0;
float2 texture0 : TEXCOORD0;
};
struct VS_OUTPUT
{
float4 position : POSITION;
float4 color : COLOR;
float2 texture0 : TEXCOORD0;
};
struct PS_OUTPUT
{
float4 color : COLOR;
};
// Vertex Shader
//-----------------------------------------------------------------------------
// Not really needed by this effect. Added as example.
VS_OUTPUT VS( VS_INPUT IN )
{
VS_OUTPUT OUT;
float4 newPos = mul(worldMatrix, IN.position);
newPos = mul( viewProjMatrix, newPos);
OUT.position = newPos;
OU*****lor = float4( 1.0, 1.0, 1.0, 1.0 );
OUT.texture0 = IN.texture0;
return OUT;
}
//-----------------------------------------------------------------------------
// Pixel Shader
//-----------------------------------------------------------------------------
PS_OUTPUT PS( VS_OUTPUT IN )
{
PS_OUTPUT OUT;
// Sampled texture color
float4 actColor = (tex2D( Sampler, IN.texture0 ) * IN.color);
OU*****lor = cColor - actColor;
return OUT;
}
//-----------------------------------------------------------------------------
// Main
//-----------------------------------------------------------------------------
technique ProcessScreen
{
pass p0
{
VertexShader = compile vs_1_1 VS();
PixelShader = compile ps_1_1 PS();
}
}
technique Fallback
{
pass p0
{
}
}
//
// SepiaTone in one pass.
//
//-----------------------------------------------------------------------------
// Effect File Variables
//-----------------------------------------------------------------------------
texture g_txSrcTexture; // This texture will be loaded by the application
sampler2D texmap_sampler = sampler_state
{
Texture = <g_txSrcTexture>;
MinFilter = Point;
MagFilter = Point;
MipFilter = Point;
};
//-----------------------------------------------------------------------------
// Main
//-----------------------------------------------------------------------------
technique ProcessScreen
{
pass p0
{
Sampler[0] = <texmap_sampler>;
MipFilter[0] = POINT;
MinFilter[0] = POINT;
MagFilter[0] = POINT;
PixelShader =
asm
{
ps_1_1
def c0, 0.299, 0.587, 0.114, 0
def c1, 0.191, -0.054, -0.221, 0
tex t0
dp3 r0, c0, t0
add r0, r0, c1
};
}
}
technique Fallback
{
pass p0
{
}
}
//
// Sobel Edge Filter.
//
// Source: HLSL Introduction
//-----------------------------------------------------------------------------
// Effect File Variables
//-----------------------------------------------------------------------------
texture g_txSrcTexture; // This texture will be loaded by the application
float Brightness = 1.0;
sampler Sampler = sampler_state
{
Texture = (g_txSrcTexture);
MipFilter = POINT;
MinFilter = POINT;
MagFilter = POINT;
};
//-----------------------------------------------------------------------------
// Vertex Definitions
//-----------------------------------------------------------------------------
struct VS_INPUT
{
float4 position : POSITION;
float4 color : COLOR0;
float2 texture0 : TEXCOORD0;
};
struct VS_OUTPUT
{
float4 position : POSITION;
float4 color : COLOR;
float2 texture0 : TEXCOORD0;
};
struct PS_OUTPUT
{
float4 color : COLOR;
};
PS_OUTPUT PS( VS_OUTPUT IN )
{
PS_OUTPUT OUT;
//const specifies the constants. The c[NUM] is a float2 constant array.
//Notes its initialization is convenience like C language. col[NUM] is a variable array
//of type float3 with NUM elements. int i declares the i as integer. These usage is
//effective for pixel shader 2.0 or later.
const int NUM = 9;
const float threshold = 0.05;
const float2 c[NUM] =
{
float2(-0.0078125, 0.0078125),
float2( 0.00 , 0.0078125),
float2( 0.0078125, 0.0078125),
float2(-0.0078125, 0.00 ),
float2( 0.0, 0.0),
float2( 0.0078125, 0.007 ),
float2(-0.0078125,-0.0078125),
float2( 0.00 , -0.0078125),
float2( 0.0078125,-0.0078125),
};
float3 col[NUM];
int i;
//store the samples of texture to col array.
for (i=0; i < NUM; i++)
{
col[i] = tex2D(Sampler, IN.texture0.xy + c[i]);
}
//now we start to compute the luminance with dot product and store them in lum array.
float3 rgb2lum = float3(0.30, 0.59, 0.11);
float lum[NUM];
for (i = 0; i < NUM; i++)
{
lum[i] = dot(col[i].xyz, rgb2lum);
}
//Sobel filter computes new value at the central position by sum the weighted neighbors.
float x = lum[2]+ lum[8]+2*lum[5]-lum[0]-2*lum[3]-lum[6];
float y = lum[6]+2*lum[7]+ lum[8]-lum[0]-2*lum[1]-lum[2];
//show the points which values are over the threshold and hide others.
//Final result is the product of col[5] and edge detector value. Brightness adjusts the brightness of the image.
float edge =(x*x + y*y < threshold)? 1.0:0.0;
//final output
OU*****lor.xyz = Brightness * col[5].xyz * edge;
OU*****lor.w = 1.0;
return OUT;
}
//-----------------------------------------------------------------------------
// Main
//-----------------------------------------------------------------------------
technique ProcessScreen
{
pass p0
{
MipFilter[0] = POINT;
MinFilter[0] = POINT;
MagFilter[0] = POINT;
PixelShader = compile ps_2_0 PS();
}
}
technique FallBack
{
pass p0
{
}
}
shared float fSaturate = 1.0;
technique T0
{
pass P0
{
}
}
//
// Model Inverse color in one pass.
//
float4 cColor = {1.0f, 1.0f, 1.0f, 1.0f};
texture texture0; // This texture will be loaded by the application
float4x4 worldMatrix;
float4x4 viewProjMatrix;
sampler Sampler0 = sampler_state
{
texture = <texture0>;
MipFilter = Linear;
MinFilter = Linear;
MagFilter = Linear;
};
//-----------------------------------------------------------------------------
// Vertex Definitions
//-----------------------------------------------------------------------------
struct VS_INPUT
{
float3 Position : POSITION0;
float3 Normal : NORMAL0;
float2 TexCoord : TEXCOORD0;
};
struct VS_OUTPUT
{
float4 Position : POSITION;
float2 TexCoord : TEXCOORD0;
float4 Color : COLOR0;
};
struct PS_OUTPUT
{
float4 color : COLOR;
};
//-----------------------------------------------------------------------------
// Vertex Shader
//-----------------------------------------------------------------------------
// Not really needed by this effect. Added as example.
VS_OUTPUT VS( VS_INPUT IN )
{
VS_OUTPUT OUT;
//OUT.position = mul( worldViewProj, float4(IN.position, 1.0) );
float4 newPos = mul(worldMatrix, float4(IN.Position,1.0));
newPos = mul( viewProjMatrix, newPos);
OUT.Position = newPos;
OUT.TexCoord = IN.TexCoord;
OU*****lor = cColor;
return OUT;
};
//-----------------------------------------------------------------------------
// Pixel Shader
//-----------------------------------------------------------------------------
PS_OUTPUT PS( VS_OUTPUT IN )
{
PS_OUTPUT OUT;
// Sampled texture color
float4 diffuseColor = (tex2D( Sampler0, IN.TexCoord ) * IN.Color);
// Invert the color
//OU*****lor = (cColor - diffuseColor);
// Just output the texture color at this pixel.
OU*****lor = diffuseColor;
return OUT;
};
technique T0
{
pass p0
{
CullMode=CCW;
VertexShader = compile vs_1_1 VS();
PixelShader = compile ps_1_1 PS();
}
}
// Fall back incase the device does not support pixel shaders
// The geforce MX440 for example only supports VS 1.1 with no support for PS.
technique FallbackOne
{
pass p0
{
CullMode=CCW;
VertexShader = compile vs_1_1 VS();
}
}
// Fallback in case the device does not support vertex or pixel shaders
technique FallbackTwo
{
pass p0
{
CullMode=CCW;
}
}
//
// Model Inverse color in one pass.
//
float4 cColor = {1.0f, 1.0f, 1.0f, 1.0f};
texture texture0; // This texture will be loaded by the application
float4x4 worldMatrix;
float4x4 viewProjMatrix;
sampler Sampler0 = sampler_state
{
texture = <texture0>;
MipFilter = Linear;
MinFilter = Linear;
MagFilter = Linear;
};
//-----------------------------------------------------------------------------
// Vertex Definitions
//-----------------------------------------------------------------------------
struct VS_INPUT
{
float3 Position : POSITION0;
float3 Normal : NORMAL0;
float2 TexCoord : TEXCOORD0;
float3 Tangent : TANGENT0;
float3 Binormal : BINORMAL0;
};
struct VS_OUTPUT
{
float4 Position : POSITION;
float2 TexCoord : TEXCOORD0;
float4 Color : COLOR0;
};
struct PS_OUTPUT
{
float4 color : COLOR;
};
//-----------------------------------------------------------------------------
// Vertex Shader
//-----------------------------------------------------------------------------
// Not really needed by this effect. Added as example.
VS_OUTPUT VS( VS_INPUT IN )
{
VS_OUTPUT OUT;
//OUT.position = mul( worldViewProj, float4(IN.position, 1.0) );
float4 newPos = mul(worldMatrix, float4(IN.Position,1.0));
newPos = mul( viewProjMatrix, newPos);
OUT.Position = newPos;
OUT.TexCoord = IN.TexCoord;
OU*****lor = cColor;
return OUT;
};
//-----------------------------------------------------------------------------
// Pixel Shader
//-----------------------------------------------------------------------------
PS_OUTPUT PS( VS_OUTPUT IN )
{
PS_OUTPUT OUT;
// Sampled texture color
float4 diffuseColor = (tex2D( Sampler0, IN.TexCoord ) * IN.Color);
// Invert the color
//OU*****lor = (cColor - diffuseColor);
// Just output the texture color at this pixel.
OU*****lor = diffuseColor;
return OUT;
};
technique T0
{
pass p0
{
CullMode=CCW;
VertexShader = compile vs_1_1 VS();
PixelShader = compile ps_1_1 PS();
}
}
// Fall back incase the device does not support pixel shaders
// The geforce MX440 for example only supports VS 1.1 with no support for PS.
technique FallbackOne
{
pass p0
{
CullMode=CCW;
VertexShader = compile vs_1_1 VS();
}
}
// Fallback in case the device does not support vertex or pixel shaders
technique FallbackTwo
{
pass p0
{
CullMode=CCW;
}
}
//
// Model Inverse color in one pass.
//
float4 cColor = {1.0f, 1.0f, 1.0f, 1.0f};
texture texture0; // This texture will be loaded by the application
float4x4 worldMatrix;
float4x4 worldMatrix1;
float4x4 worldMatrix2;
float4x4 worldMatrix3;
float4x4 viewProjMatrix;
int BoneCount = 0;
sampler Sampler0 = sampler_state
{
texture = <texture0>;
AddressU = Wrap;
AddressV = Wrap;
MipFilter = Linear;
MinFilter = Linear;
MagFilter = Linear;
};
//-----------------------------------------------------------------------------
// Vertex Definitions
//-----------------------------------------------------------------------------
struct VS_INPUT
{
float3 position : POSITION;
float BlendWeights : BLENDWEIGHT;
float3 normal : NORMAL;
float2 tex0 : TEXCOORD0;
};
struct VS_OUTPUT
{
float4 position : POSITION;
float2 tex0 : TEXCOORD0;
float4 color : COLOR0;
};
struct PS_OUTPUT
{
float4 color : COLOR;
};
//-----------------------------------------------------------------------------
// Vertex Shader
//-----------------------------------------------------------------------------
VS_OUTPUT VS_0WEIGHTS( VS_INPUT IN )
{
VS_OUTPUT OUT;
//
float4 p0 = mul(worldMatrix, float4(IN.position,1.0));
// Set this is the view projection...
float4 finalPos = mul( viewProjMatrix, p0);
OUT.position = finalPos;
OU*****lor = float4( 1.0, 1.0, 1.0, 1.0 );
OUT.tex0 = IN.tex0;
return OUT;
}
VS_OUTPUT VS_1WEIGHTS( VS_INPUT IN )
{
VS_OUTPUT OUT;
//
float4 p0 = mul(worldMatrix, float4(IN.position,1.0));
float4 p1 = mul(worldMatrix1, float4(IN.position,1.0));
//vBlend = (v1*w1) + (v2 * (1.0 - W1))
float4 vBlend = (p0*IN.BlendWeights) +
(p1 * (1.0 - IN.BlendWeights));
// Set this is the view projection...
float4 blendedPos = vBlend;
float4 finalPos = mul( viewProjMatrix, blendedPos);
OUT.position = finalPos;
OU*****lor = float4( 1.0, 1.0, 1.0, 1.0 );
OUT.tex0 = IN.tex0;
return OUT;
}
//-----------------------------------------------------------------------------
// Pixel Shader
//-----------------------------------------------------------------------------
PS_OUTPUT PS( VS_OUTPUT IN )
{
PS_OUTPUT OUT;
// Sampled texture color
float4 actColor = (tex2D( Sampler0, IN.tex0 ) * IN.color);
OU*****lor = actColor;
// Inverted color
// float4 invColor = cColor - actColor;
// OU*****lor = invColor;
return OUT;
}
VertexShader vsArray1_1[ 2 ] = { compile vs_1_1 VS_0WEIGHTS(),
compile vs_1_1 VS_1WEIGHTS()};
//
technique T0
{
pass p0
{
CullMode=CCW;
VertexShader = ( vsArray1_1[ BoneCount ] );
PixelShader = compile ps_1_1 PS();
}
}
technique Fallback
{
pass p0
{
}
}//
// Model Inverse color in one pass.
//
float4 cColor = {1.0f, 1.0f, 1.0f, 1.0f};
texture texture0; // This texture will be loaded by the application
float4x4 worldMatrix;
float4x4 worldMatrix1;
float4x4 worldMatrix2;
float4x4 worldMatrix3;
float4x4 viewProjMatrix;
int BoneCount = 0;
sampler Sampler0 = sampler_state
{
texture = <texture0>;
AddressU = Wrap;
AddressV = Wrap;
MipFilter = Linear;
MinFilter = Linear;
MagFilter = Linear;
};
//-----------------------------------------------------------------------------
// Vertex Definitions
//-----------------------------------------------------------------------------
struct VS_INPUT
{
float3 position : POSITION0;
float BlendWeights : BLENDWEIGHT0;
float3 normal : NORMAL0;
float2 tex0 : TEXCOORD0;
float3 tangent : TANGENT0;
float3 binormal : BINORMAL0;
};
struct VS_OUTPUT
{
float4 position : POSITION;
float2 tex0 : TEXCOORD0;
float4 color : COLOR0;
};
struct PS_OUTPUT
{
float4 color : COLOR;
};
//-----------------------------------------------------------------------------
// Vertex Shader
//-----------------------------------------------------------------------------
VS_OUTPUT VS_0WEIGHTS( VS_INPUT IN )
{
VS_OUTPUT OUT;
//
float4 p0 = mul(worldMatrix, float4(IN.position,1.0));
// Set this is the view projection...
float4 finalPos = mul( viewProjMatrix, p0);
OUT.position = finalPos;
OU*****lor = float4( 1.0, 1.0, 1.0, 1.0 );
OUT.tex0 = IN.tex0;
return OUT;
}
VS_OUTPUT VS_1WEIGHTS( VS_INPUT IN )
{
VS_OUTPUT OUT;
//
float4 p0 = mul(worldMatrix, float4(IN.position,1.0));
float4 p1 = mul(worldMatrix1, float4(IN.position,1.0));
//vBlend = (v1*w1) + (v2 * (1.0 - W1))
float4 vBlend = (p0*IN.BlendWeights) +
(p1 * (1.0 - IN.BlendWeights));
// Set this is the view projection...
float4 blendedPos = vBlend;
float4 finalPos = mul( viewProjMatrix, blendedPos);
OUT.position = finalPos;
OU*****lor = float4( 1.0, 1.0, 1.0, 1.0 );
OUT.tex0 = IN.tex0;
return OUT;
}
//-----------------------------------------------------------------------------
// Pixel Shader
//-----------------------------------------------------------------------------
PS_OUTPUT PS( VS_OUTPUT IN )
{
PS_OUTPUT OUT;
// Sampled texture color
float4 actColor = (tex2D( Sampler0, IN.tex0 ) * IN.color);
OU*****lor = actColor;
// Inverted color
// float4 invColor = cColor - actColor;
// OU*****lor = invColor;
return OUT;
}
VertexShader vsArray1_1[ 2 ] = { compile vs_1_1 VS_0WEIGHTS(),
compile vs_1_1 VS_1WEIGHTS()};
//
technique T0
{
pass p0
{
CullMode=CCW;
VertexShader = ( vsArray1_1[ BoneCount ] );
PixelShader = compile ps_1_1 PS();
}
}
technique Fallback
{
pass p0
{
}
}
//
// Model Inverse color in one pass.
//
float4 cColor = {1.0f, 1.0f, 1.0f, 1.0f};
texture texture0; // This texture will be loaded by the application
float4x4 worldMatrix;
float4x4 worldMatrix1;
float4x4 worldMatrix2;
float4x4 worldMatrix3;
float4x4 viewProjMatrix;
int BoneCount = 0;
sampler Sampler0 = sampler_state
{
texture = <texture0>;
AddressU = Wrap;
AddressV = Wrap;
MipFilter = Linear;
MinFilter = Linear;
MagFilter = Linear;
};
//-----------------------------------------------------------------------------
// Vertex Definitions
//-----------------------------------------------------------------------------
struct VS_INPUT
{
float3 position : POSITION;
float3 BlendWeights : BLENDWEIGHT;
float3 normal : NORMAL;
float2 tex0 : TEXCOORD0;
};
struct VS_OUTPUT
{
float4 position : POSITION;
float2 tex0 : TEXCOORD0;
float4 color : COLOR0;
};
struct PS_OUTPUT
{
float4 color : COLOR;
};
//-----------------------------------------------------------------------------
// Vertex Shader
//-----------------------------------------------------------------------------
VS_OUTPUT VS_0WEIGHTS( VS_INPUT IN )
{
VS_OUTPUT OUT;
//
float4 p0 = mul(worldMatrix, float4(IN.position,1.0));
// Set this is the view projection...
float4 finalPos = mul( viewProjMatrix, p0);
OUT.position = finalPos;
OU*****lor = float4( 1.0, 1.0, 1.0, 1.0 );
OUT.tex0 = IN.tex0;
return OUT;
}
VS_OUTPUT VS_1WEIGHTS( VS_INPUT IN )
{
VS_OUTPUT OUT;
//
float4 p0 = mul(worldMatrix, float4(IN.position,1.0));
float4 p1 = mul(worldMatrix1, float4(IN.position,1.0));
//vBlend = (v1*w1) + (v2 * (1.0 - W1))
float4 vBlend = (p0*IN.BlendWeights.x) +
(p1 * (1.0 - IN.BlendWeights.x));
// Set this is the view projection...
float4 blendedPos = vBlend;
float4 finalPos = mul( viewProjMatrix, blendedPos);
OUT.position = finalPos;
OU*****lor = float4( 1.0, 1.0, 1.0, 1.0 );
OUT.tex0 = IN.tex0;
return OUT;
}
VS_OUTPUT VS_2WEIGHTS( VS_INPUT IN )
{
VS_OUTPUT OUT;
//
float4 p0 = mul(worldMatrix, float4(IN.position,1.0));
float4 p1 = mul(worldMatrix1, float4(IN.position,1.0));
float4 p2 = mul(worldMatrix2, float4(IN.position,1.0));
// vBlend = (v1*w1) + (v2*w2) + (v3 * (1.0 -(w1 + w2)) )
float4 vBlend = (p0*IN.BlendWeights.x) +
(p1*IN.BlendWeights.y) +
(p2 * (1.0 - (IN.BlendWeights.x + IN.BlendWeights.y)));
// Set this is the view projection...
float4 blendedPos = vBlend;
float4 finalPos = mul( viewProjMatrix, blendedPos);
OUT.position = finalPos;
OU*****lor = float4( 1.0, 1.0, 1.0, 1.0 );
OUT.tex0 = IN.tex0;
return OUT;
}
VS_OUTPUT VS_3WEIGHTS( VS_INPUT IN )
{
VS_OUTPUT OUT;
//
float4 p0 = mul(worldMatrix, float4(IN.position,1.0));
float4 p1 = mul(worldMatrix1, float4(IN.position,1.0));
float4 p2 = mul(worldMatrix2, float4(IN.position,1.0));
float4 p3 = mul(worldMatrix3, float4(IN.position,1.0));
//vBlend = (v1*w1) + (v2*W2) + (v3*W3) + (v4*(1.0 - (w1+w2+w3)))
float4 vBlend = (p0*IN.BlendWeights.x) +
(p1*IN.BlendWeights.y) +
(p2*IN.BlendWeights.z) +
(p3 * (1.0 - (IN.BlendWeights.x + IN.BlendWeights.y + IN.BlendWeights.z)));
// Set this is the view projection...
float4 blendedPos = vBlend;
float4 finalPos = mul( viewProjMatrix, blendedPos);
OUT.position = finalPos;
OU*****lor = float4( 1.0, 1.0, 1.0, 1.0 );
OUT.tex0 = IN.tex0;
return OUT;
}
//-----------------------------------------------------------------------------
// Pixel Shader
//-----------------------------------------------------------------------------
PS_OUTPUT PS( VS_OUTPUT IN )
{
PS_OUTPUT OUT;
// Sampled texture color
float4 actColor = (tex2D( Sampler0, IN.tex0 ) * IN.color);
OU*****lor = actColor;
// Inverted color
// float4 invColor = cColor - actColor;
// OU*****lor = invColor;
return OUT;
}
VertexShader vsArray1_1[ 4 ] = { compile vs_1_1 VS_0WEIGHTS(),
compile vs_1_1 VS_1WEIGHTS(),
compile vs_1_1 VS_2WEIGHTS(),
compile vs_1_1 VS_3WEIGHTS()};
//
technique T0
{
pass p0
{
CullMode=CCW;
VertexShader = ( vsArray1_1[ BoneCount ] );
//PixelShader = compile ps_1_1 PS();
}
}
technique Fallback
{
pass p0
{
}
}
//
// Model Inverse color in one pass.
//
#include "..\..\Shared\objecttransforms.fx"
#include "..\..\Shared\vertexblending.fx"
float4 cColor = {1.0f, 1.0f, 1.0f, 1.0f};
int BoneCount = 0;
float tile = 1;
float depth = 0.1;
float3 ambient = {0.2,0.2,0.2};
float3 diffuse = {1,1,1};
float3 specular = {0.75,0.75,0.75};
float shine = 128.0; //128.0;
float3 lightpos = { -150.0, 200.0, -125.0 };
shared float fSaturate = 1.0;
float4x4 modelrotation;
texture texture0;
texture texture1;
sampler2D texmap_sampler = sampler_state
{
Texture = <texture0>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
};
sampler2D reliefmap_sampler = sampler_state
{
Texture = <texture1>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
};
//-----------------------------------------------------------------------------
// Vertex Definitions
//-----------------------------------------------------------------------------
struct VS_INPUT
{
float3 position : POSITION;
float3 BlendWeights : BLENDWEIGHT;
float3 normal : NORMAL;
float2 tex0 : TEXCOORD0;
float3 tangent : TANGENT0;
float3 binormal : BINORMAL0;
};
struct VERTEX_OUT
{
float4 hpos : POSITION;
float4 color : COLOR0;
float2 txcoord : TEXCOORD0;
float3 vpos : TEXCOORD1;
float3 tangent : TEXCOORD2;
float3 binormal : TEXCOORD3;
float3 normal : TEXCOORD4;
float4 lightpos : TEXCOORD5;
};
struct PS_OUTPUT
{
float4 color : COLOR;
};
//-----------------------------------------------------------------------------
// Vertex Shader
//-----------------------------------------------------------------------------
float3x3 GetTangentSpace(float3 vTangent, float3 vBinormal, float3 vNormal)
{
float3x3 mResult;
mResult[0] = vTangent;
mResult[1] = vBinormal;
mResult[2] = vNormal;
return mResult;
}
float4 GetBlendedVert(float3 Position, float3 BlendWeights, int Bones)
{
return Blend3Weights(Position, BlendWeights);
}
VERTEX_OUT VS_WEIGHTS( VS_INPUT IN )
{
VERTEX_OUT OUT;
//vBlend = (v1*w1) + (v2*W2) + (v3*W3) + (v4*(1.0 - (w1+w2+w3)))
float4 vBlend = GetBlendedVert(IN.position, IN.BlendWeights, BoneCount);
// Set this is the view projection...
float4 blendedPos = vBlend;
float4 finalPos = mul( viewProjMatrix, blendedPos);
OUT.hpos = finalPos;
OU*****lor = float4( 1.0, 1.0, 1.0, 1.0 );
OUT.txcoord = IN.tex0;
// compute modelview rotation only part
float3x3 modelviewrot;
modelviewrot[0] = modelview[0].xyz;
modelviewrot[1] = modelview[1].xyz;
modelviewrot[2] = modelview[2].xyz;
// vertex position in view space (with model transformations)
float4 pos = float4(IN.position.x, IN.position.y, IN.position.z, 1.0);
OUT.vpos = mul(modelview, blendedPos).xyz;
// light position in view space
float4 lp = float4(lightpos.x, lightpos.y, lightpos.z, 1);
OUT.lightpos = mul(view, lp);
/*
float3x3 mTangent = GetTangentSpace(Blend3WeightsVector(IN.tangent, IN.BlendWeights),
Blend3WeightsVector(IN.binormal, IN.BlendWeights),
Blend3WeightsVector(IN.normal, IN.BlendWeights));
*/
float3x3 mTangent = GetTangentSpace(IN.tangent, IN.binormal, IN.normal);
//mTangent[0] = mul((float3x3)worldMatrix, mTangent[0]);
//mTangent[1] = mul((float3x3)worldMatrix, mTangent[1]);
//mTangent[2] = mul((float3x3)worldMatrix, mTangent[2]);
//float3x3 mTangent2;
//mTangent2[0] = mul((float3x3)worldMatrix, mTangent[0]);
///mTangent2[1] = mul((float3x3)worldMatrix, mTangent[1]);
///mTangent2[2] = mul((float3x3)worldMatrix, mTangent[2]);
//mTangent2[0] = mul((float3x3)modelrotation, mTangent[0]);
//mTangent2[1] = mul((float3x3)modelrotation, mTangent[1]);
//mTangent2[2] = mul((float3x3)modelrotation, mTangent[2]);
//float3x3 mTangent2 = mul( (float3x3)modelrotation, mTangent);
//mTangent2[0] = mul(mTangent[0], (float3x3)worldMatrix);
//mTangent2[1] = mul(mTangent[1], (float3x3)worldMatrix);
//mTangent2[2] = mul(mTangent[2], (float3x3)worldMatrix);
//float3x3 mTanInv = transpose(mTangent2);
//OUT.tangent = mul(modelviewrot, mTangent2[0]);
//OUT.binormal = mul(modelviewrot, mTangent2[1]);
//OUT.normal = mul(modelviewrot, mTangent2[2]);
//float3x3 mTangentSpace = GetTangentSpace(mul(modelviewrot, mTangent[0]), mul(modelviewrot, mTangent[1]), mul(modelviewrot, mTangent[2]));
//float3x3 mTangent2 = mul( (float3x3)modelrotation, mTangent);
float3x3 mTangent2 = mul(transpose((float3x3)worldMatrix), mTangent);
float3x3 mTangentSpace2 = mul(modelviewrot, mTangent2);
OUT.tangent = mTangentSpace2[0];//mul(modelviewrot, mTangent2[0]);
OUT.binormal = mTangentSpace2[1];//mul(modelviewrot, mTangent2[1]);
OUT.normal = mTangentSpace2[2];//mul(modelviewrot, mTangent2[2]);
// copy color and texture coordinates
OU*****lor = cColor;
OUT.txcoord = IN.tex0.xy;
return OUT;
}
//-----------------------------------------------------------------------------
// Pixel Shader
//-----------------------------------------------------------------------------
float4 parallax_map( VERTEX_OUT IN ) : COLOR
{
// view and light directions
float3 v = normalize(IN.vpos);
float3 l = normalize(IN.lightpos.xyz - IN.vpos);
float2 uv = IN.txcoord * tile;
// parallax code
/*
float3x3 tbn = float3x3(IN.tangent, IN.binormal, IN.normal);
float height = tex2D(reliefmap_sampler, uv).w * 0.06 - 0.03;
uv += height * mul(v, tbn);
*/
// normal map
float4 normal = tex2D(reliefmap_sampler, uv);
normal.xy = normal.xy * 2.0 - 1.0; // trafsform to [-1,1] range
normal.z = sqrt(1.0 - dot(normal.xy, normal.xy)); // compute z component
// transform normal to world space
normal.xyz = normalize(normal.x * IN.tangent - normal.y * IN.binormal + normal.z * IN.normal);
//normal.xyz = normalize(normal.xyz);
// color map
float4 color = tex2D(texmap_sampler, uv);
// compute diffuse and specular terms
float att = saturate(dot(l,IN.normal.xyz));
float diff = saturate(dot(l,normal.xyz));
float spec = saturate(dot(normalize(l-v),normal.xyz));
// compute final color
float4 finalcolor;// = normal;
finalcolor.xyz = (ambient*color.xyz)+att*(color.xyz*diffuse.xyz*dif f+specular.xyz*pow(spec,shine)) * fSaturate;
finalcolor.w = 1.0;
return finalcolor;
//return normal;
}
//
technique T0
{
pass p0
{
//ZEnable=false;
//ZWriteEnable=true;
//AlphaBlendEnable=false;
//AlphaTestEnable=false;
//BlendMode=none;
CullMode=CCW;
//FillMode=wireframe;
VertexShader = compile vs_1_1 VS_WEIGHTS();
PixelShader = compile ps_2_0 parallax_map();
}
}
technique Fallback
{
pass p0
{
}
}
float4x4 worldMatrix;
float4x4 viewProjMatrix;
float4x4 viewMatrix;
texture texture0;
sampler2D BaseMapSampler = sampler_state
{
Texture = <texture0>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
};
struct VERTEX_IN
{
float3 Position : POSITION;
float3 Normal : NORMAL;
float2 TexCoord : TEXCOORD0;
};
struct VERTEX_OUT
{
float4 Position : POSITION;
float4 TexCoord : TEXCOORD0;
float4 Color : COLOR0;
};
//
// Vertex Shader
//
VERTEX_OUT VS(VERTEX_IN IN)
{
VERTEX_OUT OUT;
// Position in screen space.
float4 newPos = mul(worldMatrix, float4(IN.Position,1.0));
newPos = mul( viewProjMatrix, newPos);
OUT.Position = newPos;
// pass texture coordinates for fetching the normal map
OUT.TexCoord = float4(IN.TexCoord,1.0, 1.0);
OU*****lor = float4(IN.Normal, 1.0);
return OUT;
}
technique Skin
{
pass p0
{
CullMode=CCW;
VertexShader = compile vs_1_1 VS();
}
}
technique Fallback
{
pass p0
{
}
}
//
// PolyGrid - Refraction
//
shared float fSaturate = 1.0;
float4x4 worldMatrix;
float4x4 viewProjMatrix;
float4x4 modelviewproj;
float4x4 modelview;
float4x4 view;
float3 eyepos = {0,0,0};
texture texture0;
texture backbuffer;
// Get tex coords from our clip space transformed vertex position
float4 GetScreenTexCoords(float4 vPos)
{
float4 vResult;
vResult.x = ( vPos.x * 0.5 + vPos.w * 0.5 );
vResult.y = ( vPos.w * 0.5 - vPos.y * 0.5 );
vResult.z = vPos.w;
vResult.w = vPos.w;
return vResult;
}
sampler2D normalmap_sampler = sampler_state
{
Texture = <texture0>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
};
sampler2D backbuffer_sampler = sampler_state
{
Texture = <backbuffer>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
};
struct VERTEX_IN
{
float3 Position : POSITION0;
float3 Normal : NORMAL0;
float4 Color : COLOR0;
float3 TexCoord : TEXCOORD0;
float3 Tangent : TANGENT0;
float3 Binormal : BINORMAL0;
};
struct VERTEX_OUT
{
float4 Position : POSITION;
float4 color : COLOR0;
float2 txcoord : TEXCOORD0;
float4 txcoord2 : TEXCOORD1;
float3 normal : TEXCOORD2;
};
VERTEX_OUT view_space(VERTEX_IN IN)
{
VERTEX_OUT OUT;
// Transform this to world space
float4 worldPos = mul(worldMatrix, float4(IN.Position,1.0));
// Transform this to clip space
float4 clipPos = mul( viewProjMatrix, worldPos);
OUT.Position = clipPos;
OUT.normal = IN.Normal;
OU*****lor = IN.Color;
OUT.txcoord = IN.TexCoord;
OUT.txcoord2 = GetScreenTexCoords(clipPos);
return OUT;
}
float4 pixel_shader( VERTEX_OUT IN ) : COLOR
{
//Sample the normal map
float4 normal = tex2D(normalmap_sampler, IN.txcoord) * 2.0 - 1.0;
// Use the poly normal and normal map.
normal.xyz = normalize(IN.normal * normal.xyz);
//Calculate our refraction color
float4 refr = tex2D(backbuffer_sampler, (IN.txcoord2.xy / IN.txcoord2.w) + (0.02 * normal.xy));
// Standard color, Refracted, multiply blend
return (refr) * IN.color * fSaturate;
}
technique Refraction
{
pass p0
{
CullMode = none;
AlphaBlendEnable = false;
VertexShader = compile vs_1_1 view_space();
PixelShader = compile ps_2_0 pixel_shader();
}
}
// If our device does not support PS 2.0, then we need to fall back to a simple multiply blend.
technique MultiplyBlend
{
pass p0
{
CullMode = CCW;
AlphaBlendEnable = true;
SrcBlend=ZERO;
DestBlend=SRCCOLOR;
}
}
float4 diffuse = {1,1,1,1};
float4 c0 = {0.299, 0.587, 0.114, 0};
float4 c1 = {0.191, -0.054, -0.221, 0};
shared float fSaturate = 1.0;
float4x4 worldMatrix;
float4x4 viewProjMatrix;
float4x4 modelviewproj;
float4x4 modelview;
float4x4 view;
float3 eyepos = {0,0,0};
texture texture0;
texture texture1;
texture backbuffer;
// Get tex coords from our clip space transformed vertex position
float4 GetScreenTexCoords(float4 vPos)
{
float4 vResult;
vResult.x = ( vPos.x * 0.5 + vPos.w * 0.5 );
vResult.y = ( vPos.w * 0.5 - vPos.y * 0.5 );
vResult.z = vPos.w;
vResult.w = vPos.w;
return vResult;
}
sampler2D normalmap_sampler = sampler_state
{
Texture = <texture0>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
};
samplerCUBE envmap_sampler = sampler_state
{
Texture = <texture1>;
AddressU=Clamp;
AddressV=Clamp;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
};
sampler2D backbuffer_sampler = sampler_state
{
Texture = <backbuffer>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
};
struct VERTEX_IN
{
float3 Position : POSITION0;
float3 Normal : NORMAL0;
float4 Color : COLOR0;
float3 TexCoord : TEXCOORD0;
float3 Tangent : TANGENT0;
float3 Binormal : BINORMAL0;
};
struct VERTEX_OUT
{
float4 Position : POSITION;
float4 color : COLOR0;
float2 txcoord : TEXCOORD0;
float4 txcoord2 : TEXCOORD1;
//float3 tangent : TEXCOORD3;
//float3 binormal : TEXCOORD4;
float4 Basis0 : TEXCOORD2; //first row of the 3x3 transform from tangent to cube space
float4 Basis1 : TEXCOORD3; //second row of the 3x3 transform from tangent to cube space
float4 Basis2 : TEXCOORD4; //third row of the 3x3 transform from tangent to cube space
};
VERTEX_OUT view_space(VERTEX_IN IN)
{
VERTEX_OUT OUT;
// Transform this to world space
float4 worldPos = mul(worldMatrix, float4(IN.Position,1.0));
// Transform this to clip space
float4 clipPos = mul( viewProjMatrix, worldPos);
OUT.Position = clipPos;
OU*****lor = IN.Color;
OUT.txcoord = IN.TexCoord;
OUT.txcoord2 = GetScreenTexCoords(clipPos);
// Since we don't have real tangent information, let's just use the normal.
//float3 normal = float3(0,1,0);//IN.Normal.xyz;//renormal.xyz;
//float3 tangent = float3(1,0,0);//IN.Tangent.xyz;//IN.Normal.xyz;
//float3 binormal = float3(0,0,1);//IN.Binormal.xyz;//cross(normal,tangent.xyz);
float3 normal = IN.Normal.xyz;//renormal.xyz;
float3 tangent = IN.Tangent.xyz;//IN.Normal.xyz;
float3 binormal = IN.Binormal.xyz;//cross(normal,tangent.xyz);
// compute the 4x4 tranform from tangent space to object space
float3x3 TangentToObjSpace;
// first rows are the tangent and binormal scaled by the bump scale
TangentToObjSpace[0] = float3(tangent.x, binormal.x, normal.x);
TangentToObjSpace[1] = float3(tangent.y, binormal.y, normal.y);
TangentToObjSpace[2] = float3(tangent.z, binormal.z, normal.z);
OUT.Basis0.x = dot(worldMatrix[0].xyz, TangentToObjSpace[0]);
OUT.Basis0.y = dot(worldMatrix[1].xyz, TangentToObjSpace[0]);
OUT.Basis0.z = dot(worldMatrix[2].xyz, TangentToObjSpace[0]);
OUT.Basis1.x = dot(worldMatrix[0].xyz, TangentToObjSpace[1]);
OUT.Basis1.y = dot(worldMatrix[1].xyz, TangentToObjSpace[1]);
OUT.Basis1.z = dot(worldMatrix[2].xyz, TangentToObjSpace[1]);
OUT.Basis2.x = dot(worldMatrix[0].xyz, TangentToObjSpace[2]);
OUT.Basis2.y = dot(worldMatrix[1].xyz, TangentToObjSpace[2]);
OUT.Basis2.z = dot(worldMatrix[2].xyz, TangentToObjSpace[2]);
OUT.Basis0.xyz = tangent;
OUT.Basis1.xyz = binormal;
OUT.Basis2.xyz = normal;
//transpose contains eye position in world space in last row.
float4 eyeVector = worldPos - float4(eyepos, 1.0);
OUT.Basis0.w = eyeVector.x;
OUT.Basis1.w = eyeVector.y;
OUT.Basis2.w = eyeVector.z;
return OUT;
}
float4 pixel_shader( VERTEX_OUT IN ) : COLOR
{
//Sample the normal map
// normal map
float4 normal = tex2D(normalmap_sampler, IN.txcoord);
normal.xy = normal.xy * 2.0 - 1.0; // transform to [-1,1] range
normal.z = sqrt(1.0 - dot(normal.xy, normal.xy)); // compute z component
// transform normal to world space
normal.xyz = normalize(normal.xyz);
//normal.xyz = normalize(normal.x * IN.tangent - normal.y * IN.binormal + normal.z * IN.normal);
float4 refr = tex2D(backbuffer_sampler, (IN.txcoord2.xy / IN.txcoord2.w) + (0.02 * normal.xy));
float3 eyevec = float3(IN.Basis0.w, IN.Basis1.w, IN.Basis2.w);
float3 worldNorm;
worldNorm.x = dot(IN.Basis0.xyz,normal);
worldNorm.y = dot(IN.Basis1.xyz,normal);
worldNorm.z = dot(IN.Basis2.xyz,normal);
float3 envlookup = reflect(eyevec, IN.Basis2.xyz);
float4 env = texCUBE(envmap_sampler, envlookup);
// Diffuse color
//float4 basemap = float4(1,1,1,1);
//float4 basemap = tex2D(basemap_sampler, IN.txcoord);
// Standard color, Refracted, multiply blend
return (refr) * (env) * IN.color * fSaturate;
//return (env) * IN.color * fSaturate;
}
technique Refraction
{
pass p0
{
// fillmode=wireframe;
CullMode = CCW;
AlphaBlendEnable = false;
VertexShader = compile vs_1_1 view_space();
PixelShader = compile ps_2_0 pixel_shader();
}
}
// If our device does not support PS 2.0, then we need to fall back to a simple multiply blend.
technique MultiplyBlend
{
pass p0
{
CullMode = CCW;
AlphaBlendEnable = true;
SrcBlend=ZERO;
DestBlend=SRCCOLOR;
}
}
float4x4 worldMatrix;
float4x4 worldMatrix1;
float4x4 worldMatrix2;
float4x4 worldMatrix3;
float4x4 viewProjMatrix;
float4x4 invViewMatrix;
float4x4 modelviewproj;
float4x4 modelview;
float4x4 view;
float4 Blend0Weights(float3 Position, float3 BlendWeights)
{
float4 p0 = mul(worldMatrix, float4(Position,1.0));
return p0;
}
float4 Blend1Weights(float3 Position, float3 BlendWeights)
{
//
float4 p0 = mul(worldMatrix, float4(Position,1.0));
float4 p1 = mul(worldMatrix1, float4(Position,1.0));
//vBlend = (v1*w1) + (v2 * (1.0 - W1))
float4 vBlend = (p0*BlendWeights.x) +
(p1 * (1.0 - BlendWeights.x));
return vBlend;
}
float4 Blend2Weights(float3 Position, float3 BlendWeights)
{
float4 p0 = mul(worldMatrix, float4(Position,1.0));
float4 p1 = mul(worldMatrix1, float4(Position,1.0));
float4 p2 = mul(worldMatrix2, float4(Position,1.0));
// vBlend = (v1*w1) + (v2*w2) + (v3 * (1.0 -(w1 + w2)) )
float4 vBlend = (p0*BlendWeights.x) +
(p1*BlendWeights.y) +
(p2 * (1.0 - (BlendWeights.x + BlendWeights.y)));
return vBlend;
}
float4 Blend3Weights(float3 Position, float3 BlendWeights)
{
float4 p0 = mul(worldMatrix, float4(Position,1.0));
float4 p1 = mul(worldMatrix1, float4(Position,1.0));
float4 p2 = mul(worldMatrix2, float4(Position,1.0));
float4 p3 = mul(worldMatrix3, float4(Position,1.0));
//vBlend = (v1*w1) + (v2*W2) + (v3*W3) + (v4*(1.0 - (w1+w2+w3)))
float4 vBlend = (p0*BlendWeights.x) +
(p1*BlendWeights.y) +
(p2*BlendWeights.z) +
(p3 * (1.0 - (BlendWeights.x + BlendWeights.y + BlendWeights.z)));
return vBlend;
}
float3 Blend3WeightsVector(float3 Vector, float3 BlendWeights)
{
float3 v0 = mul((float3x3)worldMatrix, Vector);
float3 v1 = mul((float3x3)worldMatrix1, Vector);
float3 v2 = mul((float3x3)worldMatrix2, Vector);
float3 v3 = mul((float3x3)worldMatrix3, Vector);
//vBlend = (v1*w1) + (v2*W2) + (v3*W3) + (v4*(1.0 - (w1+w2+w3)))
float3 vBlend = (v0*BlendWeights.x) +
(v1*BlendWeights.y) +
(v2*BlendWeights.z) +
(v3 * (1.0 - (BlendWeights.x + BlendWeights.y + BlendWeights.z)));
return vBlend;
}
float4 diffuse = {1,1,1,1};
float4 c0 = {0.299, 0.587, 0.114, 0};
float4 c1 = {0.191, -0.054, -0.221, 0};
shared float fSaturate = 1.0;
float4x4 worldMatrix;
float4x4 viewProjMatrix;
float4x4 modelviewproj;
float4x4 modelview;
float4x4 view;
float4 eyepos;
texture texture0;
texture texture1;
texture backbuffer;
texture rendertarget;
// Get tex coords from our clip space transformed vertex position
float4 GetScreenTexCoords(float4 vPos)
{
float4 vResult;
vResult.x = ( vPos.x * 0.5 + vPos.w * 0.5 );
vResult.y = ( vPos.w * 0.5 - vPos.y * 0.5 );
vResult.z = vPos.w;
vResult.w = vPos.w;
return vResult;
}
sampler2D normalmap_sampler = sampler_state
{
Texture = <texture0>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
};
sampler2D backbuffer_sampler = sampler_state
{
Texture = <backbuffer>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
};
struct VERTEX_IN
{
float3 Position : POSITION0;
float4 Color : COLOR0;
float3 TexCoord : TEXCOORD0;
};
struct VERTEX_OUT
{
float4 Position : POSITION;
float4 color : COLOR0;
float2 txcoord : TEXCOORD0;
float4 txcoord2 : TEXCOORD1;
};
VERTEX_OUT view_space(VERTEX_IN IN)
{
VERTEX_OUT OUT;
// Transform this to world space
float4 newPos = mul(worldMatrix, float4(IN.Position,1.0));
// Transform this to clip space
newPos = mul( viewProjMatrix, newPos);
OUT.Position = newPos;
OU*****lor = IN.Color;
OUT.txcoord = IN.TexCoord;
OUT.txcoord2 = GetScreenTexCoords(newPos);
return OUT;
}
float4 pixel_shader( VERTEX_OUT IN ) : COLOR
{
//Sample the normal map
float4 normal = tex2D(normalmap_sampler, IN.txcoord);
normal.xy = normal.xy * 2.0 - 1.0; // transform to [-1,1] range
normal.z = sqrt(1.0 - dot(normal.xy, normal.xy)); // compute z component
// normalize
normal.xyz = normalize(normal.xyz);
// Factor the alpha color into the normal. (allow for refraction fade out as alpha reaches zero)
// As alpha fades to zero, normal fades to vector (0,0,1).
normal = (normal * IN.color.a) + (float4(0.0,0.0,1.0,0.0) * (1.0-IN.color.a));
float4 refr = tex2D(backbuffer_sampler, (IN.txcoord2.xy / IN.txcoord2.w) + (0.02 * normal.xy));
// Standard color, Refracted, multiply blend
return (refr * IN.color * fSaturate);
}
technique Refraction
{
pass p0
{
CullMode = CCW;
AlphaBlendEnable = false;
VertexShader = compile vs_1_1 view_space();
PixelShader = compile ps_2_0 pixel_shader();
}
}
// If our device does not support PS 2.0, then we need to fall back to a simple multiply blend.
technique MultiplyBlend
{
pass p0
{
CullMode = CCW;
AlphaBlendEnable = true;
SrcBlend=ZERO;
DestBlend=SRCCOLOR;
}
}
float4x4 worldMatrix;
float4x4 wvpMatrix;
float4x4 worldViewMatrix;
float4x4 worldViewMatrixI;
float4x4 viewMatrix;
float4x4 viewInverseMatrix;
float4x4 viewProjMatrix;
float4 eye_position;
float bu***eight = 0.5;
float saturate = 1.0;
texture texture0;
texture texture1;// : NORMAL;
texture texture2;// : ENVIRONMENT;
sampler2D BaseMapSampler = sampler_state
{
Texture = <texture0>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
};
sampler2D normalMapSampler = sampler_state
{
Texture = <texture1>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
};
samplerCUBE envMapSampler = sampler_state
{
Texture = <texture2>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
};
struct VERTEX_IN
{
float3 Position : POSITION0;
float3 Normal : NORMAL0;
float3 Tangent : TANGENT0;
float3 Binormal : BINORMAL0;
float4 Color : COLOR0;
float3 TexCoord : TEXCOORD0;
};
struct VERTEX_OUT
{
float4 Position : POSITION;
float4 TexCoord : TEXCOORD0;
float4 TexCoord1 : TEXCOORD1; //first row of the 3x3 transform from tangent to cube space
float4 TexCoord2 : TEXCOORD2; //second row of the 3x3 transform from tangent to cube space
float4 TexCoord3 : TEXCOORD3; //third row of the 3x3 transform from tangent to cube space
float4 TexCoord4 : TEXCOORD4; //third row of the 3x3 transform from tangent to cube space
float4 Color : COLOR0;
//float4 TexCoord4 : COLOR1;
//float4 Binormal : BINORMAL;
};
//
// Vertex Shader
//
VERTEX_OUT BumpReflectVS(VERTEX_IN IN,
uniform float4x4 WorldViewProj,
uniform float4x4 World,
uniform float4x4 ViewIT)
{
VERTEX_OUT OUT;
// Position in screen space.
//OUT.Position = mul(wvpMatrix, IN.Position);
float4 newPos = mul(worldMatrix, float4(IN.Position,1.0));
newPos = mul( viewProjMatrix, newPos);
OUT.Position = newPos;
// pass texture coordinates for fetching the normal map
OUT.TexCoord = float4(IN.TexCoord, 1.0);
OU*****lor = IN.Color;
//float4 renormal = mul(worldMatrix, IN.Normal);
//renormal = normalize(renormal);
// Since we don't have real tangent information, let's just use the normal.
float3 normal = IN.Normal.xyz;//renormal.xyz;
float3 tangent = IN.Tangent.xyz;//IN.Normal.xyz;
float3 binormal = IN.Binormal.xyz;//cross(normal,tangent.xyz);
// compute the 4x4 tranform from tangent space to object space
float3x3 TangentToObjSpace;
// first rows are the tangent and binormal scaled by the bump scale
TangentToObjSpace[0] = float3(tangent.x, binormal.x, normal.x);
TangentToObjSpace[1] = float3(tangent.y, binormal.y, normal.y);
TangentToObjSpace[2] = float3(tangent.z, binormal.z, normal.z);
OUT.TexCoord1.x = dot(World[0].xyz, TangentToObjSpace[0]);
OUT.TexCoord1.y = dot(World[1].xyz, TangentToObjSpace[0]);
OUT.TexCoord1.z = dot(World[2].xyz, TangentToObjSpace[0]);
OUT.TexCoord2.x = dot(World[0].xyz, TangentToObjSpace[1]);
OUT.TexCoord2.y = dot(World[1].xyz, TangentToObjSpace[1]);
OUT.TexCoord2.z = dot(World[2].xyz, TangentToObjSpace[1]);
OUT.TexCoord3.x = dot(World[0].xyz, TangentToObjSpace[2]);
OUT.TexCoord3.y = dot(World[1].xyz, TangentToObjSpace[2]);
OUT.TexCoord3.z = dot(World[2].xyz, TangentToObjSpace[2]);
float4 worldPos = mul(World, IN.Position);
//transpose contains eye position in world space in last row.
float4 eyeVector = worldPos - eye_position;
OUT.TexCoord1.w = eyeVector.x;
OUT.TexCoord2.w = eyeVector.y;
OUT.TexCoord3.w = eyeVector.z;
OUT.TexCoord4 = float4(IN.Normal, 1.0);
return OUT;
}
//
// Pixel Shader
//
float4 BumpReflectPS(VERTEX_OUT IN,
uniform sampler2D NormalMap,
uniform samplerCUBE EnvironmentMap,
uniform float BumpScale) : COLOR
{
// fetch the bump normal from the normal map
float3 baseColor = tex2D(BaseMapSampler, IN.TexCoord);
float3 normal = tex2D(NormalMap, IN.TexCoord.xy).xyz * 2.0 - 1.0;
normal = normalize(float3(normal.x * BumpScale, normal.y * BumpScale, normal.z));
// transform the bump normal into cube space
// then use the transformed normal and eye vector to compute a reflection vector
// used to fetch the cube map
// (we multiply by 2 only to increase brightness)
float3 eyevec = float3(IN.TexCoord1.w, IN.TexCoord2.w, IN.TexCoord3.w);
float3 worldNorm;
worldNorm.x = dot(IN.TexCoord1.xyz,normal);
worldNorm.y = dot(IN.TexCoord2.xyz,normal);
worldNorm.z = dot(IN.TexCoord3.xyz,normal);
float3 lookup = reflect(eyevec, worldNorm);
// Do the Bump Reflect and blend the vertex colors (use baked in world lighting)
return float4(baseColor, 1.0) * texCUBE(EnvironmentMap, lookup) * (IN.Color*(saturate*2.0));
//Just return the normal
//return normalize(IN.TexCoord4);
}
technique BumpReflect
{
pass p0
{
VertexShader = compile vs_1_1 BumpReflectVS(wvpMatrix,worldMatrix,viewInverseMat rix);
PixelShader = compile ps_2_0 BumpReflectPS(normalMapSampler,envMapSampler,bu*** eight);
}
}
technique Fallback
{
pass p0
{
}
}
float tile = 1;
float depth = 0.1;
float3 ambient = {0.2,0.2,0.2};
float3 diffuse = {1,1,1};
float3 specular = {0.75,0.75,0.75};
float shine = 128.0;
float3 lightpos = { -150.0, 200.0, -125.0 };
shared float fSaturate = 1.0;
float4x4 worldMatrix;
float4x4 viewProjMatrix;
float4x4 modelviewproj;
float4x4 modelview;
float4x4 view;
texture texture0;
texture texture1;
sampler2D texmap_sampler = sampler_state
{
Texture = <texture0>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
};
sampler2D reliefmap_sampler = sampler_state
{
Texture = <texture1>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
};
struct VERTEX_IN
{
float3 Position : POSITION0;
float3 Normal : NORMAL0;
float3 Tangent : TANGENT0;
float3 Binormal : BINORMAL0;
float4 Color : COLOR0;
float3 TexCoord : TEXCOORD0;
};
struct VERTEX_OUT
{
float4 hpos : POSITION;
float4 color : COLOR0;
float2 txcoord : TEXCOORD0;
float3 vpos : TEXCOORD1;
float3 tangent : TEXCOORD2;
float3 binormal : TEXCOORD3;
float3 normal : TEXCOORD4;
float4 lightpos : TEXCOORD5;
float depth : TEXCOORD6;
};
VERTEX_OUT view_space(VERTEX_IN IN)
{
VERTEX_OUT OUT;
// vertex position in object space
float4 pos = float4(IN.Position.x, IN.Position.y, IN.Position.z, 1.0);
// compute modelview rotation only part
float3x3 modelviewrot;
modelviewrot[0] = modelview[0].xyz;
modelviewrot[1] = modelview[1].xyz;
modelviewrot[2] = modelview[2].xyz;
float4 newPos = mul(worldMatrix, float4(IN.Position,1.0));
newPos = mul( viewProjMatrix, newPos);
OUT.hpos = newPos;
OUT.depth = newPos.z;
// vertex position in view space (with model transformations)
OUT.vpos = mul(modelview, pos).xyz;
// light position in view space
float4 lp = float4(lightpos.x, lightpos.y, lightpos.z, 1);
OUT.lightpos = mul(view, lp);
// tangent space vectors in view space (with model transformations)
OUT.tangent = mul(modelviewrot, IN.Tangent.xyz);
OUT.binormal = mul(modelviewrot, IN.Binormal.xyz);
OUT.normal = mul(modelviewrot, IN.Normal.xyz);
// copy color and texture coordinates
OU*****lor = IN.Color;
OUT.txcoord = IN.TexCoord.xy;
return OUT;
}
float4 parallax_map( VERTEX_OUT IN ) : COLOR
{
// view and light directions
float3 v = normalize(IN.vpos);
float3 l = normalize(IN.lightpos.xyz - IN.vpos);
float2 uv = IN.txcoord * tile;
// parallax code
float3x3 tbn = float3x3(IN.tangent, IN.binormal, IN.normal);
float height = tex2D(reliefmap_sampler, uv).w * 0.06 - 0.03;
uv += height * mul(v, tbn);
// normal map
float4 normal = tex2D(reliefmap_sampler, uv);
normal.xy = normal.xy * 2.0 - 1.0; // trafsform to [-1,1] range
normal.z = sqrt(1.0 - dot(normal.xy, normal.xy)); // compute z component
// transform normal to world space
normal.xyz = normalize(normal.x * IN.tangent - normal.y * IN.binormal + normal.z * IN.normal);
// color map
float4 color = tex2D(texmap_sampler, uv);
// compute diffuse and specular terms
float att = saturate(dot(l,IN.normal.xyz));
float diff = saturate(dot(l,normal.xyz));
float spec = saturate(dot(normalize(l-v),normal.xyz));
//test for depath
//float4 fDepth = normalize(float4(255, 255, IN.depth, 1.0));
//fDepth.x = 0;
//fDepth.y = 0;
// compute final color
float4 finalcolor;// = fDepth;// = normal; //This is a test.. just output the normal for now
finalcolor.xyz = (ambient*color.xyz)+att*(color.xyz*diffuse.xyz*dif f+specular.xyz*pow(spec,shine)) * fSaturate;
finalcolor.w = 1.0;
return finalcolor;
}
technique parallax_mapping
{
pass p0
{
CullMode = CCW;
VertexShader = compile vs_1_1 view_space();
PixelShader = compile ps_2_0 parallax_map();
}
}
technique Fallback
{
pass p0
{
}
}
float4 diffuse = {1,1,1,1};
float4 c0 = {0.299, 0.587, 0.114, 0};
float4 c1 = {0.191, -0.054, -0.221, 0};
shared float fSaturate = 1.0;
float4x4 worldMatrix;
float4x4 viewProjMatrix;
float4x4 modelviewproj;
float4x4 modelview;
float4x4 view;
texture texture0;
texture texture1;
texture backbuffer;
// Get tex coords from our clip space transformed vertex position
float4 GetScreenTexCoords(float4 vPos)
{
float4 vResult;
vResult.x = ( vPos.x * 0.5 + vPos.w * 0.5 );
vResult.y = ( vPos.w * 0.5 - vPos.y * 0.5 );
vResult.z = vPos.w;
vResult.w = vPos.w;
return vResult;
}
sampler2D basemap_sampler = sampler_state
{
Texture = <texture0>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
};
sampler2D normalmap_sampler = sampler_state
{
Texture = <texture1>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
};
sampler2D backbuffer_sampler = sampler_state
{
Texture = <backbuffer>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
};
struct VERTEX_IN
{
float3 Position : POSITION0;
float3 Normal : NORMAL0;
float3 Tangent : TANGENT0;
float3 Binormal : BINORMAL0;
float4 Color : COLOR0;
float3 TexCoord : TEXCOORD0;
};
struct VERTEX_OUT
{
float4 Position : POSITION;
float4 color : COLOR0;
float2 txcoord : TEXCOORD0;
float4 txcoord2 : TEXCOORD1;
//float3 normal : TEXCOORD2;
//float3 tangent : TEXCOORD3;
//float3 binormal : TEXCOORD4;
};
VERTEX_OUT view_space(VERTEX_IN IN)
{
VERTEX_OUT OUT;
// Transform this to world space
float4 newPos = mul(worldMatrix, float4(IN.Position,1.0));
// Transform this to clip space
newPos = mul( viewProjMatrix, newPos);
OUT.Position = newPos;
OU*****lor = IN.Color;
OUT.txcoord = IN.TexCoord;
OUT.txcoord2 = GetScreenTexCoords(newPos);
//OUT.normal = IN.Normal;
//OUT.tangent = IN.Tangent;
//OUT.binormal = IN.Binormal;
return OUT;
}
float4 pixel_shader( VERTEX_OUT IN ) : COLOR
{
//Sample the normal map
// normal map
float4 normal = tex2D(normalmap_sampler, IN.txcoord);
normal.xy = normal.xy * 2.0 - 1.0; // transform to [-1,1] range
normal.z = sqrt(1.0 - dot(normal.xy, normal.xy)); // compute z component
// transform normal to world space
normal.xyz = normalize(normal.xyz);
//normal.xyz = normalize(normal.x * IN.tangent - normal.y * IN.binormal + normal.z * IN.normal);
float4 refr = tex2D(backbuffer_sampler, (IN.txcoord2.xy / IN.txcoord2.w) + (0.02 * normal.xy));
// Diffuse color
//float4 basemap = float4(1,1,1,1);
float4 basemap = tex2D(basemap_sampler, IN.txcoord);
// Standard color, Refracted, multiply blend
return (refr * basemap) * fSaturate;
}
technique Refraction
{
pass p0
{
CullMode = CCW;
AlphaBlendEnable = false;
VertexShader = compile vs_1_1 view_space();
PixelShader = compile ps_2_0 pixel_shader();
}
}
// If our device does not support PS 2.0, then we need to fall back to a simple multiply blend.
technique MultiplyBlend
{
pass p0
{
CullMode = CCW;
AlphaBlendEnable = true;
SrcBlend=ZERO;
DestBlend=SRCCOLOR;
}
}
Last edited by kerov; 07-08-2010 at 11:51 PM.