//=================================================================== // Environment Diffuse Normal Specular LightMap Ambient Occlusion Shader // @author jboldiga // No dynamic lighting. Uses HDR lightmaps and fake specular lighting //=================================================================== #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 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; }; #ifdef _MAX_ // this is so that in max the channels match correctly int texcoord0 : Texcoord < int Texcoord = 0; int MapChannel = 1; string UIType = "None"; >; #endif float SpeedAndDirLR < string UIName = "Speed/Dir (-R/+L)"; string UIWidget = "Slider"; float UIMin = -10.0; float UIMax = 10.0; float UIStep = 0.01; > = -0.05; float SpeedAndDirUD < string UIName = "Speed/Dir (-U/+D)"; string UIWidget = "Slider"; float UIMin = -10.0; float UIMax = 10.0; float UIStep = 0.01; > = 1.0; float globalTime < string UIWidget = "Slider"; float UIMin = 0.0; float UIMax = 999.0; float UIStep = 0.01; string UIName = "Global Time (Engine Only)"; > = 1.0; float LowExposure < string UIWidget = "slider"; string UIName = "Low Exposure"; float UIMin = -100.0; float UIMax = 0.0; float UIStep = 0.5; > = -2.0; float HighExposure < string UIWidget = "slider"; string UIName = "High Exposure"; float UIMin = 0.0; float UIMax = 100.0; float UIStep = 0.5; > = 2.0; float Threshold < string UIWidget = "slider"; string UIName = "Threshold"; float UIMin = 0.0; float UIMax = 100.0; float UIStep = 0.1; > = 50.0f; // matrices float4x4 wvp : WorldViewProjection < string UIType = "None"; >; // input from application struct a2v { float4 position : POSITION; float2 texCoord0 : TEXCOORD0; }; // output to fragment program struct v2f { float4 position : POSITION; float2 texCoord0 : TEXCOORD0; }; //Vertex Shader v2f av(a2v In) { v2f Out = (v2f)0; Out.texCoord0 = In.texCoord0; //pass through texture coordinates from channel 1 Out.position = matmul(In.position, wvp); //transform vert position to homogeneous clip space return Out; } //Pixel Shader float4 af(v2f In) : COLOR { float scrollX = globalTime * SpeedAndDirLR; float scrollY = globalTime * SpeedAndDirUD; float2 uvs = In.texCoord0.xy; // offset the UVs. uvs.x = uvs.x + scrollX; uvs.y = uvs.y + scrollY; float4 diffuseTex = tex2D(diffuseTextureSampler, uvs); float3 lightMapHDR = CalculateLightMapHDR(diffuseTex.rgb, LowExposure, HighExposure, Threshold); return float4(lightMapHDR, 1.0f); } technique Complete { pass ambient { VertexShader = compile vs_3_0 av(); ZEnable = true; ZWriteEnable = true; CullMode = cw; ShadeMode = Gouraud; AlphaBlendEnable = false; AlphaTestEnable = false; PixelShader = compile ps_3_0 af(); } }