[3255] | 1 |
|
---|
| 2 | //-----------------------------------------------------------------------------
|
---|
| 3 | // Globals
|
---|
| 4 | //-----------------------------------------------------------------------------
|
---|
| 5 |
|
---|
| 6 | float4x4 WorldView;
|
---|
| 7 | float4x4 WorldViewProj;
|
---|
| 8 | float4x4 Proj;
|
---|
| 9 | float4x4 WorldViewIT;
|
---|
| 10 |
|
---|
| 11 | float fireTemperature;
|
---|
| 12 |
|
---|
| 13 | float3 mLightPos;
|
---|
| 14 | float3 mCameraPos;
|
---|
| 15 | float shimmerOffset;
|
---|
| 16 | float motionBlur;
|
---|
| 17 | //-----------------------------------------------------------------------------
|
---|
| 18 | // Macro definition for filtered samplers
|
---|
| 19 | //-----------------------------------------------------------------------------
|
---|
| 20 | #define SAMPLER_LINEAR(g_samplerMap, g_txMap); \
|
---|
| 21 | sampler2D g_samplerMap = sampler_state { \
|
---|
| 22 | Texture = <g_txMap>; \
|
---|
| 23 | MinFilter = Linear; \
|
---|
| 24 | MagFilter = Linear; \
|
---|
| 25 | MipFilter = Linear; \
|
---|
| 26 | AddressU = WRAP; \
|
---|
| 27 | AddressV = WRAP; \
|
---|
| 28 | };
|
---|
| 29 |
|
---|
| 30 | //-----------------------------------------------------------------------------
|
---|
| 31 | // Macro definition for non-filtered samplers
|
---|
| 32 | //-----------------------------------------------------------------------------
|
---|
| 33 | #define SAMPLER_POINT(g_samplerMap, g_txMap); \
|
---|
| 34 | sampler2D g_samplerMap = sampler_state { \
|
---|
| 35 | Texture = <g_txMap>; \
|
---|
| 36 | MinFilter = Point; \
|
---|
| 37 | MagFilter = Point; \
|
---|
| 38 | MipFilter = Point; \
|
---|
| 39 | AddressU = WRAP; \
|
---|
| 40 | AddressV = WRAP; \
|
---|
| 41 | };
|
---|
| 42 |
|
---|
| 43 | #define SAMPLER_LINEAR_CLAMP(g_samplerMap, g_txMap); \
|
---|
| 44 | sampler2D g_samplerMap = sampler_state { \
|
---|
| 45 | Texture = <g_txMap>; \
|
---|
| 46 | MinFilter = Linear; \
|
---|
| 47 | MagFilter = Linear; \
|
---|
| 48 | MipFilter = Linear; \
|
---|
| 49 | AddressU = CLAMP; \
|
---|
| 50 | AddressV = CLAMP; \
|
---|
| 51 | };
|
---|
| 52 |
|
---|
| 53 | //-----------------------------------------------------------------------------
|
---|
| 54 | // Textures and samplers
|
---|
| 55 | //-----------------------------------------------------------------------------
|
---|
| 56 | texture ColorMap;
|
---|
| 57 | SAMPLER_LINEAR(ColorMapSampler, ColorMap);
|
---|
| 58 | texture PlanckColors;
|
---|
| 59 | SAMPLER_LINEAR(PlanckColorsSampler, PlanckColors);
|
---|
| 60 |
|
---|
| 61 | texture SceneTexture;
|
---|
| 62 | SAMPLER_LINEAR_CLAMP(sceneSampler, SceneTexture);
|
---|
| 63 | texture ParticleTexture;
|
---|
| 64 | SAMPLER_LINEAR_CLAMP(ParticleColorSampler, ParticleTexture);
|
---|
| 65 | texture HeatTexture;
|
---|
| 66 | SAMPLER_LINEAR(ParticleHeatSampler, HeatTexture);
|
---|
| 67 |
|
---|
| 68 |
|
---|
| 69 | //-----------------------------------------------------------------------------
|
---|
| 70 | // Vertex shader input
|
---|
| 71 | //-----------------------------------------------------------------------------
|
---|
| 72 | struct VS_INPUT {
|
---|
| 73 | float4 Position : POSITION;
|
---|
| 74 | float4 Normal : NORMAL;
|
---|
| 75 | float4 Binormal : BINORMAL;
|
---|
| 76 | float4 Tangent : TANGENT;
|
---|
| 77 | float2 TexCoord : TEXCOORD0;
|
---|
| 78 | float4 Color : COLOR0;
|
---|
| 79 | };
|
---|
| 80 |
|
---|
| 81 | //-----------------------------------------------------------------------------
|
---|
| 82 | // Vertex shader output when no shading needed
|
---|
| 83 | //-----------------------------------------------------------------------------
|
---|
| 84 | struct VS_OUTPUT_NOSHADING {
|
---|
| 85 | float4 hPosition : POSITION; // in normalized device space
|
---|
| 86 | float4 Color : COLOR0;
|
---|
| 87 | float2 TexCoord :TEXCOORD;
|
---|
| 88 | float3 cPosition:TEXCOORD1;
|
---|
| 89 | };
|
---|
| 90 |
|
---|
| 91 | //-----------------------------------------------------------------------------
|
---|
| 92 | // Vertex shader when no shading needed
|
---|
| 93 | //-----------------------------------------------------------------------------
|
---|
| 94 | VS_OUTPUT_NOSHADING MainVS_NOSHADING( VS_INPUT IN )
|
---|
| 95 | {
|
---|
| 96 | VS_OUTPUT_NOSHADING OUT;
|
---|
| 97 | OUT.Color=IN.Color;
|
---|
| 98 | OUT.TexCoord=IN.TexCoord;
|
---|
| 99 |
|
---|
| 100 | OUT.hPosition = mul(IN.Position, WorldViewProj);
|
---|
| 101 | OUT.cPosition = mul(IN.Position, WorldView);
|
---|
| 102 | return OUT;
|
---|
| 103 | }
|
---|
| 104 |
|
---|
| 105 | //-----------------------------------------------------------------------------
|
---|
| 106 | // Pixel shader when no shading needed
|
---|
| 107 | //-----------------------------------------------------------------------------
|
---|
| 108 | float4 MainPS_NOSHADING(VS_OUTPUT_NOSHADING IN):COLOR
|
---|
| 109 | {
|
---|
| 110 | float T0 = fireTemperature;
|
---|
| 111 | float T = T0 + 0.2;
|
---|
| 112 | float4 lightColor = tex2D(PlanckColorsSampler, float2(T, 0.5));
|
---|
| 113 | float4 Color = tex2D(ColorMapSampler,IN.TexCoord.xy) * lightColor;
|
---|
| 114 |
|
---|
| 115 | Color.a = length(IN.cPosition);
|
---|
| 116 | return Color;
|
---|
| 117 | }
|
---|
| 118 |
|
---|
| 119 | void MainVS_FullScreen(float4 position:POSITION,
|
---|
| 120 | out float4 hPosition :POSITION,
|
---|
| 121 | out float2 texCoord :TEXCOORD0)
|
---|
| 122 | {
|
---|
| 123 | hPosition = position;
|
---|
| 124 | texCoord = position.xy * 0.5 + 0.5;
|
---|
| 125 | texCoord.y = 1.0 - texCoord.y;
|
---|
| 126 | }
|
---|
| 127 | float4 MainPS_FullScreen(float4 position :POSITION,
|
---|
| 128 | float2 texCoord :TEXCOORD0
|
---|
| 129 | ):COLOR
|
---|
| 130 | {
|
---|
| 131 | float2 Offset = tex2D(ParticleHeatSampler, texCoord).rg;
|
---|
| 132 | Offset *= shimmerOffset;
|
---|
| 133 | float4 s = tex2D(sceneSampler, texCoord + Offset);
|
---|
| 134 | float4 p = tex2D(ParticleColorSampler, texCoord + Offset);
|
---|
| 135 | float4 Color = s * (1 - p.a) + p;
|
---|
| 136 | Color.a = motionBlur;
|
---|
| 137 | return Color;
|
---|
| 138 | }
|
---|
| 139 |
|
---|
| 140 | void MainVS_Phase(float4 position:POSITION,
|
---|
| 141 | out float4 hPosition :POSITION,
|
---|
| 142 | out float2 texCoord :TEXCOORD0)
|
---|
| 143 | {
|
---|
| 144 | hPosition = position;
|
---|
| 145 | texCoord = position.xy;
|
---|
| 146 | texCoord.y = - texCoord.y;
|
---|
| 147 | }
|
---|
| 148 |
|
---|
| 149 | float4 MainPS_Phase(float4 position :POSITION,
|
---|
| 150 | float2 texCoord :TEXCOORD0
|
---|
| 151 | ):COLOR
|
---|
| 152 | {
|
---|
| 153 | float phase = 1.0 / (4.0 * 3.14);
|
---|
| 154 | phase *= 3.0 * (1.0 - texCoord.y * texCoord.y) * (1.0 + texCoord.x * texCoord.x);
|
---|
| 155 | phase /= 2.0 * (2.0 + texCoord.y * texCoord.y)
|
---|
| 156 | * pow(1 + texCoord.y * texCoord.y + 2.0 * texCoord.y * texCoord.x, 1.5);
|
---|
| 157 |
|
---|
| 158 | float4 Color = phase;
|
---|
| 159 | return Color;
|
---|
| 160 | }
|
---|
| 161 |
|
---|
| 162 |
|
---|
| 163 | //-----------------------------------------------------------------------------
|
---|
| 164 | // Macro definition for Techniques
|
---|
| 165 | //-----------------------------------------------------------------------------
|
---|
| 166 | #define Technique(name); \
|
---|
| 167 | technique name \
|
---|
| 168 | { \
|
---|
| 169 | pass p0 \
|
---|
| 170 | { \
|
---|
| 171 | VertexShader = compile vs_3_0 MainVS_##name(); \
|
---|
| 172 | PixelShader = compile ps_3_0 MainPS_##name(); \
|
---|
| 173 | } \
|
---|
| 174 | } \
|
---|
| 175 |
|
---|
| 176 | //-----------------------------------------------------------------------------
|
---|
| 177 | // Techniques
|
---|
| 178 | //-----------------------------------------------------------------------------
|
---|
| 179 | Technique( NOSHADING );
|
---|
| 180 | Technique( FullScreen );
|
---|
| 181 | Technique( Phase );
|
---|