diff --git a/StockEffects/AlphaTestEffect.fx b/StockEffects/AlphaTestEffect.fx deleted file mode 100644 index 287368c3..00000000 --- a/StockEffects/AlphaTestEffect.fx +++ /dev/null @@ -1,194 +0,0 @@ -//----------------------------------------------------------------------------- -// AlphaTestEffect.fx -// -// Microsoft XNA Community Game Platform -// Copyright (C) Microsoft Corporation. All rights reserved. -//----------------------------------------------------------------------------- - -#include "Macros.fxh" - - -DECLARE_TEXTURE(Texture, 0); - - -BEGIN_CONSTANTS - - float4 DiffuseColor _vs(c0) _cb(c0); - float4 AlphaTest _ps(c0) _cb(c1); - float3 FogColor _ps(c1) _cb(c2); - float4 FogVector _vs(c5) _cb(c3); - -MATRIX_CONSTANTS - - float4x4 WorldViewProj _vs(c1) _cb(c0); - -END_CONSTANTS - - -#include "Structures.fxh" -#include "Common.fxh" - - -// Vertex shader: basic. -VSOutputTx VSAlphaTest(VSInputTx vin) -{ - VSOutputTx vout; - - CommonVSOutput cout = ComputeCommonVSOutput(vin.Position); - SetCommonVSOutputParams; - - vout.TexCoord = vin.TexCoord; - - return vout; -} - - -// Vertex shader: no fog. -VSOutputTxNoFog VSAlphaTestNoFog(VSInputTx vin) -{ - VSOutputTxNoFog vout; - - CommonVSOutput cout = ComputeCommonVSOutput(vin.Position); - SetCommonVSOutputParamsNoFog; - - vout.TexCoord = vin.TexCoord; - - return vout; -} - - -// Vertex shader: vertex color. -VSOutputTx VSAlphaTestVc(VSInputTxVc vin) -{ - VSOutputTx vout; - - CommonVSOutput cout = ComputeCommonVSOutput(vin.Position); - SetCommonVSOutputParams; - - vout.TexCoord = vin.TexCoord; - vout.Diffuse *= vin.Color; - - return vout; -} - - -// Vertex shader: vertex color, no fog. -VSOutputTxNoFog VSAlphaTestVcNoFog(VSInputTxVc vin) -{ - VSOutputTxNoFog vout; - - CommonVSOutput cout = ComputeCommonVSOutput(vin.Position); - SetCommonVSOutputParamsNoFog; - - vout.TexCoord = vin.TexCoord; - vout.Diffuse *= vin.Color; - - return vout; -} - - -// Pixel shader: less/greater compare function. -float4 PSAlphaTestLtGt(PSInputTx pin) : SV_Target0 -{ - float4 color = SAMPLE_TEXTURE(Texture, pin.TexCoord) * pin.Diffuse; - - clip((color.a < AlphaTest.x) ? AlphaTest.z : AlphaTest.w); - - ApplyFog(color, pin.Specular.w); - - return color; -} - - -// Pixel shader: less/greater compare function, no fog. -float4 PSAlphaTestLtGtNoFog(PSInputTxNoFog pin) : SV_Target0 -{ - float4 color = SAMPLE_TEXTURE(Texture, pin.TexCoord) * pin.Diffuse; - - clip((color.a < AlphaTest.x) ? AlphaTest.z : AlphaTest.w); - - return color; -} - - -// Pixel shader: equal/notequal compare function. -float4 PSAlphaTestEqNe(PSInputTx pin) : SV_Target0 -{ - float4 color = SAMPLE_TEXTURE(Texture, pin.TexCoord) * pin.Diffuse; - - clip((abs(color.a - AlphaTest.x) < AlphaTest.y) ? AlphaTest.z : AlphaTest.w); - - ApplyFog(color, pin.Specular.w); - - return color; -} - - -// Pixel shader: equal/notequal compare function, no fog. -float4 PSAlphaTestEqNeNoFog(PSInputTxNoFog pin) : SV_Target0 -{ - float4 color = SAMPLE_TEXTURE(Texture, pin.TexCoord) * pin.Diffuse; - - clip((abs(color.a - AlphaTest.x) < AlphaTest.y) ? AlphaTest.z : AlphaTest.w); - - return color; -} - - -VertexShader VSArray[4] = -{ - compile vs_2_0 VSAlphaTest(), - compile vs_2_0 VSAlphaTestNoFog(), - compile vs_2_0 VSAlphaTestVc(), - compile vs_2_0 VSAlphaTestVcNoFog(), -}; - - -int VSIndices[8] = -{ - 0, // lt/gt - 1, // lt/gt, no fog - 2, // lt/gt, vertex color - 3, // lt/gt, vertex color, no fog - - 0, // eq/ne - 1, // eq/ne, no fog - 2, // eq/ne, vertex color - 3, // eq/ne, vertex color, no fog -}; - - -PixelShader PSArray[4] = -{ - compile ps_2_0 PSAlphaTestLtGt(), - compile ps_2_0 PSAlphaTestLtGtNoFog(), - compile ps_2_0 PSAlphaTestEqNe(), - compile ps_2_0 PSAlphaTestEqNeNoFog(), -}; - - -int PSIndices[8] = -{ - 0, // lt/gt - 1, // lt/gt, no fog - 0, // lt/gt, vertex color - 1, // lt/gt, vertex color, no fog - - 2, // eq/ne - 3, // eq/ne, no fog - 2, // eq/ne, vertex color - 3, // eq/ne, vertex color, no fog -}; - - -int ShaderIndex = 0; - - -Technique AlphaTestEffect -{ - Pass - { - VertexShader = (VSArray[VSIndices[ShaderIndex]]); - PixelShader = (PSArray[PSIndices[ShaderIndex]]); - } -} diff --git a/StockEffects/BasicEffect.fx b/StockEffects/BasicEffect.fx deleted file mode 100644 index 0efd76d8..00000000 --- a/StockEffects/BasicEffect.fx +++ /dev/null @@ -1,588 +0,0 @@ -//----------------------------------------------------------------------------- -// BasicEffect.fx -// -// Microsoft XNA Community Game Platform -// Copyright (C) Microsoft Corporation. All rights reserved. -//----------------------------------------------------------------------------- - -#include "Macros.fxh" - - -DECLARE_TEXTURE(Texture, 0); - - -BEGIN_CONSTANTS - - float4 DiffuseColor _vs(c0) _ps(c1) _cb(c0); - float3 EmissiveColor _vs(c1) _ps(c2) _cb(c1); - float3 SpecularColor _vs(c2) _ps(c3) _cb(c2); - float SpecularPower _vs(c3) _ps(c4) _cb(c2.w); - - float3 DirLight0Direction _vs(c4) _ps(c5) _cb(c3); - float3 DirLight0DiffuseColor _vs(c5) _ps(c6) _cb(c4); - float3 DirLight0SpecularColor _vs(c6) _ps(c7) _cb(c5); - - float3 DirLight1Direction _vs(c7) _ps(c8) _cb(c6); - float3 DirLight1DiffuseColor _vs(c8) _ps(c9) _cb(c7); - float3 DirLight1SpecularColor _vs(c9) _ps(c10) _cb(c8); - - float3 DirLight2Direction _vs(c10) _ps(c11) _cb(c9); - float3 DirLight2DiffuseColor _vs(c11) _ps(c12) _cb(c10); - float3 DirLight2SpecularColor _vs(c12) _ps(c13) _cb(c11); - - float3 EyePosition _vs(c13) _ps(c14) _cb(c12); - - float3 FogColor _ps(c0) _cb(c13); - float4 FogVector _vs(c14) _cb(c14); - - float4x4 World _vs(c19) _cb(c15); - float3x3 WorldInverseTranspose _vs(c23) _cb(c19); - -MATRIX_CONSTANTS - - float4x4 WorldViewProj _vs(c15) _cb(c0); - -END_CONSTANTS - - -#include "Structures.fxh" -#include "Common.fxh" -#include "Lighting.fxh" - - -// Vertex shader: basic. -VSOutput VSBasic(VSInput vin) -{ - VSOutput vout; - - CommonVSOutput cout = ComputeCommonVSOutput(vin.Position); - SetCommonVSOutputParams; - - return vout; -} - - -// Vertex shader: no fog. -VSOutputNoFog VSBasicNoFog(VSInput vin) -{ - VSOutputNoFog vout; - - CommonVSOutput cout = ComputeCommonVSOutput(vin.Position); - SetCommonVSOutputParamsNoFog; - - return vout; -} - - -// Vertex shader: vertex color. -VSOutput VSBasicVc(VSInputVc vin) -{ - VSOutput vout; - - CommonVSOutput cout = ComputeCommonVSOutput(vin.Position); - SetCommonVSOutputParams; - - vout.Diffuse *= vin.Color; - - return vout; -} - - -// Vertex shader: vertex color, no fog. -VSOutputNoFog VSBasicVcNoFog(VSInputVc vin) -{ - VSOutputNoFog vout; - - CommonVSOutput cout = ComputeCommonVSOutput(vin.Position); - SetCommonVSOutputParamsNoFog; - - vout.Diffuse *= vin.Color; - - return vout; -} - - -// Vertex shader: texture. -VSOutputTx VSBasicTx(VSInputTx vin) -{ - VSOutputTx vout; - - CommonVSOutput cout = ComputeCommonVSOutput(vin.Position); - SetCommonVSOutputParams; - - vout.TexCoord = vin.TexCoord; - - return vout; -} - - -// Vertex shader: texture, no fog. -VSOutputTxNoFog VSBasicTxNoFog(VSInputTx vin) -{ - VSOutputTxNoFog vout; - - CommonVSOutput cout = ComputeCommonVSOutput(vin.Position); - SetCommonVSOutputParamsNoFog; - - vout.TexCoord = vin.TexCoord; - - return vout; -} - - -// Vertex shader: texture + vertex color. -VSOutputTx VSBasicTxVc(VSInputTxVc vin) -{ - VSOutputTx vout; - - CommonVSOutput cout = ComputeCommonVSOutput(vin.Position); - SetCommonVSOutputParams; - - vout.TexCoord = vin.TexCoord; - vout.Diffuse *= vin.Color; - - return vout; -} - - -// Vertex shader: texture + vertex color, no fog. -VSOutputTxNoFog VSBasicTxVcNoFog(VSInputTxVc vin) -{ - VSOutputTxNoFog vout; - - CommonVSOutput cout = ComputeCommonVSOutput(vin.Position); - SetCommonVSOutputParamsNoFog; - - vout.TexCoord = vin.TexCoord; - vout.Diffuse *= vin.Color; - - return vout; -} - - -// Vertex shader: vertex lighting. -VSOutput VSBasicVertexLighting(VSInputNm vin) -{ - VSOutput vout; - - CommonVSOutput cout = ComputeCommonVSOutputWithLighting(vin.Position, vin.Normal, 3); - SetCommonVSOutputParams; - - return vout; -} - - -// Vertex shader: vertex lighting + vertex color. -VSOutput VSBasicVertexLightingVc(VSInputNmVc vin) -{ - VSOutput vout; - - CommonVSOutput cout = ComputeCommonVSOutputWithLighting(vin.Position, vin.Normal, 3); - SetCommonVSOutputParams; - - vout.Diffuse *= vin.Color; - - return vout; -} - - -// Vertex shader: vertex lighting + texture. -VSOutputTx VSBasicVertexLightingTx(VSInputNmTx vin) -{ - VSOutputTx vout; - - CommonVSOutput cout = ComputeCommonVSOutputWithLighting(vin.Position, vin.Normal, 3); - SetCommonVSOutputParams; - - vout.TexCoord = vin.TexCoord; - - return vout; -} - - -// Vertex shader: vertex lighting + texture + vertex color. -VSOutputTx VSBasicVertexLightingTxVc(VSInputNmTxVc vin) -{ - VSOutputTx vout; - - CommonVSOutput cout = ComputeCommonVSOutputWithLighting(vin.Position, vin.Normal, 3); - SetCommonVSOutputParams; - - vout.TexCoord = vin.TexCoord; - vout.Diffuse *= vin.Color; - - return vout; -} - - -// Vertex shader: one light. -VSOutput VSBasicOneLight(VSInputNm vin) -{ - VSOutput vout; - - CommonVSOutput cout = ComputeCommonVSOutputWithLighting(vin.Position, vin.Normal, 1); - SetCommonVSOutputParams; - - return vout; -} - - -// Vertex shader: one light + vertex color. -VSOutput VSBasicOneLightVc(VSInputNmVc vin) -{ - VSOutput vout; - - CommonVSOutput cout = ComputeCommonVSOutputWithLighting(vin.Position, vin.Normal, 1); - SetCommonVSOutputParams; - - vout.Diffuse *= vin.Color; - - return vout; -} - - -// Vertex shader: one light + texture. -VSOutputTx VSBasicOneLightTx(VSInputNmTx vin) -{ - VSOutputTx vout; - - CommonVSOutput cout = ComputeCommonVSOutputWithLighting(vin.Position, vin.Normal, 1); - SetCommonVSOutputParams; - - vout.TexCoord = vin.TexCoord; - - return vout; -} - - -// Vertex shader: one light + texture + vertex color. -VSOutputTx VSBasicOneLightTxVc(VSInputNmTxVc vin) -{ - VSOutputTx vout; - - CommonVSOutput cout = ComputeCommonVSOutputWithLighting(vin.Position, vin.Normal, 1); - SetCommonVSOutputParams; - - vout.TexCoord = vin.TexCoord; - vout.Diffuse *= vin.Color; - - return vout; -} - - -// Vertex shader: pixel lighting. -VSOutputPixelLighting VSBasicPixelLighting(VSInputNm vin) -{ - VSOutputPixelLighting vout; - - CommonVSOutputPixelLighting cout = ComputeCommonVSOutputPixelLighting(vin.Position, vin.Normal); - SetCommonVSOutputParamsPixelLighting; - - vout.Diffuse = float4(1, 1, 1, DiffuseColor.a); - - return vout; -} - - -// Vertex shader: pixel lighting + vertex color. -VSOutputPixelLighting VSBasicPixelLightingVc(VSInputNmVc vin) -{ - VSOutputPixelLighting vout; - - CommonVSOutputPixelLighting cout = ComputeCommonVSOutputPixelLighting(vin.Position, vin.Normal); - SetCommonVSOutputParamsPixelLighting; - - vout.Diffuse.rgb = vin.Color.rgb; - vout.Diffuse.a = vin.Color.a * DiffuseColor.a; - - return vout; -} - - -// Vertex shader: pixel lighting + texture. -VSOutputPixelLightingTx VSBasicPixelLightingTx(VSInputNmTx vin) -{ - VSOutputPixelLightingTx vout; - - CommonVSOutputPixelLighting cout = ComputeCommonVSOutputPixelLighting(vin.Position, vin.Normal); - SetCommonVSOutputParamsPixelLighting; - - vout.Diffuse = float4(1, 1, 1, DiffuseColor.a); - vout.TexCoord = vin.TexCoord; - - return vout; -} - - -// Vertex shader: pixel lighting + texture + vertex color. -VSOutputPixelLightingTx VSBasicPixelLightingTxVc(VSInputNmTxVc vin) -{ - VSOutputPixelLightingTx vout; - - CommonVSOutputPixelLighting cout = ComputeCommonVSOutputPixelLighting(vin.Position, vin.Normal); - SetCommonVSOutputParamsPixelLighting; - - vout.Diffuse.rgb = vin.Color.rgb; - vout.Diffuse.a = vin.Color.a * DiffuseColor.a; - vout.TexCoord = vin.TexCoord; - - return vout; -} - - -// Pixel shader: basic. -float4 PSBasic(PSInput pin) : SV_Target0 -{ - float4 color = pin.Diffuse; - - ApplyFog(color, pin.Specular.w); - - return color; -} - - -// Pixel shader: no fog. -float4 PSBasicNoFog(PSInputNoFog pin) : SV_Target0 -{ - return pin.Diffuse; -} - - -// Pixel shader: texture. -float4 PSBasicTx(PSInputTx pin) : SV_Target0 -{ - float4 color = SAMPLE_TEXTURE(Texture, pin.TexCoord) * pin.Diffuse; - - ApplyFog(color, pin.Specular.w); - - return color; -} - - -// Pixel shader: texture, no fog. -float4 PSBasicTxNoFog(PSInputTxNoFog pin) : SV_Target0 -{ - return SAMPLE_TEXTURE(Texture, pin.TexCoord) * pin.Diffuse; -} - - -// Pixel shader: vertex lighting. -float4 PSBasicVertexLighting(PSInput pin) : SV_Target0 -{ - float4 color = pin.Diffuse; - - AddSpecular(color, pin.Specular.rgb); - ApplyFog(color, pin.Specular.w); - - return color; -} - - -// Pixel shader: vertex lighting, no fog. -float4 PSBasicVertexLightingNoFog(PSInput pin) : SV_Target0 -{ - float4 color = pin.Diffuse; - - AddSpecular(color, pin.Specular.rgb); - - return color; -} - - -// Pixel shader: vertex lighting + texture. -float4 PSBasicVertexLightingTx(PSInputTx pin) : SV_Target0 -{ - float4 color = SAMPLE_TEXTURE(Texture, pin.TexCoord) * pin.Diffuse; - - AddSpecular(color, pin.Specular.rgb); - ApplyFog(color, pin.Specular.w); - - return color; -} - - -// Pixel shader: vertex lighting + texture, no fog. -float4 PSBasicVertexLightingTxNoFog(PSInputTx pin) : SV_Target0 -{ - float4 color = SAMPLE_TEXTURE(Texture, pin.TexCoord) * pin.Diffuse; - - AddSpecular(color, pin.Specular.rgb); - - return color; -} - - -// Pixel shader: pixel lighting. -float4 PSBasicPixelLighting(PSInputPixelLighting pin) : SV_Target0 -{ - float4 color = pin.Diffuse; - - float3 eyeVector = normalize(EyePosition - pin.PositionWS.xyz); - float3 worldNormal = normalize(pin.NormalWS); - - ColorPair lightResult = ComputeLights(eyeVector, worldNormal, 3); - - color.rgb *= lightResult.Diffuse; - - AddSpecular(color, lightResult.Specular); - ApplyFog(color, pin.PositionWS.w); - - return color; -} - - -// Pixel shader: pixel lighting + texture. -float4 PSBasicPixelLightingTx(PSInputPixelLightingTx pin) : SV_Target0 -{ - float4 color = SAMPLE_TEXTURE(Texture, pin.TexCoord) * pin.Diffuse; - - float3 eyeVector = normalize(EyePosition - pin.PositionWS.xyz); - float3 worldNormal = normalize(pin.NormalWS); - - ColorPair lightResult = ComputeLights(eyeVector, worldNormal, 3); - - color.rgb *= lightResult.Diffuse; - - AddSpecular(color, lightResult.Specular); - ApplyFog(color, pin.PositionWS.w); - - return color; -} - - -VertexShader VSArray[20] = -{ - compile vs_2_0 VSBasic(), - compile vs_2_0 VSBasicNoFog(), - compile vs_2_0 VSBasicVc(), - compile vs_2_0 VSBasicVcNoFog(), - compile vs_2_0 VSBasicTx(), - compile vs_2_0 VSBasicTxNoFog(), - compile vs_2_0 VSBasicTxVc(), - compile vs_2_0 VSBasicTxVcNoFog(), - - compile vs_2_0 VSBasicVertexLighting(), - compile vs_2_0 VSBasicVertexLightingVc(), - compile vs_2_0 VSBasicVertexLightingTx(), - compile vs_2_0 VSBasicVertexLightingTxVc(), - - compile vs_2_0 VSBasicOneLight(), - compile vs_2_0 VSBasicOneLightVc(), - compile vs_2_0 VSBasicOneLightTx(), - compile vs_2_0 VSBasicOneLightTxVc(), - - compile vs_2_0 VSBasicPixelLighting(), - compile vs_2_0 VSBasicPixelLightingVc(), - compile vs_2_0 VSBasicPixelLightingTx(), - compile vs_2_0 VSBasicPixelLightingTxVc(), -}; - - -int VSIndices[32] = -{ - 0, // basic - 1, // no fog - 2, // vertex color - 3, // vertex color, no fog - 4, // texture - 5, // texture, no fog - 6, // texture + vertex color - 7, // texture + vertex color, no fog - - 8, // vertex lighting - 8, // vertex lighting, no fog - 9, // vertex lighting + vertex color - 9, // vertex lighting + vertex color, no fog - 10, // vertex lighting + texture - 10, // vertex lighting + texture, no fog - 11, // vertex lighting + texture + vertex color - 11, // vertex lighting + texture + vertex color, no fog - - 12, // one light - 12, // one light, no fog - 13, // one light + vertex color - 13, // one light + vertex color, no fog - 14, // one light + texture - 14, // one light + texture, no fog - 15, // one light + texture + vertex color - 15, // one light + texture + vertex color, no fog - - 16, // pixel lighting - 16, // pixel lighting, no fog - 17, // pixel lighting + vertex color - 17, // pixel lighting + vertex color, no fog - 18, // pixel lighting + texture - 18, // pixel lighting + texture, no fog - 19, // pixel lighting + texture + vertex color - 19, // pixel lighting + texture + vertex color, no fog -}; - - -PixelShader PSArray[10] = -{ - compile ps_2_0 PSBasic(), - compile ps_2_0 PSBasicNoFog(), - compile ps_2_0 PSBasicTx(), - compile ps_2_0 PSBasicTxNoFog(), - - compile ps_2_0 PSBasicVertexLighting(), - compile ps_2_0 PSBasicVertexLightingNoFog(), - compile ps_2_0 PSBasicVertexLightingTx(), - compile ps_2_0 PSBasicVertexLightingTxNoFog(), - - compile ps_2_0 PSBasicPixelLighting(), - compile ps_2_0 PSBasicPixelLightingTx(), -}; - - -int PSIndices[32] = -{ - 0, // basic - 1, // no fog - 0, // vertex color - 1, // vertex color, no fog - 2, // texture - 3, // texture, no fog - 2, // texture + vertex color - 3, // texture + vertex color, no fog - - 4, // vertex lighting - 5, // vertex lighting, no fog - 4, // vertex lighting + vertex color - 5, // vertex lighting + vertex color, no fog - 6, // vertex lighting + texture - 7, // vertex lighting + texture, no fog - 6, // vertex lighting + texture + vertex color - 7, // vertex lighting + texture + vertex color, no fog - - 4, // one light - 5, // one light, no fog - 4, // one light + vertex color - 5, // one light + vertex color, no fog - 6, // one light + texture - 7, // one light + texture, no fog - 6, // one light + texture + vertex color - 7, // one light + texture + vertex color, no fog - - 8, // pixel lighting - 8, // pixel lighting, no fog - 8, // pixel lighting + vertex color - 8, // pixel lighting + vertex color, no fog - 9, // pixel lighting + texture - 9, // pixel lighting + texture, no fog - 9, // pixel lighting + texture + vertex color - 9, // pixel lighting + texture + vertex color, no fog -}; - - -int ShaderIndex = 0; - - -Technique BasicEffect -{ - Pass - { - VertexShader = (VSArray[VSIndices[ShaderIndex]]); - PixelShader = (PSArray[PSIndices[ShaderIndex]]); - } -} diff --git a/StockEffects/Common.fxh b/StockEffects/Common.fxh deleted file mode 100644 index ff8c4a96..00000000 --- a/StockEffects/Common.fxh +++ /dev/null @@ -1,58 +0,0 @@ -//----------------------------------------------------------------------------- -// Common.fxh -// -// Microsoft XNA Community Game Platform -// Copyright (C) Microsoft Corporation. All rights reserved. -//----------------------------------------------------------------------------- - - -float ComputeFogFactor(float4 position) -{ - return saturate(dot(position, FogVector)); -} - - -void ApplyFog(inout float4 color, float fogFactor) -{ - color.rgb = lerp(color.rgb, FogColor * color.a, fogFactor); -} - - -void AddSpecular(inout float4 color, float3 specular) -{ - color.rgb += specular * color.a; -} - - -struct CommonVSOutput -{ - float4 Pos_ps; - float4 Diffuse; - float3 Specular; - float FogFactor; -}; - - -CommonVSOutput ComputeCommonVSOutput(float4 position) -{ - CommonVSOutput vout; - - vout.Pos_ps = mul(position, WorldViewProj); - vout.Diffuse = DiffuseColor; - vout.Specular = 0; - vout.FogFactor = ComputeFogFactor(position); - - return vout; -} - - -#define SetCommonVSOutputParams \ - vout.PositionPS = cout.Pos_ps; \ - vout.Diffuse = cout.Diffuse; \ - vout.Specular = float4(cout.Specular, cout.FogFactor); - - -#define SetCommonVSOutputParamsNoFog \ - vout.PositionPS = cout.Pos_ps; \ - vout.Diffuse = cout.Diffuse; - diff --git a/StockEffects/DualTextureEffect.fx b/StockEffects/DualTextureEffect.fx deleted file mode 100644 index df74b4f8..00000000 --- a/StockEffects/DualTextureEffect.fx +++ /dev/null @@ -1,157 +0,0 @@ -//----------------------------------------------------------------------------- -// DualTextureEffect.fx -// -// Microsoft XNA Community Game Platform -// Copyright (C) Microsoft Corporation. All rights reserved. -//----------------------------------------------------------------------------- - -#include "Macros.fxh" - - -DECLARE_TEXTURE(Texture, 0); -DECLARE_TEXTURE(Texture2, 1); - - -BEGIN_CONSTANTS - - float4 DiffuseColor _vs(c0) _cb(c0); - float3 FogColor _ps(c0) _cb(c1); - float4 FogVector _vs(c5) _cb(c2); - -MATRIX_CONSTANTS - - float4x4 WorldViewProj _vs(c1) _cb(c0); - -END_CONSTANTS - - -#include "Structures.fxh" -#include "Common.fxh" - - -// Vertex shader: basic. -VSOutputTx2 VSDualTexture(VSInputTx2 vin) -{ - VSOutputTx2 vout; - - CommonVSOutput cout = ComputeCommonVSOutput(vin.Position); - SetCommonVSOutputParams; - - vout.TexCoord = vin.TexCoord; - vout.TexCoord2 = vin.TexCoord2; - - return vout; -} - - -// Vertex shader: no fog. -VSOutputTx2NoFog VSDualTextureNoFog(VSInputTx2 vin) -{ - VSOutputTx2NoFog vout; - - CommonVSOutput cout = ComputeCommonVSOutput(vin.Position); - SetCommonVSOutputParamsNoFog; - - vout.TexCoord = vin.TexCoord; - vout.TexCoord2 = vin.TexCoord2; - - return vout; -} - - -// Vertex shader: vertex color. -VSOutputTx2 VSDualTextureVc(VSInputTx2Vc vin) -{ - VSOutputTx2 vout; - - CommonVSOutput cout = ComputeCommonVSOutput(vin.Position); - SetCommonVSOutputParams; - - vout.TexCoord = vin.TexCoord; - vout.TexCoord2 = vin.TexCoord2; - vout.Diffuse *= vin.Color; - - return vout; -} - - -// Vertex shader: vertex color, no fog. -VSOutputTx2NoFog VSDualTextureVcNoFog(VSInputTx2Vc vin) -{ - VSOutputTx2NoFog vout; - - CommonVSOutput cout = ComputeCommonVSOutput(vin.Position); - SetCommonVSOutputParamsNoFog; - - vout.TexCoord = vin.TexCoord; - vout.TexCoord2 = vin.TexCoord2; - vout.Diffuse *= vin.Color; - - return vout; -} - - -// Pixel shader: basic. -float4 PSDualTexture(PSInputTx2 pin) : SV_Target0 -{ - float4 color = SAMPLE_TEXTURE(Texture, pin.TexCoord); - float4 overlay = SAMPLE_TEXTURE(Texture2, pin.TexCoord2); - - color.rgb *= 2; - color *= overlay * pin.Diffuse; - - ApplyFog(color, pin.Specular.w); - - return color; -} - - -// Pixel shader: no fog. -float4 PSDualTextureNoFog(PSInputTx2NoFog pin) : SV_Target0 -{ - float4 color = SAMPLE_TEXTURE(Texture, pin.TexCoord); - float4 overlay = SAMPLE_TEXTURE(Texture2, pin.TexCoord2); - - color.rgb *= 2; - color *= overlay * pin.Diffuse; - - return color; -} - - -VertexShader VSArray[4] = -{ - compile vs_2_0 VSDualTexture(), - compile vs_2_0 VSDualTextureNoFog(), - compile vs_2_0 VSDualTextureVc(), - compile vs_2_0 VSDualTextureVcNoFog(), -}; - - -PixelShader PSArray[2] = -{ - compile ps_2_0 PSDualTexture(), - compile ps_2_0 PSDualTextureNoFog(), -}; - - -int PSIndices[4] = -{ - 0, // basic - 1, // no fog - 0, // vertex color - 1, // vertex color, no fog -}; - - -int ShaderIndex = 0; - - -Technique DualTextureEffect -{ - Pass - { - VertexShader = (VSArray[ShaderIndex]); - PixelShader = (PSArray[PSIndices[ShaderIndex]]); - } -} diff --git a/StockEffects/EnvironmentMapEffect.fx b/StockEffects/EnvironmentMapEffect.fx deleted file mode 100644 index b691ad1c..00000000 --- a/StockEffects/EnvironmentMapEffect.fx +++ /dev/null @@ -1,249 +0,0 @@ -//----------------------------------------------------------------------------- -// EnvironmentMapEffect.fx -// -// Microsoft XNA Community Game Platform -// Copyright (C) Microsoft Corporation. All rights reserved. -//----------------------------------------------------------------------------- - -#include "Macros.fxh" - - -DECLARE_TEXTURE(Texture, 0); -DECLARE_CUBEMAP(EnvironmentMap, 1); - - -BEGIN_CONSTANTS - - float3 EnvironmentMapSpecular _ps(c0) _cb(c0); - float FresnelFactor _vs(c0) _cb(c0.w); - float EnvironmentMapAmount _vs(c1) _cb(c2.w); - - float4 DiffuseColor _vs(c2) _cb(c1); - float3 EmissiveColor _vs(c3) _cb(c2); - - float3 DirLight0Direction _vs(c4) _cb(c3); - float3 DirLight0DiffuseColor _vs(c5) _cb(c4); - - float3 DirLight1Direction _vs(c6) _cb(c5); - float3 DirLight1DiffuseColor _vs(c7) _cb(c6); - - float3 DirLight2Direction _vs(c8) _cb(c7); - float3 DirLight2DiffuseColor _vs(c9) _cb(c8); - - float3 EyePosition _vs(c10) _cb(c9); - - float3 FogColor _ps(c1) _cb(c10); - float4 FogVector _vs(c11) _cb(c11); - - float4x4 World _vs(c16) _cb(c12); - float3x3 WorldInverseTranspose _vs(c19) _cb(c16); - -MATRIX_CONSTANTS - - float4x4 WorldViewProj _vs(c12) _cb(c0); - -END_CONSTANTS - - -// We don't use these parameters, but Lighting.fxh won't compile without them. -#define SpecularPower 0 -#define SpecularColor float3(0, 0, 0) -#define DirLight0SpecularColor float3(0, 0, 0) -#define DirLight1SpecularColor float3(0, 0, 0) -#define DirLight2SpecularColor float3(0, 0, 0) - - -#include "Structures.fxh" -#include "Common.fxh" -#include "Lighting.fxh" - - -float ComputeFresnelFactor(float3 eyeVector, float3 worldNormal) -{ - float viewAngle = dot(eyeVector, worldNormal); - - return pow(max(1 - abs(viewAngle), 0), FresnelFactor) * EnvironmentMapAmount; -} - - -VSOutputTxEnvMap ComputeEnvMapVSOutput(VSInputNmTx vin, uniform bool useFresnel, uniform int numLights) -{ - VSOutputTxEnvMap vout; - - float4 pos_ws = mul(vin.Position, World); - float3 eyeVector = normalize(EyePosition - pos_ws.xyz); - float3 worldNormal = normalize(mul(vin.Normal, WorldInverseTranspose)); - - ColorPair lightResult = ComputeLights(eyeVector, worldNormal, numLights); - - vout.PositionPS = mul(vin.Position, WorldViewProj); - vout.Diffuse = float4(lightResult.Diffuse, DiffuseColor.a); - - if (useFresnel) - vout.Specular.rgb = ComputeFresnelFactor(eyeVector, worldNormal); - else - vout.Specular.rgb = EnvironmentMapAmount; - - vout.Specular.a = ComputeFogFactor(vin.Position); - vout.TexCoord = vin.TexCoord; - vout.EnvCoord = reflect(-eyeVector, worldNormal); - - return vout; -} - - -// Vertex shader: basic. -VSOutputTxEnvMap VSEnvMap(VSInputNmTx vin) -{ - return ComputeEnvMapVSOutput(vin, false, 3); -} - - -// Vertex shader: fresnel. -VSOutputTxEnvMap VSEnvMapFresnel(VSInputNmTx vin) -{ - return ComputeEnvMapVSOutput(vin, true, 3); -} - - -// Vertex shader: one light. -VSOutputTxEnvMap VSEnvMapOneLight(VSInputNmTx vin) -{ - return ComputeEnvMapVSOutput(vin, false, 1); -} - - -// Vertex shader: one light, fresnel. -VSOutputTxEnvMap VSEnvMapOneLightFresnel(VSInputNmTx vin) -{ - return ComputeEnvMapVSOutput(vin, true, 1); -} - - -// Pixel shader: basic. -float4 PSEnvMap(PSInputTxEnvMap pin) : SV_Target0 -{ - float4 color = SAMPLE_TEXTURE(Texture, pin.TexCoord) * pin.Diffuse; - float4 envmap = SAMPLE_CUBEMAP(EnvironmentMap, pin.EnvCoord) * color.a; - - color.rgb = lerp(color.rgb, envmap.rgb, pin.Specular.rgb); - - ApplyFog(color, pin.Specular.w); - - return color; -} - - -// Pixel shader: no fog. -float4 PSEnvMapNoFog(PSInputTxEnvMap pin) : SV_Target0 -{ - float4 color = SAMPLE_TEXTURE(Texture, pin.TexCoord) * pin.Diffuse; - float4 envmap = SAMPLE_CUBEMAP(EnvironmentMap, pin.EnvCoord) * color.a; - - color.rgb = lerp(color.rgb, envmap.rgb, pin.Specular.rgb); - - return color; -} - - -// Pixel shader: specular. -float4 PSEnvMapSpecular(PSInputTxEnvMap pin) : SV_Target0 -{ - float4 color = SAMPLE_TEXTURE(Texture, pin.TexCoord) * pin.Diffuse; - float4 envmap = SAMPLE_CUBEMAP(EnvironmentMap, pin.EnvCoord) * color.a; - - color.rgb = lerp(color.rgb, envmap.rgb, pin.Specular.rgb); - color.rgb += EnvironmentMapSpecular * envmap.a; - - ApplyFog(color, pin.Specular.w); - - return color; -} - - -// Pixel shader: specular, no fog. -float4 PSEnvMapSpecularNoFog(PSInputTxEnvMap pin) : SV_Target0 -{ - float4 color = SAMPLE_TEXTURE(Texture, pin.TexCoord) * pin.Diffuse; - float4 envmap = SAMPLE_CUBEMAP(EnvironmentMap, pin.EnvCoord) * color.a; - - color.rgb = lerp(color.rgb, envmap.rgb, pin.Specular.rgb); - color.rgb += EnvironmentMapSpecular * envmap.a; - - return color; -} - - -VertexShader VSArray[4] = -{ - compile vs_2_0 VSEnvMap(), - compile vs_2_0 VSEnvMapFresnel(), - compile vs_2_0 VSEnvMapOneLight(), - compile vs_2_0 VSEnvMapOneLightFresnel(), -}; - - -int VSIndices[16] = -{ - 0, // basic - 0, // basic, no fog - 1, // fresnel - 1, // fresnel, no fog - 0, // specular - 0, // specular, no fog - 1, // fresnel + specular - 1, // fresnel + specular, no fog - - 2, // one light - 2, // one light, no fog - 3, // one light, fresnel - 3, // one light, fresnel, no fog - 2, // one light, specular - 2, // one light, specular, no fog - 3, // one light, fresnel + specular - 3, // one light, fresnel + specular, no fog -}; - - -PixelShader PSArray[4] = -{ - compile ps_2_0 PSEnvMap(), - compile ps_2_0 PSEnvMapNoFog(), - compile ps_2_0 PSEnvMapSpecular(), - compile ps_2_0 PSEnvMapSpecularNoFog(), -}; - - -int PSIndices[16] = -{ - 0, // basic - 1, // basic, no fog - 0, // fresnel - 1, // fresnel, no fog - 2, // specular - 3, // specular, no fog - 2, // fresnel + specular - 3, // fresnel + specular, no fog - - 0, // one light - 1, // one light, no fog - 0, // one light, fresnel - 1, // one light, fresnel, no fog - 2, // one light, specular - 3, // one light, specular, no fog - 2, // one light, fresnel + specular - 3, // one light, fresnel + specular, no fog -}; - - -int ShaderIndex = 0; - - -Technique EnvironmentMapEffect -{ - Pass - { - VertexShader = (VSArray[VSIndices[ShaderIndex]]); - PixelShader = (PSArray[PSIndices[ShaderIndex]]); - } -} diff --git a/StockEffects/Lighting.fxh b/StockEffects/Lighting.fxh deleted file mode 100644 index 656bed19..00000000 --- a/StockEffects/Lighting.fxh +++ /dev/null @@ -1,94 +0,0 @@ -//----------------------------------------------------------------------------- -// Lighting.fxh -// -// Microsoft XNA Community Game Platform -// Copyright (C) Microsoft Corporation. All rights reserved. -//----------------------------------------------------------------------------- - - -struct ColorPair -{ - float3 Diffuse; - float3 Specular; -}; - - -ColorPair ComputeLights(float3 eyeVector, float3 worldNormal, uniform int numLights) -{ - float3x3 lightDirections = 0; - float3x3 lightDiffuse = 0; - float3x3 lightSpecular = 0; - float3x3 halfVectors = 0; - - [unroll] - for (int i = 0; i < numLights; i++) - { - lightDirections[i] = float3x3(DirLight0Direction, DirLight1Direction, DirLight2Direction) [i]; - lightDiffuse[i] = float3x3(DirLight0DiffuseColor, DirLight1DiffuseColor, DirLight2DiffuseColor) [i]; - lightSpecular[i] = float3x3(DirLight0SpecularColor, DirLight1SpecularColor, DirLight2SpecularColor)[i]; - - halfVectors[i] = normalize(eyeVector - lightDirections[i]); - } - - float3 dotL = mul(-lightDirections, worldNormal); - float3 dotH = mul(halfVectors, worldNormal); - - float3 zeroL = step(0, dotL); - - float3 diffuse = zeroL * dotL; - float3 specular = pow(max(dotH, 0) * zeroL, SpecularPower); - - ColorPair result; - - result.Diffuse = mul(diffuse, lightDiffuse) * DiffuseColor.rgb + EmissiveColor; - result.Specular = mul(specular, lightSpecular) * SpecularColor; - - return result; -} - - -CommonVSOutput ComputeCommonVSOutputWithLighting(float4 position, float3 normal, uniform int numLights) -{ - CommonVSOutput vout; - - float4 pos_ws = mul(position, World); - float3 eyeVector = normalize(EyePosition - pos_ws.xyz); - float3 worldNormal = normalize(mul(normal, WorldInverseTranspose)); - - ColorPair lightResult = ComputeLights(eyeVector, worldNormal, numLights); - - vout.Pos_ps = mul(position, WorldViewProj); - vout.Diffuse = float4(lightResult.Diffuse, DiffuseColor.a); - vout.Specular = lightResult.Specular; - vout.FogFactor = ComputeFogFactor(position); - - return vout; -} - - -struct CommonVSOutputPixelLighting -{ - float4 Pos_ps; - float3 Pos_ws; - float3 Normal_ws; - float FogFactor; -}; - - -CommonVSOutputPixelLighting ComputeCommonVSOutputPixelLighting(float4 position, float3 normal) -{ - CommonVSOutputPixelLighting vout; - - vout.Pos_ps = mul(position, WorldViewProj); - vout.Pos_ws = mul(position, World).xyz; - vout.Normal_ws = normalize(mul(normal, WorldInverseTranspose)); - vout.FogFactor = ComputeFogFactor(position); - - return vout; -} - - -#define SetCommonVSOutputParamsPixelLighting \ - vout.PositionPS = cout.Pos_ps; \ - vout.PositionWS = float4(cout.Pos_ws, cout.FogFactor); \ - vout.NormalWS = cout.Normal_ws; diff --git a/StockEffects/Macros.fxh b/StockEffects/Macros.fxh deleted file mode 100644 index fdb05a24..00000000 --- a/StockEffects/Macros.fxh +++ /dev/null @@ -1,58 +0,0 @@ -//----------------------------------------------------------------------------- -// Macros.fxh -// -// Microsoft XNA Community Game Platform -// Copyright (C) Microsoft Corporation. All rights reserved. -//----------------------------------------------------------------------------- - -#ifdef SM4 - - -// Macros for targetting shader model 4.0 (DX11) - -#define BEGIN_CONSTANTS cbuffer Parameters : register(b0) { -#define MATRIX_CONSTANTS }; cbuffer ProjectionMatrix : register(b1) { -#define END_CONSTANTS }; - -#define _vs(r) -#define _ps(r) -#define _cb(r) : packoffset(r) - -#define DECLARE_TEXTURE(Name, index) \ - Texture2D Name : register(t##index); \ - sampler Name##Sampler : register(s##index) - -#define DECLARE_CUBEMAP(Name, index) \ - TextureCube Name : register(t##index); \ - sampler Name##Sampler : register(s##index) - -#define SAMPLE_TEXTURE(Name, texCoord) Name.Sample(Name##Sampler, texCoord) -#define SAMPLE_CUBEMAP(Name, texCoord) Name.Sample(Name##Sampler, texCoord) - - -#else - - -// Macros for targetting shader model 2.0 (DX9) - -#define BEGIN_CONSTANTS -#define MATRIX_CONSTANTS -#define END_CONSTANTS - -#define _vs(r) : register(vs, r) -#define _ps(r) : register(ps, r) -#define _cb(r) - -#define DECLARE_TEXTURE(Name, index) \ - texture2D Name; \ - sampler Name##Sampler : register(s##index) = sampler_state { Texture = (Name); }; - -#define DECLARE_CUBEMAP(Name, index) \ - textureCUBE Name; \ - sampler Name##Sampler : register(s##index) = sampler_state { Texture = (Name); }; - -#define SAMPLE_TEXTURE(Name, texCoord) tex2D(Name##Sampler, texCoord) -#define SAMPLE_CUBEMAP(Name, texCoord) texCUBE(Name##Sampler, texCoord) - - -#endif diff --git a/StockEffects/SkinnedEffect.fx b/StockEffects/SkinnedEffect.fx deleted file mode 100644 index 80fa3259..00000000 --- a/StockEffects/SkinnedEffect.fx +++ /dev/null @@ -1,345 +0,0 @@ -//----------------------------------------------------------------------------- -// SkinnedEffect.fx -// -// Microsoft XNA Community Game Platform -// Copyright (C) Microsoft Corporation. All rights reserved. -//----------------------------------------------------------------------------- - -#include "Macros.fxh" - -#define SKINNED_EFFECT_MAX_BONES 72 - - -DECLARE_TEXTURE(Texture, 0); - - -BEGIN_CONSTANTS - - float4 DiffuseColor _vs(c0) _ps(c1) _cb(c0); - float3 EmissiveColor _vs(c1) _ps(c2) _cb(c1); - float3 SpecularColor _vs(c2) _ps(c3) _cb(c2); - float SpecularPower _vs(c3) _ps(c4) _cb(c2.w); - - float3 DirLight0Direction _vs(c4) _ps(c5) _cb(c3); - float3 DirLight0DiffuseColor _vs(c5) _ps(c6) _cb(c4); - float3 DirLight0SpecularColor _vs(c6) _ps(c7) _cb(c5); - - float3 DirLight1Direction _vs(c7) _ps(c8) _cb(c6); - float3 DirLight1DiffuseColor _vs(c8) _ps(c9) _cb(c7); - float3 DirLight1SpecularColor _vs(c9) _ps(c10) _cb(c8); - - float3 DirLight2Direction _vs(c10) _ps(c11) _cb(c9); - float3 DirLight2DiffuseColor _vs(c11) _ps(c12) _cb(c10); - float3 DirLight2SpecularColor _vs(c12) _ps(c13) _cb(c11); - - float3 EyePosition _vs(c13) _ps(c14) _cb(c12); - - float3 FogColor _ps(c0) _cb(c13); - float4 FogVector _vs(c14) _cb(c14); - - float4x4 World _vs(c19) _cb(c15); - float3x3 WorldInverseTranspose _vs(c23) _cb(c19); - - float4x3 Bones[SKINNED_EFFECT_MAX_BONES] _vs(c26) _cb(c22); - -MATRIX_CONSTANTS - - float4x4 WorldViewProj _vs(c15) _cb(c0); - -END_CONSTANTS - - -#include "Structures.fxh" -#include "Common.fxh" -#include "Lighting.fxh" - - -void Skin(inout VSInputNmTxWeights vin, uniform int boneCount) -{ - float4x3 skinning = 0; - - [unroll] - for (int i = 0; i < boneCount; i++) - { - skinning += Bones[vin.Indices[i]] * vin.Weights[i]; - } - - vin.Position.xyz = mul(vin.Position, skinning); - vin.Normal = mul(vin.Normal, (float3x3)skinning); -} - - -// Vertex shader: vertex lighting, one bone. -VSOutputTx VSSkinnedVertexLightingOneBone(VSInputNmTxWeights vin) -{ - VSOutputTx vout; - - Skin(vin, 1); - - CommonVSOutput cout = ComputeCommonVSOutputWithLighting(vin.Position, vin.Normal, 3); - SetCommonVSOutputParams; - - vout.TexCoord = vin.TexCoord; - - return vout; -} - - -// Vertex shader: vertex lighting, two bones. -VSOutputTx VSSkinnedVertexLightingTwoBones(VSInputNmTxWeights vin) -{ - VSOutputTx vout; - - Skin(vin, 2); - - CommonVSOutput cout = ComputeCommonVSOutputWithLighting(vin.Position, vin.Normal, 3); - SetCommonVSOutputParams; - - vout.TexCoord = vin.TexCoord; - - return vout; -} - - -// Vertex shader: vertex lighting, four bones. -VSOutputTx VSSkinnedVertexLightingFourBones(VSInputNmTxWeights vin) -{ - VSOutputTx vout; - - Skin(vin, 4); - - CommonVSOutput cout = ComputeCommonVSOutputWithLighting(vin.Position, vin.Normal, 3); - SetCommonVSOutputParams; - - vout.TexCoord = vin.TexCoord; - - return vout; -} - - -// Vertex shader: one light, one bone. -VSOutputTx VSSkinnedOneLightOneBone(VSInputNmTxWeights vin) -{ - VSOutputTx vout; - - Skin(vin, 1); - - CommonVSOutput cout = ComputeCommonVSOutputWithLighting(vin.Position, vin.Normal, 1); - SetCommonVSOutputParams; - - vout.TexCoord = vin.TexCoord; - - return vout; -} - - -// Vertex shader: one light, two bones. -VSOutputTx VSSkinnedOneLightTwoBones(VSInputNmTxWeights vin) -{ - VSOutputTx vout; - - Skin(vin, 2); - - CommonVSOutput cout = ComputeCommonVSOutputWithLighting(vin.Position, vin.Normal, 1); - SetCommonVSOutputParams; - - vout.TexCoord = vin.TexCoord; - - return vout; -} - - -// Vertex shader: one light, four bones. -VSOutputTx VSSkinnedOneLightFourBones(VSInputNmTxWeights vin) -{ - VSOutputTx vout; - - Skin(vin, 4); - - CommonVSOutput cout = ComputeCommonVSOutputWithLighting(vin.Position, vin.Normal, 1); - SetCommonVSOutputParams; - - vout.TexCoord = vin.TexCoord; - - return vout; -} - - -// Vertex shader: pixel lighting, one bone. -VSOutputPixelLightingTx VSSkinnedPixelLightingOneBone(VSInputNmTxWeights vin) -{ - VSOutputPixelLightingTx vout; - - Skin(vin, 1); - - CommonVSOutputPixelLighting cout = ComputeCommonVSOutputPixelLighting(vin.Position, vin.Normal); - SetCommonVSOutputParamsPixelLighting; - - vout.Diffuse = float4(1, 1, 1, DiffuseColor.a); - vout.TexCoord = vin.TexCoord; - - return vout; -} - - -// Vertex shader: pixel lighting, two bones. -VSOutputPixelLightingTx VSSkinnedPixelLightingTwoBones(VSInputNmTxWeights vin) -{ - VSOutputPixelLightingTx vout; - - Skin(vin, 2); - - CommonVSOutputPixelLighting cout = ComputeCommonVSOutputPixelLighting(vin.Position, vin.Normal); - SetCommonVSOutputParamsPixelLighting; - - vout.Diffuse = float4(1, 1, 1, DiffuseColor.a); - vout.TexCoord = vin.TexCoord; - - return vout; -} - - -// Vertex shader: pixel lighting, four bones. -VSOutputPixelLightingTx VSSkinnedPixelLightingFourBones(VSInputNmTxWeights vin) -{ - VSOutputPixelLightingTx vout; - - Skin(vin, 4); - - CommonVSOutputPixelLighting cout = ComputeCommonVSOutputPixelLighting(vin.Position, vin.Normal); - SetCommonVSOutputParamsPixelLighting; - - vout.Diffuse = float4(1, 1, 1, DiffuseColor.a); - vout.TexCoord = vin.TexCoord; - - return vout; -} - - -// Pixel shader: vertex lighting. -float4 PSSkinnedVertexLighting(PSInputTx pin) : SV_Target0 -{ - float4 color = SAMPLE_TEXTURE(Texture, pin.TexCoord) * pin.Diffuse; - - AddSpecular(color, pin.Specular.rgb); - ApplyFog(color, pin.Specular.w); - - return color; -} - - -// Pixel shader: vertex lighting, no fog. -float4 PSSkinnedVertexLightingNoFog(PSInputTx pin) : SV_Target0 -{ - float4 color = SAMPLE_TEXTURE(Texture, pin.TexCoord) * pin.Diffuse; - - AddSpecular(color, pin.Specular.rgb); - - return color; -} - - -// Pixel shader: pixel lighting. -float4 PSSkinnedPixelLighting(PSInputPixelLightingTx pin) : SV_Target0 -{ - float4 color = SAMPLE_TEXTURE(Texture, pin.TexCoord) * pin.Diffuse; - - float3 eyeVector = normalize(EyePosition - pin.PositionWS.xyz); - float3 worldNormal = normalize(pin.NormalWS); - - ColorPair lightResult = ComputeLights(eyeVector, worldNormal, 3); - - color.rgb *= lightResult.Diffuse; - - AddSpecular(color, lightResult.Specular); - ApplyFog(color, pin.PositionWS.w); - - return color; -} - - -VertexShader VSArray[9] = -{ - compile vs_2_0 VSSkinnedVertexLightingOneBone(), - compile vs_2_0 VSSkinnedVertexLightingTwoBones(), - compile vs_2_0 VSSkinnedVertexLightingFourBones(), - - compile vs_2_0 VSSkinnedOneLightOneBone(), - compile vs_2_0 VSSkinnedOneLightTwoBones(), - compile vs_2_0 VSSkinnedOneLightFourBones(), - - compile vs_2_0 VSSkinnedPixelLightingOneBone(), - compile vs_2_0 VSSkinnedPixelLightingTwoBones(), - compile vs_2_0 VSSkinnedPixelLightingFourBones(), -}; - - -int VSIndices[18] = -{ - 0, // vertex lighting, one bone - 0, // vertex lighting, one bone, no fog - 1, // vertex lighting, two bones - 1, // vertex lighting, two bones, no fog - 2, // vertex lighting, four bones - 2, // vertex lighting, four bones, no fog - - 3, // one light, one bone - 3, // one light, one bone, no fog - 4, // one light, two bones - 4, // one light, two bones, no fog - 5, // one light, four bones - 5, // one light, four bones, no fog - - 6, // pixel lighting, one bone - 6, // pixel lighting, one bone, no fog - 7, // pixel lighting, two bones - 7, // pixel lighting, two bones, no fog - 8, // pixel lighting, four bones - 8, // pixel lighting, four bones, no fog -}; - - -PixelShader PSArray[3] = -{ - compile ps_2_0 PSSkinnedVertexLighting(), - compile ps_2_0 PSSkinnedVertexLightingNoFog(), - compile ps_2_0 PSSkinnedPixelLighting(), -}; - - -int PSIndices[18] = -{ - 0, // vertex lighting, one bone - 1, // vertex lighting, one bone, no fog - 0, // vertex lighting, two bones - 1, // vertex lighting, two bones, no fog - 0, // vertex lighting, four bones - 1, // vertex lighting, four bones, no fog - - 0, // one light, one bone - 1, // one light, one bone, no fog - 0, // one light, two bones - 1, // one light, two bones, no fog - 0, // one light, four bones - 1, // one light, four bones, no fog - - 2, // pixel lighting, one bone - 2, // pixel lighting, one bone, no fog - 2, // pixel lighting, two bones - 2, // pixel lighting, two bones, no fog - 2, // pixel lighting, four bones - 2, // pixel lighting, four bones, no fog -}; - - -int ShaderIndex = 0; - - -Technique SkinnedEffect -{ - Pass - { - VertexShader = (VSArray[VSIndices[ShaderIndex]]); - PixelShader = (PSArray[PSIndices[ShaderIndex]]); - } -} diff --git a/StockEffects/SpriteEffect.fx b/StockEffects/SpriteEffect.fx deleted file mode 100644 index b1abf877..00000000 --- a/StockEffects/SpriteEffect.fx +++ /dev/null @@ -1,44 +0,0 @@ -//----------------------------------------------------------------------------- -// SpriteEffect.fx -// -// Microsoft XNA Community Game Platform -// Copyright (C) Microsoft Corporation. All rights reserved. -//----------------------------------------------------------------------------- - -#include "Macros.fxh" - - -DECLARE_TEXTURE(Texture, 0); - - -BEGIN_CONSTANTS -MATRIX_CONSTANTS - - float4x4 MatrixTransform _vs(c0) _cb(c0); - -END_CONSTANTS - - -void SpriteVertexShader(inout float4 color : COLOR0, - inout float2 texCoord : TEXCOORD0, - inout float4 position : SV_Position) -{ - position = mul(position, MatrixTransform); -} - - -float4 SpritePixelShader(float4 color : COLOR0, - float2 texCoord : TEXCOORD0) : SV_Target0 -{ - return SAMPLE_TEXTURE(Texture, texCoord) * color; -} - - -technique SpriteBatch -{ - pass - { - VertexShader = compile vs_2_0 SpriteVertexShader(); - PixelShader = compile ps_2_0 SpritePixelShader(); - } -} diff --git a/StockEffects/StockEffects.contentproj b/StockEffects/StockEffects.contentproj deleted file mode 100644 index 87efbc73..00000000 --- a/StockEffects/StockEffects.contentproj +++ /dev/null @@ -1,73 +0,0 @@ - - - - {B250043B-C41D-4E56-A477-0664D2E47054} - {96E2B04D-8817-42c6-938A-82C39BA4D311};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - Debug - x86 - Library - Properties - v4.0 - v4.0 - bin\$(Platform)\$(Configuration) - - - StockEffects - - - - - - - - - - - - AlphaTestEffect - EffectImporter - EffectProcessor - - - - - BasicEffect - EffectImporter - EffectProcessor - - - DualTextureEffect - EffectImporter - EffectProcessor - - - EnvironmentMapEffect - EffectImporter - EffectProcessor - - - SkinnedEffect - EffectImporter - EffectProcessor - - - SpriteEffect - EffectImporter - EffectProcessor - - - - - {ECBF60CB-1CF0-4F92-8963-E73115B04B43} - ANX.Framework.ContentPipeline - - - - - \ No newline at end of file diff --git a/StockEffects/Structures.fxh b/StockEffects/Structures.fxh deleted file mode 100644 index a432a265..00000000 --- a/StockEffects/Structures.fxh +++ /dev/null @@ -1,226 +0,0 @@ -//----------------------------------------------------------------------------- -// Structurs.fxh -// -// Microsoft XNA Community Game Platform -// Copyright (C) Microsoft Corporation. All rights reserved. -//----------------------------------------------------------------------------- - - -// Vertex shader input structures. - -struct VSInput -{ - float4 Position : SV_Position; -}; - -struct VSInputVc -{ - float4 Position : SV_Position; - float4 Color : COLOR; -}; - -struct VSInputTx -{ - float4 Position : SV_Position; - float2 TexCoord : TEXCOORD0; -}; - -struct VSInputTxVc -{ - float4 Position : SV_Position; - float2 TexCoord : TEXCOORD0; - float4 Color : COLOR; -}; - -struct VSInputNm -{ - float4 Position : SV_Position; - float3 Normal : NORMAL; -}; - -struct VSInputNmVc -{ - float4 Position : SV_Position; - float3 Normal : NORMAL; - float4 Color : COLOR; -}; - -struct VSInputNmTx -{ - float4 Position : SV_Position; - float3 Normal : NORMAL; - float2 TexCoord : TEXCOORD0; -}; - -struct VSInputNmTxVc -{ - float4 Position : SV_Position; - float3 Normal : NORMAL; - float2 TexCoord : TEXCOORD0; - float4 Color : COLOR; -}; - -struct VSInputTx2 -{ - float4 Position : SV_Position; - float2 TexCoord : TEXCOORD0; - float2 TexCoord2 : TEXCOORD1; -}; - -struct VSInputTx2Vc -{ - float4 Position : SV_Position; - float2 TexCoord : TEXCOORD0; - float2 TexCoord2 : TEXCOORD1; - float4 Color : COLOR; -}; - -struct VSInputNmTxWeights -{ - float4 Position : SV_Position; - float3 Normal : NORMAL; - float2 TexCoord : TEXCOORD0; - int4 Indices : BLENDINDICES0; - float4 Weights : BLENDWEIGHT0; -}; - - - -// Vertex shader output structures. - -struct VSOutput -{ - float4 Diffuse : COLOR0; - float4 Specular : COLOR1; - float4 PositionPS : SV_Position; -}; - -struct VSOutputNoFog -{ - float4 Diffuse : COLOR0; - float4 PositionPS : SV_Position; -}; - -struct VSOutputTx -{ - float4 Diffuse : COLOR0; - float4 Specular : COLOR1; - float2 TexCoord : TEXCOORD0; - float4 PositionPS : SV_Position; -}; - -struct VSOutputTxNoFog -{ - float4 Diffuse : COLOR0; - float2 TexCoord : TEXCOORD0; - float4 PositionPS : SV_Position; -}; - -struct VSOutputPixelLighting -{ - float4 PositionWS : TEXCOORD0; - float3 NormalWS : TEXCOORD1; - float4 Diffuse : COLOR0; - float4 PositionPS : SV_Position; -}; - -struct VSOutputPixelLightingTx -{ - float2 TexCoord : TEXCOORD0; - float4 PositionWS : TEXCOORD1; - float3 NormalWS : TEXCOORD2; - float4 Diffuse : COLOR0; - float4 PositionPS : SV_Position; -}; - -struct VSOutputTx2 -{ - float4 Diffuse : COLOR0; - float4 Specular : COLOR1; - float2 TexCoord : TEXCOORD0; - float2 TexCoord2 : TEXCOORD1; - float4 PositionPS : SV_Position; -}; - -struct VSOutputTx2NoFog -{ - float4 Diffuse : COLOR0; - float2 TexCoord : TEXCOORD0; - float2 TexCoord2 : TEXCOORD1; - float4 PositionPS : SV_Position; -}; - -struct VSOutputTxEnvMap -{ - float4 Diffuse : COLOR0; - float4 Specular : COLOR1; - float2 TexCoord : TEXCOORD0; - float3 EnvCoord : TEXCOORD1; - float4 PositionPS : SV_Position; -}; - - - -// Pixel shader input structures. - -struct PSInput -{ - float4 Diffuse : COLOR0; - float4 Specular : COLOR1; -}; - -struct PSInputNoFog -{ - float4 Diffuse : COLOR0; -}; - -struct PSInputTx -{ - float4 Diffuse : COLOR0; - float4 Specular : COLOR1; - float2 TexCoord : TEXCOORD0; -}; - -struct PSInputTxNoFog -{ - float4 Diffuse : COLOR0; - float2 TexCoord : TEXCOORD0; -}; - -struct PSInputPixelLighting -{ - float4 PositionWS : TEXCOORD0; - float3 NormalWS : TEXCOORD1; - float4 Diffuse : COLOR0; -}; - -struct PSInputPixelLightingTx -{ - float2 TexCoord : TEXCOORD0; - float4 PositionWS : TEXCOORD1; - float3 NormalWS : TEXCOORD2; - float4 Diffuse : COLOR0; -}; - -struct PSInputTx2 -{ - float4 Diffuse : COLOR0; - float4 Specular : COLOR1; - float2 TexCoord : TEXCOORD0; - float2 TexCoord2 : TEXCOORD1; -}; - -struct PSInputTx2NoFog -{ - float4 Diffuse : COLOR0; - float2 TexCoord : TEXCOORD0; - float2 TexCoord2 : TEXCOORD1; -}; - -struct PSInputTxEnvMap -{ - float4 Diffuse : COLOR0; - float4 Specular : COLOR1; - float2 TexCoord : TEXCOORD0; - float3 EnvCoord : TEXCOORD1; -}; diff --git a/Tools/ANX.Framework.Tools.sln b/Tools/ANX.Framework.Tools.sln new file mode 100644 index 00000000..15891076 --- /dev/null +++ b/Tools/ANX.Framework.Tools.sln @@ -0,0 +1,32 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ANXStatusComparer", "ANXStatusComparer\ANXStatusComparer.csproj", "{9D8DC781-2E0D-4348-BAD9-745F91428A3F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StockShaderCodeGenerator", "StockShaderCodeGenerator\StockShaderCodeGenerator.csproj", "{D73E5FF4-AE88-4637-8159-120FBDA564BF}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XNAToANXConverter", "XNAToANXConverter\XNAToANXConverter.csproj", "{B5209A04-B2F8-4033-A5E7-545BE771214C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x86 = Debug|x86 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9D8DC781-2E0D-4348-BAD9-745F91428A3F}.Debug|x86.ActiveCfg = Debug|x86 + {9D8DC781-2E0D-4348-BAD9-745F91428A3F}.Debug|x86.Build.0 = Debug|x86 + {9D8DC781-2E0D-4348-BAD9-745F91428A3F}.Release|x86.ActiveCfg = Release|x86 + {9D8DC781-2E0D-4348-BAD9-745F91428A3F}.Release|x86.Build.0 = Release|x86 + {D73E5FF4-AE88-4637-8159-120FBDA564BF}.Debug|x86.ActiveCfg = Debug|x86 + {D73E5FF4-AE88-4637-8159-120FBDA564BF}.Debug|x86.Build.0 = Debug|x86 + {D73E5FF4-AE88-4637-8159-120FBDA564BF}.Release|x86.ActiveCfg = Release|x86 + {D73E5FF4-AE88-4637-8159-120FBDA564BF}.Release|x86.Build.0 = Release|x86 + {B5209A04-B2F8-4033-A5E7-545BE771214C}.Debug|x86.ActiveCfg = Debug|x86 + {B5209A04-B2F8-4033-A5E7-545BE771214C}.Debug|x86.Build.0 = Debug|x86 + {B5209A04-B2F8-4033-A5E7-545BE771214C}.Release|x86.ActiveCfg = Release|x86 + {B5209A04-B2F8-4033-A5E7-545BE771214C}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal