int Version = 102; float4x4 UVWorldViewProj; float4x4 WorldViewProj; float4x4 World; float4x4 View; float4x4 DiffUVXForm; float3 EyePosObjSpace; float3 EyePos; float4 SelectionColor; float4 SelfColor; /* * Shadow Parameters */ float3 LightPos; float3 LightPosObjSpace; float R9700ShadowMapBias; float4 ShadowDensity; #include "Lighting.fx" #include "Skinning.fx" texture DiffTex; texture SelfTex; texture SpecTex; texture ReflectionTex; texture ShadowTex; texture ShadowMaskTex; #define SHADOWTECH_NONE 0 #define SHADOWTECH_R9700 1 #define SHADOWTECH_GF3 2 texture BlendTex; float BlendTexCoeff; texture HeatTex; texture GlowTex; float4 TranslucyCoeff; sampler DiffSampler = sampler_state { Texture = (DiffTex); MinFilter = Linear; MipFilter = Linear; MagFilter = Linear; AddressU = Wrap; AddressV = Wrap; AddressW = Wrap; }; sampler SpecSampler = sampler_state { Texture = (SpecTex); MinFilter = Linear; MipFilter = Point; MagFilter = Linear; AddressU = Wrap; AddressV = Wrap; AddressW = Wrap; }; sampler SelfSampler = sampler_state { Texture = (SelfTex); MinFilter = Linear; MipFilter = Point; MagFilter = Linear; AddressU = Wrap; AddressV = Wrap; AddressW = Wrap; }; sampler ReflectionSampler = sampler_state { Texture = (ReflectionTex); MinFilter = Linear; MipFilter = Point; MagFilter = Linear; AddressU = Wrap; AddressV = Wrap; AddressW = Wrap; }; sampler ShadowSampler = sampler_state { Texture = (ShadowTex); MinFilter = Linear; MipFilter = Point; MagFilter = Linear; AddressU = Clamp; AddressV = Clamp; AddressW = Clamp; }; sampler ShadowMaskSampler = sampler_state { Texture = (ShadowMaskTex); // Texture = (DiffTex); MinFilter = Linear; MipFilter = Linear; MagFilter = Linear; AddressU = Clamp; AddressV = Clamp; AddressW = Clamp; }; sampler BlendSampler = sampler_state { Texture = (BlendTex); MinFilter = Linear; MipFilter = Linear; MagFilter = Linear; AddressU = Wrap; AddressV = Wrap; AddressW = Wrap; }; sampler HeatSampler = sampler_state { Texture = (HeatTex); MinFilter = Linear; MipFilter = Point; MagFilter = Linear; AddressU = Wrap; AddressV = Wrap; AddressW = Wrap; }; sampler GlowSampler = sampler_state { Texture = (GlowTex); MinFilter = Linear; MipFilter = Point; MagFilter = Linear; AddressU = Wrap; AddressV = Wrap; AddressW = Wrap; }; struct VSIn { float4 Pos : POSITION; float3 Norm : NORMAL; float2 Tex : TEXCOORD0; float4 BlendWeight : BLENDWEIGHT; int4 BlendIndices : BLENDINDICES; }; struct VSOut { float4 Pos : POSITION; float4 Diff : COLOR0; float4 Spec : COLOR1; float4 Tex[4] : TEXCOORD0; }; struct PSIn { float4 Diff : COLOR0; float4 Spec : COLOR1; float4 Tex[4] : TEXCOORD0; }; VSOut VS(VSIn In, uniform int NbOmni, uniform int NbSpot, uniform int NbBone, uniform bool bEnvmapTexgen, uniform bool bSkinNormal, uniform bool bShadowCast, uniform bool bShadowReceive, uniform int ShadowTech, uniform bool bDiffUVXform ) { VSOut Out; float4 Pos; float3 Norm; SSkinningIn SkIn; SkIn.Pos = In.Pos; SkIn.Norm = In.Norm; SkIn.BlendIndexArray = (int[4])(D3DCOLORtoUBYTE4(In.BlendIndices)); SkIn.BlendWeightsArray = (float[4])In.BlendWeight; SSkinningOut SkOut = ComputeSkinning(SkIn, NbBone, bSkinNormal); Pos = SkOut.Pos; Norm = SkOut.Norm; Out.Pos = mul(Pos, WorldViewProj); float3 WorldPos = mul(Pos, World); /* * lighting */ SLightIn LightIn; LightIn.Pos = Pos; LightIn.Norm = Norm; LightIn.WorldPos = WorldPos; SLightOut LightOut; Out.Diff = 0; Out.Spec = 0; for (int iLight=0; iLight CurrentDistance ? 1 : 0; float4 ShadowMul = saturate(Shadow + MaskColor + ShadowDensity); In.Diff *= ShadowMul; In.Spec *= ShadowMul; } if (ShadowTech == SHADOWTECH_GF3) { // Projection flag need to be set outside of the .fx float4 Shadow = tex2D(ShadowSampler, In.Tex[2]); float4 MaskColor = tex2D(ShadowMaskSampler, In.Tex[3]); float4 ShadowMul = saturate(Shadow + MaskColor + ShadowDensity); In.Diff *= ShadowMul; In.Spec *= ShadowMul; } } float4 Color; Color = (Diff * (In.Diff + AmbientLight) * 4) + In.Spec; Color.a = Diff.a; if (bTranslucy) { Color.a = Color.a * TranslucyCoeff.a; } if (bHeat) { float4 Heat = tex2D(HeatSampler, In.Tex[0]); return Heat.aaaa; } if (bGlow) { float4 Glow = tex2D(GlowSampler, In.Tex[0]); return Glow; } return Color; } float4 main(PSIn In) : COLOR0 { bool bSelfIllumTex = false; bool bSelfIllumColor = false; bool bSpecMask = false; bool bReflection = false; bool bShadowCast = false; bool bShadowReceive = false; int ShadowTech = SHADOWTECH_NONE; bool bHeat = false; bool bGlow = false; bool bTranslucy = false; return PS(In, bSelfIllumTex, bSelfIllumColor, bSpecMask, bReflection, bShadowCast, bShadowReceive, ShadowTech, bHeat, bGlow, bTranslucy); } VSOut mainVS(VSIn In) { int NbOmni = 1; int NbSpot = 0; int NbBone = 0; bool bEnvmapTexgen = false; bool bSkinNormal = false; bool bShadowCast = false; bool bShadowReceive = true; int ShadowTech = SHADOWTECH_R9700; bool bDiffUVXForm = false; return VS(In, NbOmni, NbSpot, NbBone, bEnvmapTexgen, bSkinNormal, bShadowCast, bShadowReceive, ShadowTech, bDiffUVXForm ); } int CurrentVertexShader = 0; int CurrentPixelShader = 0; #include "DX8ShaderArray.fx" technique t0 { pass VertexLighting { VertexShader = (VSArray[CurrentVertexShader]); PixelShader = (PSArray[CurrentPixelShader]); FogEnable = false; } }