//=================================================================== // Eyelash shader // @author jboldiga //=================================================================== #ifdef _MAX_ // Max includes are in ../3dsMax/MaterialLibraries/ #include "../KFF_Macros" #include "lighting.fx" #else #include "c:/_project/Fatburger/Assets/Shaders/lighting.fx" #include "c:/_project/Fatburger/Assets/Shaders/KFF_Macros" #endif #ifdef _XBOX // Vertex shader texture sampler for the bone matrix palette. #define POINT_SAMPLER sampler_state { MipFilter = NONE; MinFilter = POINT; MagFilter = POINT; AddressU = CLAMP; AddressV = CLAMP; } sampler1D bone_palette_texture = POINT_SAMPLER; int bone_count; #endif texture diffuseTexture : Diffuse < string Name = "EUPHBARK.TGA"; string UIName = "Diffuse Map"; string ResourceType = "2D"; >; sampler2D diffuseTextureSampler = sampler_state { Texture = ; MinFilter = LINEAR; MagFilter = LINEAR; MipFilter = LINEAR; AddressU = WRAP; AddressV = WRAP; }; // matrices float4x4 wvp : WorldViewProjection < string UIType = "None"; >; float4x4 viewprojection : ViewProjection < string UIType = "None"; >; float4x4 worldI : WorldInverse < string UIType = "None"; >; #ifdef _XBOX #define MAX_BONE_COUNT 129 //jboldiga 2011-01-27: Fetch bone from the bone pallete in the texture cache float4x3 TFetchBoneMatrix( float BoneIndex ) { float TexCoord = BoneIndex / bone_count; float4 Result1; float4 Result2; float4 Result3; asm { tfetch1D Result1, TexCoord, bone_palette_texture, UseComputedLOD = false, OffsetX = 0.5 tfetch1D Result2, TexCoord, bone_palette_texture, UseComputedLOD = false, OffsetX = 1.5 tfetch1D Result3, TexCoord, bone_palette_texture, UseComputedLOD = false, OffsetX = 2.5 }; float4x3 Result; Result._11_21_31_41 = Result1.xyzw; Result._12_22_32_42 = Result2.xyzw; Result._13_23_33_43 = Result3.xyzw; return Result; } #endif // input from application struct a2v { float4 position : POSITION; float2 texCoord0 : TEXCOORD0; #ifdef _XBOX float4 boneIndices : BLENDINDICES; float4 boneWeights : BLENDWEIGHT; #endif }; // output to fragment program struct v2f { float4 position : POSITION; float2 texCoord0 : TEXCOORD0; }; //Vertex Shader v2f av(a2v In) { v2f Out = (v2f)0; float4 position; #ifdef _XBOX float BoneWeights[4] = (float[4])In.boneWeights; int BoneIndices[4] = (int[4])In.boneIndices; float4x3 LocalToWorldMatrix = 0; for( int i = 3; i >= 0; --i ) { LocalToWorldMatrix += BoneWeights[i] * TFetchBoneMatrix( BoneIndices[i] ); } [isolate] { position = float4(mul( In.position, LocalToWorldMatrix ), 1.0f); } //position = matmul(position, worldI); #else position = In.position; #endif Out.texCoord0 = In.texCoord0; //pass through texture coordinates from channel 1 Out.position = matmul(position, wvp); //transform vert position to homogeneous clip space return Out; } //Pixel Shader float4 af(v2f In) : COLOR { float4 diffuseTex = tex2D(diffuseTextureSampler, In.texCoord0.xy); return diffuseTex; } technique Complete { pass ambient { VertexShader = compile vs_3_0 av(); ZEnable = true; ZWriteEnable = true; CullMode = cw; ShadeMode = Gouraud; AlphaBlendEnable = true; AlphaTestEnable = true; AlphaRef = 64; AlphaFunc = GREATER; PixelShader = compile ps_3_0 af(); } }