home *** CD-ROM | disk | FTP | other *** search
/ Programming an RTS Game with Direct3D / Programming an RTS Game with Direct3D.iso / Examples / Chapter 14 / Example 14.1 / Debug / Shaders / fire.ps < prev    next >
Encoding:
Text File  |  2006-06-23  |  1.2 KB  |  33 lines

  1. //////////////////////////////////////////////////////////////////////////
  2. //                                                                      //
  3. //                        Fire Pixelshader                              //
  4. //                                                                      //
  5. //                   Written by C. Granberg, 2006                       //
  6. //                                                                      //
  7. //////////////////////////////////////////////////////////////////////////
  8.  
  9. sampler fireTexture;
  10. sampler noiseTexture;
  11.  
  12. float4 Main(float2 UV         : TEXCOORD0, 
  13.             float2 UV_NOISE1  : TEXCOORD1,
  14.             float2 UV_NOISE2  : TEXCOORD2,
  15.             float2 UV_NOISE3  : TEXCOORD3,
  16.             float  mainAlpha  : TEXCOORD4) : COLOR
  17. {
  18.     //Sample noise pixels
  19.     float n1 = tex2D(noiseTexture, UV_NOISE1);
  20.     float n2 = tex2D(noiseTexture, UV_NOISE2);
  21.     float n3 = tex2D(noiseTexture, UV_NOISE3);
  22.  
  23.     //Sum up noise and perturb the x coordinate of the main UV
  24.     UV.x += (n1 + n2 + n3) * 0.1f - 0.05f;
  25.    
  26.     //Sample the diffuse texture
  27.     float4 c0 = tex2D(fireTexture, UV);
  28.  
  29.     //Multiply mainAlpha with this pixels alpha value
  30.     c0.a *= mainAlpha;
  31.  
  32.     return c0;
  33. }