home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
GameStar 2005 May
/
Gamestar_73_2005-05_dvd.iso
/
Programy
/
ATITool_0.0.23.exe
/
ATITool.exe
/
1031
/
RCDATA
/
152
< prev
next >
Wrap
Text File
|
2005-01-10
|
7KB
|
255 lines
#ifndef MAX_NUM_LIGHTS
#define MAX_NUM_LIGHTS 4
#endif
float Time : TIME;
float4x4 g_mWorldView;
float4x4 g_mProj;
texture g_txRoom;
float4 g_vLightIntensity = { 66.0f, 66.0f, 66.0f, 1.0f };
float4 g_vLightPosView[MAX_NUM_LIGHTS]; // Light positions in view space
sampler2D g_samRoom =
sampler_state
{
Texture = <g_txRoom>;
MinFilter = Point;
MagFilter = Linear;
MipFilter = Linear;
};
//---------------------------------------------------------------------------------
//Static constants
//---------------------------------------------------------------------------------
float4 Color_ID7 = {1.01, 0.21, 0.13, 1}; //no comments
float4 Vector_ID8 = {0.01, 0.01, 0.01, 1}; //no comments
const float4 Vertex_Normal_ID9 = {0, 0, 0, 1}; //no comments
float Frequency_ID9 = 3.5; //no comments
float NoiseScale_ID9 = 0.9; //no comments
float RingSharpness_ID9 = 15.4; //no comments
float4 DarkColor_ID9 = {0.44, 0.21, 0, 1}; //no comments
float4 LiteColor_ID9 = {0.92, 0.5, 0.13, 1}; //no comments
float Scale_ID12 = 0.3; //no comments
//---------------------------------------------------------------------------------
//Textures
//---------------------------------------------------------------------------------
texture Texture_ID13 : register(t0);
//---------------------------------------------------------------------------------
//Sampler states
//---------------------------------------------------------------------------------
sampler SAMPLER_Sampler_FID14 : register(s0) = sampler_state
{
texture = <Texture_ID13>;
};
//---------------------------------------------------------------------------------
//Sampler functions
//---------------------------------------------------------------------------------
float4 Sampler_FID14(float4 TexCoords)
{
return tex3D(SAMPLER_Sampler_FID14, TexCoords);
}
//---------------------------------------------------------------------------------
//Functions
//---------------------------------------------------------------------------------
//Function (Block FID9)
float4 Wood_FID9(float4 Noise, float4 Vertex_Position, float4 Vertex_Normal, float Frequency, float NoiseScale, float RingSharpness, float4 DarkColor, float4 LiteColor, float4 Grain_Direction)
{
// Signed noise
float snoise = 2 * Noise - 1;
//Direction = float4(1, 0.5, 0, 0);
float3 Dir = normalize(Grain_Direction.xyz);
float r = frac(Frequency * (Vertex_Position.x*Dir.x+Vertex_Position.y*Dir.y + Vertex_Position.z*Dir.z)/2 + NoiseScale * snoise);
float invMax = pow(RingSharpness , RingSharpness / (RingSharpness - 1)) / (RingSharpness - 1);
float ring = invMax * (r - pow(r, RingSharpness ));
float3 Base = lerp(DarkColor.xyz, LiteColor.xyz, ring + snoise);
return abs(float4(Base, 1.0));
}
//Function (Block FID10)
float4 Reflection_FID10(float4 Vertex_Position, float4 Vertex_Normal)
{
float3 E = normalize(Vertex_Position.xyz);
float3 Normal = normalize(Vertex_Normal.xyz);
float3 R = normalize(E - 2 * dot(E, Normal ) * Normal );
return float4(R, 1.0);
}
//Function (Block FID11)
float4 SpecularIntensityGloss_FID11(float4 Wood, float4 Gloss, float4 Diffuse)
{
float Ks = pow((Wood.r+Wood.g+Wood.b)/3, 2) * 4;//-0.2;
float4 Color = float4(Wood.xyz + pow(Gloss.xyz, 2)/3, 1.0);
Color = Color*Diffuse;//*2*Ks;
return abs(Color);
}
//Function (Block FID12)
float4 Vector_Scale_FID12(float4 Vector, float Scale)
{
return Scale * Vector;
}
//-----------------------------------------------------------------------------
// Vertex Shader: HDRVertRoom
// Desc: Process vertex for HDR-enabled Room
//-----------------------------------------------------------------------------
void HDRVertRoom( float4 iPos : POSITION,
float3 iNormal : NORMAL,
float2 iTex : TEXCOORD0,
out float4 oPos : POSITION,
out float2 Tex : TEXCOORD0,
out float3 Pos : TEXCOORD1,
out float3 Normal : TEXCOORD2,
out float4 tc3 : TEXCOORD3 )
{
//
// Transform position to view space
//
oPos = mul( iPos, g_mWorldView );
//
// Also write view position to texcoord1 to do per-pixel lighting
//
Pos = oPos;
//
// Transform to screen coord
//
oPos = mul( oPos, g_mProj );
//
// Transform normal and write to texcoord2 for per-pixel lighting
//
Normal = normalize( mul( iNormal, (float3x3)g_mWorldView ) );
//
// Propagate texture coord
//
Tex = iTex;
tc3=iPos;
}
texture Texture_ID15 : register(t1);
sampler SAMPLER_Sampler_FID16 : register(s1) = sampler_state
{
texture = <Texture_ID15>;
};
float4 Sampler_FID16(float4 TexCoords)
{
return tex2D(SAMPLER_Sampler_FID16, TexCoords);
}
//---------------------------------------------------------------------------------
//Shader entry
//---------------------------------------------------------------------------------
float4 HDRPixRoom( float2 TC0_Vertex_Position : TEXCOORD0,
float4 TC1_Vertex_Position : TEXCOORD3):COLOR
{
float4 Out = (float4)0;
//Block level
float4 Vector_ID12 = TC1_Vertex_Position;
float4 Result_ID12 = Vector_Scale_FID12(Vector_ID12, Scale_ID12);
//Block level
float4 TexCoords_ID14 = Result_ID12;
float4 Vertex_Position_ID10 = Result_ID12;
float4 Pixel_ID14 = Sampler_FID14(Result_ID12);
Pixel_ID14 = tex2D( g_samRoom, TC1_Vertex_Position );
//Block level
float4 Noise_ID9 = Pixel_ID14;
float4 Vertex_Position_ID9 = TC1_Vertex_Position;
float4 Grain_Direction_ID9 = Pixel_ID14;
float4 Output_ID9 = Wood_FID9(Noise_ID9, Vertex_Position_ID9, Vertex_Normal_ID9, Frequency_ID9, NoiseScale_ID9, RingSharpness_ID9, DarkColor_ID9, LiteColor_ID9, Grain_Direction_ID9);
float4 UVW_ID10 = Reflection_FID10(Vertex_Position_ID10, Vector_ID8);
//Block level
float4 Wood = Output_ID9;
float4 Gloss = Color_ID7;
float4 Diffuse = UVW_ID10;
float4 Output_ID11 = SpecularIntensityGloss_FID11(Wood, Gloss, Diffuse);
Out = Output_ID11;
float2 tc = TC1_Vertex_Position * 0.01;
Out=Out+tex2D( g_samRoom, tc );
return Out;
}
//-----------------------------------------------------------------------------
// Technique: RenderRoom
// Desc: Renders Room objects
//-----------------------------------------------------------------------------
// sampler
sampler WrappedLinear =
sampler_state
{
Texture = NULL;
AddressU = WRAP;
AddressV = WRAP;
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
};
technique RenderRoom
{
pass p0
{
// render states
CullMode = CCW;
Sampler[0] = (WrappedLinear);
VertexShader = compile vs_1_1 HDRVertRoom();
PixelShader = compile ps_2_0 HDRPixRoom();
}
}