//----------------------------------------------------------------------------- // Globals //----------------------------------------------------------------------------- float4x4 WorldView; float4x4 WorldViewProj; float4x4 Proj; float4x4 WorldViewIT; float fireTemperature; float3 mLightPos; float3 mCameraPos; float shimmerOffset; float motionBlur; //----------------------------------------------------------------------------- // Macro definition for filtered samplers //----------------------------------------------------------------------------- #define SAMPLER_LINEAR(g_samplerMap, g_txMap); \ sampler2D g_samplerMap = sampler_state { \ Texture = ; \ MinFilter = Linear; \ MagFilter = Linear; \ MipFilter = Linear; \ AddressU = WRAP; \ AddressV = WRAP; \ }; //----------------------------------------------------------------------------- // Macro definition for non-filtered samplers //----------------------------------------------------------------------------- #define SAMPLER_POINT(g_samplerMap, g_txMap); \ sampler2D g_samplerMap = sampler_state { \ Texture = ; \ MinFilter = Point; \ MagFilter = Point; \ MipFilter = Point; \ AddressU = WRAP; \ AddressV = WRAP; \ }; #define SAMPLER_LINEAR_CLAMP(g_samplerMap, g_txMap); \ sampler2D g_samplerMap = sampler_state { \ Texture = ; \ MinFilter = Linear; \ MagFilter = Linear; \ MipFilter = Linear; \ AddressU = CLAMP; \ AddressV = CLAMP; \ }; //----------------------------------------------------------------------------- // Textures and samplers //----------------------------------------------------------------------------- texture ColorMap; SAMPLER_LINEAR(ColorMapSampler, ColorMap); texture PlanckColors; SAMPLER_LINEAR(PlanckColorsSampler, PlanckColors); texture SceneTexture; SAMPLER_LINEAR_CLAMP(sceneSampler, SceneTexture); texture ParticleTexture; SAMPLER_LINEAR_CLAMP(ParticleColorSampler, ParticleTexture); texture HeatTexture; SAMPLER_LINEAR(ParticleHeatSampler, HeatTexture); //----------------------------------------------------------------------------- // Vertex shader input //----------------------------------------------------------------------------- struct VS_INPUT { float4 Position : POSITION; float4 Normal : NORMAL; float4 Binormal : BINORMAL; float4 Tangent : TANGENT; float2 TexCoord : TEXCOORD0; float4 Color : COLOR0; }; //----------------------------------------------------------------------------- // Vertex shader output when no shading needed //----------------------------------------------------------------------------- struct VS_OUTPUT_NOSHADING { float4 hPosition : POSITION; // in normalized device space float4 Color : COLOR0; float2 TexCoord :TEXCOORD; float3 cPosition:TEXCOORD1; }; //----------------------------------------------------------------------------- // Vertex shader when no shading needed //----------------------------------------------------------------------------- VS_OUTPUT_NOSHADING MainVS_NOSHADING( VS_INPUT IN ) { VS_OUTPUT_NOSHADING OUT; OUT.Color=IN.Color; OUT.TexCoord=IN.TexCoord; OUT.hPosition = mul(IN.Position, WorldViewProj); OUT.cPosition = mul(IN.Position, WorldView); return OUT; } //----------------------------------------------------------------------------- // Pixel shader when no shading needed //----------------------------------------------------------------------------- float4 MainPS_NOSHADING(VS_OUTPUT_NOSHADING IN):COLOR { float T0 = fireTemperature; float T = T0 + 0.2; float4 lightColor = tex2D(PlanckColorsSampler, float2(T, 0.5)); float4 Color = tex2D(ColorMapSampler,IN.TexCoord.xy) * lightColor; Color.a = length(IN.cPosition); return Color; } void MainVS_FullScreen(float4 position:POSITION, out float4 hPosition :POSITION, out float2 texCoord :TEXCOORD0) { hPosition = position; texCoord = position.xy * 0.5 + 0.5; texCoord.y = 1.0 - texCoord.y; } float4 MainPS_FullScreen(float4 position :POSITION, float2 texCoord :TEXCOORD0 ):COLOR { float2 Offset = tex2D(ParticleHeatSampler, texCoord).rg; Offset *= shimmerOffset; float4 s = tex2D(sceneSampler, texCoord + Offset); float4 p = tex2D(ParticleColorSampler, texCoord + Offset); float4 Color = s * (1 - p.a) + p; Color.a = motionBlur; return Color; } void MainVS_Phase(float4 position:POSITION, out float4 hPosition :POSITION, out float2 texCoord :TEXCOORD0) { hPosition = position; texCoord = position.xy; texCoord.y = - texCoord.y; } float4 MainPS_Phase(float4 position :POSITION, float2 texCoord :TEXCOORD0 ):COLOR { float phase = 1.0 / (4.0 * 3.14); phase *= 3.0 * (1.0 - texCoord.y * texCoord.y) * (1.0 + texCoord.x * texCoord.x); phase /= 2.0 * (2.0 + texCoord.y * texCoord.y) * pow(1 + texCoord.y * texCoord.y + 2.0 * texCoord.y * texCoord.x, 1.5); float4 Color = phase; return Color; } //----------------------------------------------------------------------------- // Macro definition for Techniques //----------------------------------------------------------------------------- #define Technique(name); \ technique name \ { \ pass p0 \ { \ VertexShader = compile vs_3_0 MainVS_##name(); \ PixelShader = compile ps_3_0 MainPS_##name(); \ } \ } \ //----------------------------------------------------------------------------- // Techniques //----------------------------------------------------------------------------- Technique( NOSHADING ); Technique( FullScreen ); Technique( Phase );