All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
FogShaderIncludes.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include <string>
6 
7 // FogIntensities.xyz = {HeightFogIntensity, DistanceFogIntensity, FogDensityGlobal}
8 // FogRamp.xyzw = {fogValues.HeightFogMinAltitudeCameraRelative, fogValues.HeightFogMaxAltitudeCameraRelative, (fogValues.DistanceFogNear)^2, (fogValues.DistanceFogFar)^2};
9 
10 namespace Eegeo
11 {
12  namespace Rendering
13  {
14  namespace FogShaderIncludes
15  {
16  const std::string CameraRelativeModelOriginName = "CameraRelativeModelOrigin";
17  const std::string WorldUpName = "WorldUp";
18  const std::string FogIntensitiesName = "FogIntensities";
19  const std::string FogRampName = "FogRamp";
20  const std::string FogColourName = "FogColour";
21  }
22  }
23 }
24 
25 #define FOG_VERTEX_SHADER_UNIFORMS \
26 "uniform highp vec3 CameraRelativeModelOrigin;\n" \
27 "uniform lowp vec3 WorldUp;\n" \
28 "uniform lowp vec3 FogIntensities;\n" \
29 "uniform highp vec4 FogRamp;\n"
30 
31 #define FOG_VERTEX_SHADER_FUNCTIONS \
32 "lowp float CalcHeightFogDensity(highp vec3 vertexPos) {\n" \
33  "highp vec3 cameraRelativePos = CameraRelativeModelOrigin + vertexPos;\n" \
34  "highp vec2 rampParams = vec2(dot(cameraRelativePos, WorldUp), dot(cameraRelativePos, cameraRelativePos));\n" \
35  "lowp vec2 ramps = smoothstep(FogRamp.yz, FogRamp.xw, rampParams);\n" \
36  "lowp vec2 heightAndDistanceFogParams = vec2(ramps.x*ramps.x, ramps.y); \n" \
37  "return clamp(dot(heightAndDistanceFogParams, FogIntensities.xy), 0.0, 1.0); \n" \
38 "}\n"
39 
40 
41 #define FOG_FRAGMENT_SHADER_UNIFORMS \
42 "uniform lowp vec4 FogColour;\n"