home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2005 April / Gamestar_72_2005-04_dvd.iso / Dema / Liquidator / Liquidator.tma / data / renderer / fog.fx < prev    next >
Text File  |  2004-12-13  |  2KB  |  39 lines

  1. //--------------------------------------------------------------------------
  2. //  TMShaders
  3. //  Copyright (c) 2002 by Tools-Media Corp., All Right Reserved.
  4. //  Programmer: Tima Tcvetkov
  5. //
  6. //  fog.fx
  7. //  Fog shaders
  8. //--------------------------------------------------------------------------
  9. #ifndef __FOG_FX__
  10. #define __FOG_FX__
  11.  
  12. #define VOLUME_FOG_DISTANCE_SCALE vecFogParams.x
  13.  
  14. // transform incoming vertex by world-view-projection matrix
  15. void PositionDistanceW( uniform int stage ){
  16.   float4 vPos = mul(g_fVertexPosition, matProjection);
  17.   g_fTexCoords[stage].x = vPos.w * VOLUME_FOG_DISTANCE_SCALE;
  18.   g_fTexCoords[stage].y = 0;
  19. }
  20. void CalculateVolumeFogCoordinates( uniform int stage ){
  21.   //float3 rWorldVertex = (float3)g_fWorldVertexPosition;
  22.   //rWorldVertex[1] = 0.0;
  23.   //float fDistance = length(vecEyePosition -  rWorldVertex);
  24.   //fDistance = dot(fDistance,fDistance);
  25.   float fYDot = dot( vecEyePosition,g_fWorldVertexPosition);
  26.   g_fTexCoords[stage].x =  1.0f;
  27.   g_fTexCoords[stage].y =  1.0f - ( ( ( vecFogParams[0] - fYDot ) / vecFogParams[1] ) + ( vecFogParams[2] * 0.5f ) ); 
  28. }
  29.  
  30. void CalculateProjectionFog( uniform int stage ){
  31.   g_fTexCoords[stage].xy = g_fWorldViewVertexPosition.xz * vecFogParams[0].xx;      
  32.   g_fTexCoords[stage].y  = 1.0f - g_fTexCoords[stage].y; 
  33.   g_fTexCoords[stage].x += 0.5f;
  34. }
  35. void CalculateProjectionFogMirrorOnce( uniform int stage ){
  36.   g_fTexCoords[stage].xy = g_fWorldViewVertexPosition.xz * vecFogParams[0].xx;    
  37.   g_fTexCoords[stage].y  = 1.0f - g_fTexCoords[stage].y; 
  38. }
  39. #endif //__FOG_FX__