/*** Generated through Lumonix shaderFX by: scott in 3dsmax at: 6/12/2009 1:14:56 PM ***/ // This FX shader was built to support 3ds Max's standard shader compiler. texture NormalMap : NormalMap < string Name = "C:\\_project\\ChiliDogs\\Assets\\Characters\\Chuck_Lidell\\Textures\\Chuck_Lidell_skin_N.dds"; string UIName = "Normal Map"; string ResourceType = "2D"; >; sampler2D NormalMapSampler = sampler_state { Texture = ; MinFilter = LINEAR; MagFilter = LINEAR; MipFilter = LINEAR; AddressU = WRAP; AddressV = WRAP; }; float4x4 worldIT : WorldInverseTranspose < string UIType = "None"; >; // this function does the different types of light attenuation float attenuation_func(int lightattenType, float4 lightAttenuation, float3 lightVec) { float att = 1.0; return att; } // this function does the different types of cone angle float coneangle_func(int lightconeType, float lightHotspot, float lightFalloff, float3 lightVec, float3 lightDir) { float cone = 1.0; return cone; } /************** light info **************/ float3 light1Dir : Direction < string UIName = "Light 1 Direction"; string Object = "TargetLight"; string Space = "World"; int refID = 1; > = {100.0f, 100.0f, 100.0f}; float3 light1Pos : POSITION < string UIName = "Light 1 Position"; string Object = "PointLight"; string Space = "World"; int refID = 1; > = {100.0f, 100.0f, 100.0f}; float4 light1Color : LIGHTCOLOR = { 1.0f, 1.0f, 1.0f, 1.0f}; float4 light1Attenuation : LightAttenuation = { 20.0f, 30.0f, 0.0f, 100.0f}; float light1Hotspot : LightHotSpot = { 43.0f }; float light1Falloff : LightFallOff = { 45.0f }; #define light1Type 1 #define light1attenType 0 #define light1coneType 0 #define light1CastShadows false //---------------------------------- float4x4 wvp : WorldViewProjection < string UIType = "None"; >; float4x4 worldI : WorldInverse < string UIType = "None"; >; // create the light vector float3 lightVec_func(float3 worldSpacePos, float3 lightVector, float3x3 objTangentXf, int lightType) { float3 lightVec = mul(objTangentXf, (mul((lightVector - worldSpacePos), worldI).xyz)); return lightVec; } // input from application struct a2v { float4 position : POSITION; float2 texCoord : TEXCOORD0; float4 tangent : TANGENT; float4 binormal : BINORMAL; float4 normal : NORMAL; }; // output to fragment program struct v2f { float4 position : POSITION; float2 texCoord : TEXCOORD0; float3 worldTangent : TEXCOORD1; float3 worldBinormal : TEXCOORD2; float3 worldNormal : TEXCOORD3; }; // Ambient Pass Vertex Shader: v2f av(a2v In, uniform float3 lightPos, uniform int lightType, uniform float3 lightDir) { v2f Out = (v2f)0; Out.position = mul(In.position, wvp); //transform vert position to homogeneous clip space In.texCoord.y += 1.0f; //this fixes Max's V texcoord which is off by one Out.texCoord = In.texCoord; //pass through texture coordinates from channel 1 //this code was added by the World Space Transform Node Out.worldNormal = mul(In.normal, worldIT).xyz; //compute world space normal Out.worldBinormal = mul(In.binormal, worldIT).xyz; //compute world space binormal Out.worldTangent = mul(In.tangent, worldIT).xyz; //compute world space tangent return Out; } // Ambient Pass Pixel Shader: float4 af(v2f In, uniform float3 lightDir, uniform float4 lightColor, uniform float4 lightAttenuation, uniform float lightHotspot, uniform float lightFalloff, uniform int lightType, uniform int lightattenType, uniform int lightconeType, uniform bool lightCastShadows, uniform int shadowPassCount) : COLOR { float4 NormalMap = tex2D(NormalMapSampler, In.texCoord.xy); NormalMap.xyz = NormalMap.xyz * 2 - 1; //expand to -1 to 1 range NormalMap.rgb = normalize(NormalMap.rgb); //normalized the normal vector //this code was added by the World Space Transform Node float3 Nn = normalize(In.worldNormal); //input the vectors required for tangent to world space transform float3 Tn = normalize(In.worldTangent); float3 Bn = normalize(In.worldBinormal); float3 MathWorldXform_8404 = ( Nn * NormalMap.rgb.z ) + (NormalMap.rgb.x * Tn ) + ( NormalMap.rgb.y * -Bn); float3 input1 = MathWorldXform_8404; float4 ret = float4(input1, 1); return ret; } technique Complete { pass ambient { VertexShader = compile vs_3_0 av(light1Pos, light1Type, light1Dir); ZEnable = true; ZWriteEnable = true; CullMode = none; ShadeMode = Gouraud; AlphaBlendEnable = false; AlphaTestEnable = FALSE; PixelShader = compile ps_3_0 af(light1Dir, light1Color, light1Attenuation, light1Hotspot, light1Falloff, light1Type, light1attenType, light1coneType, light1CastShadows, 1); } }