home *** CD-ROM | disk | FTP | other *** search
- ////////////////////////////////////////////////////////////////////////////
- //
- // Crytek Engine Source File.
- // Vertex Program
- // Copyright (C), Crytek Studios, 2001-2004.
- // -------------------------------------------------------------------------
- // File name: CGVPMacro.csi
- // Version: v1.00
- // Created: 11/2/2004 by Andrey Honich.
- // Compilers: CG/HLSL
- // Description: Vertex/pixel shaders common macroses
- // -------------------------------------------------------------------------
- // History:
- //
- ////////////////////////////////////////////////////////////////////////////
-
- #define _ATI_DEMO 1
-
- //============================================================================
- // Vert. Attributes macro:
-
- #define POSITION_3 VertArray (Verts 3 FLOAT Vertex)
- #define NORMAL_3 VertArray (Normal FLOAT Normals)
- #define TNORMAL_3 VertArray (Normal FLOAT TNormals)
- #define TANGENT_3 VertArray (Texture2 3 FLOAT Tangent)
- #define BINORMAL_3 VertArray (Texture3 3 FLOAT Binormal)
- #define TEXCOORD0_2 VertArray (Texture0 2 FLOAT Texture0)
- #define PRIM_COLOR VertArray (Color 4 BYTE Color)
- #define SEC_COLOR VertArray (SecColor 4 BYTE SecColor)
- #define TEXCOORD1_2 VertArray (Texture1 2 FLOAT Texture1)
- #define TANG_3X3 VertArray (Texture2 3 FLOAT Tangent) VertArray (Texture3 3 FLOAT Binormal) VertArray (Normal FLOAT TNormal)
-
-
- //============================================================================
- // Constants
-
- // Vertex shader parameters
- #define VIEWPROJ_MATRIX uniform float4x4 ModelViewProj : register(c0)
- #define PROJ_MATRIX uniform float4x4 ProjMatrix : register(c0)
- #define LIGHT_POS uniform float4 LightPos : register(c4)
- #define CAMERA_POS uniform float4 CameraPos : register(c5)
- #define ATTEN uniform float4 AttenInfo : register(c6)
- #define BEND uniform float4 Bend : register(c7)
- #define TEX_MATRIX2x4 uniform float2x4 TexMatrix : register(c8)
- #define LIGHT_MATRIX uniform float4x4 LightMatrix : register(c10)
- #define CLIPPLANE uniform float4 ClipPlane : register(c14)
-
- // Pixel shader parameters
- #define AMBIENT uniform float4 Ambient : register(c0)
- #define DIFFUSE uniform float4 Diffuse : register(c1)
- #define SPECULAR uniform float4 Specular : register(c2)
-
- #define GLOBALFOGCOLOR uniform float4 GlobalFogColor : register(c7)
-
- #ifdef RADEON
- #define FLOAT float
- #define FLOAT2 float2
- #define FLOAT3 float3
- #define FLOAT4 float4
- #endif
- #ifdef OTHER
- #define FLOAT half
- #define FLOAT2 half2
- #define FLOAT3 half3
- #define FLOAT4 half4
- #endif
-
- #define HDR_OVERBRIGHT 8
- #define HDR_EXP_OFFSET 64
- #define HDR_EXP_BASE 1.04
- #define HDRFAKE_MAXOVERBRIGHT 16
-
- SubrScript 'CommonSubroutines'
-
- //============================================================================
- // Declarations macro:
-
- //============================================================================
- // Vertex shader input
- #ifdef D3D
- #define IN_TNORMVEC float3 TNormal : BLENDWEIGHT;
- #endif
-
- #ifdef OPENGL
- #define IN_TNORMVEC float3 TNormal : NORMAL;
- #endif
-
- #define IN_TANGVECS \
- float3 Tangent : TEXCOORD2; \
- float3 Binormal : TEXCOORD3; \
- IN_TNORMVEC \
-
- #define IN_P float4 Position : POSITION;
- #define IN_N float3 Normal : NORMAL;
- #ifdef D3D
- #define IN_TN float3 TNormal : BLENDWEIGHT;
- #endif
- #ifdef OPENGL
- #define IN_TN float3 TNormal : NORMAL;
- #endif
- #define IN_C0 float4 Color : COLOR0;
- #define IN_C1 float4 Color1 : COLOR1;
- #define IN_T0 float4 TexCoord0 : TEXCOORD0;
- #define IN_T1 float4 TexCoord1 : TEXCOORD1;
- #define IN_T2 float4 TexCoord2 : TEXCOORD2;
- #define IN_T3 float4 TexCoord3 : TEXCOORD3;
- #define IN_T4 float4 TexCoord4 : TEXCOORD4;
- #define IN_T5 float4 TexCoord5 : TEXCOORD5;
- #define IN_T6 float4 TexCoord6 : TEXCOORD6;
- #define IN_T7 float4 TexCoord7 : TEXCOORD7;
- #define IN_T8 float4 TexCoord8 : TEXCOORD8;
- #define IN_TANG \
- float3 Tangent : TEXCOORD2; \
- float3 Binormal : TEXCOORD3; \
- IN_TNORMVEC \
-
- //============================================================================
- // Vertex shader output
- #define OUT_P float4 HPosition : POSITION;
- #define OUT_C0 float4 Color : COLOR0;
- #define OUT_C0 float4 Color : COLOR0;
- #define OUT_C1 float4 Color1 : COLOR1;
- #define OUT_T0 float4 Tex0 : TEXCOORD0;
- #define OUT_T0_2 float2 Tex0 : TEXCOORD0;
- #define OUT_T1 float4 Tex1 : TEXCOORD1;
- #define OUT_T1_2 float2 Tex1 : TEXCOORD1;
- #define OUT_T2 float4 Tex2 : TEXCOORD2;
- #define OUT_T2_2 float2 Tex2 : TEXCOORD2;
- #define OUT_T3 float4 Tex3 : TEXCOORD3;
- #define OUT_T3_2 float2 Tex3 : TEXCOORD3;
- #define OUT_T4 float4 Tex4 : TEXCOORD4;
- #define OUT_T4_2 float2 Tex4 : TEXCOORD4;
- #define OUT_T5 float4 Tex5 : TEXCOORD5;
- #define OUT_T5_2 float2 Tex5 : TEXCOORD5;
- #define OUT_T6 float4 Tex6 : TEXCOORD6;
- #define OUT_T6_2 float2 Tex6 : TEXCOORD6;
- #define OUT_T7 float4 Tex7 : TEXCOORD7;
- #define OUT_T7_2 float2 Tex7 : TEXCOORD7;
-
- //============================================================================
- // Pixel shader output
- #define FOUT \
- # define _PIX_OUT \
- struct pixout \
- { \
- float4 Color : COLOR; \
- }; \
-
- #define FOUT_DEPTH \
- # define _PIX_OUT \
- # define _DEPTH_OUT \
- struct pixout \
- { \
- float4 Color : COLOR; \
- float Depth : DEPTH; \
- }; \
-
- #define FOUT_2 \
- # define _MRT \
- # define _PIX_OUT \
- struct pixout \
- { \
- float4 Color0 : COLOR0; \
- float4 Color1 : COLOR1; \
- }; \
-
- #define FOUT_2_DEPTH \
- # define _MRT \
- # define _PIX_OUT \
- # define _DEPTH_OUT \
- struct pixout \
- { \
- float4 Color0 : COLOR0; \
- float4 Color1 : COLOR1; \
- float Depth : DEPTH; \
- }; \
-
- //============================================================================
- // Functions
-
- #define BENDING \
- \
- float4 vPos = IN.Position; \
- \
- float fBF = max(vPos.z, 0) * Bend.z + Bend.w; \
- fBF = fBF * fBF; \
- fBF = fBF * fBF - Bend.w; \
- \
- float4 vP; \
- vP.xy = Bend.xy * fBF; \
- \
- float fLength = length(vPos.xyz); \
- \
- vPos.xy = vPos.xy + vP.xy; \
- float3 vDirect = normalize(vPos.xyz); \
- vPos.xyz = vDirect * fLength;
-
- //============================================================================
-
- #define TANG_MATR \
- \
- float3x3 objToTangentSpace; \
- objToTangentSpace[0] = IN.Tangent; \
- objToTangentSpace[1] = IN.Binormal; \
- objToTangentSpace[2] = IN.TNormal; \
-
- //============================================================================
-
- #define PROC_ATTENPIX lightVec * (AttenInfo.y * AttenInfo.z) + AttenInfo.z
- #define PROC_ATTENVERT (AttenInfo.x - 1/fiSqDist) * AttenInfo.y
-