home *** CD-ROM | disk | FTP | other *** search
- //--------------------------------------------------------------------------
- // TMShaders
- // Copyright (c) 2002 by Tools-Media Corp., All Right Reserved.
- // Programmer: Tima Tcvetkov
- //
- // fog.fx
- // Fog shaders
- //--------------------------------------------------------------------------
- #ifndef __FOG_FX__
- #define __FOG_FX__
-
- #define VOLUME_FOG_DISTANCE_SCALE vecFogParams.x
-
- // transform incoming vertex by world-view-projection matrix
- void PositionDistanceW( uniform int stage ){
- float4 vPos = mul(g_fVertexPosition, matProjection);
- g_fTexCoords[stage].x = vPos.w * VOLUME_FOG_DISTANCE_SCALE;
- g_fTexCoords[stage].y = 0;
- }
- void CalculateVolumeFogCoordinates( uniform int stage ){
- //float3 rWorldVertex = (float3)g_fWorldVertexPosition;
- //rWorldVertex[1] = 0.0;
- //float fDistance = length(vecEyePosition - rWorldVertex);
- //fDistance = dot(fDistance,fDistance);
- float fYDot = dot( vecEyePosition,g_fWorldVertexPosition);
- g_fTexCoords[stage].x = 1.0f;
- g_fTexCoords[stage].y = 1.0f - ( ( ( vecFogParams[0] - fYDot ) / vecFogParams[1] ) + ( vecFogParams[2] * 0.5f ) );
- }
-
- void CalculateProjectionFog( uniform int stage ){
- g_fTexCoords[stage].xy = g_fWorldViewVertexPosition.xz * vecFogParams[0].xx;
- g_fTexCoords[stage].y = 1.0f - g_fTexCoords[stage].y;
- g_fTexCoords[stage].x += 0.5f;
- }
- void CalculateProjectionFogMirrorOnce( uniform int stage ){
- g_fTexCoords[stage].xy = g_fWorldViewVertexPosition.xz * vecFogParams[0].xx;
- g_fTexCoords[stage].y = 1.0f - g_fTexCoords[stage].y;
- }
- #endif //__FOG_FX__