MCPcopy Create free account
hub / github.com/ClassiCube/ClassiCube / UpdateFogNormal

Function UpdateFogNormal

src/EnvRenderer.c:99–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97}
98
99static void UpdateFogNormal(float fogDensity, PackedCol fogColor) {
100 float density;
101
102 if (fogDensity != 0.0f) {
103 Gfx_SetFogMode(FOG_EXP);
104 Gfx_SetFogDensity(fogDensity);
105 } else if (Env.ExpFog) {
106 Gfx_SetFogMode(FOG_EXP);
107 /* f = 1-z/end f = e^(-dz)
108 solve for f = 0.01 gives:
109 e^(-dz)=0.01 --> -dz=ln(0.01)
110 0.99=z/end --> z=end*0.99
111 therefore
112 d = -ln(0.01)/(end*0.99) */
113 #define LOG_001 -4.60517018598809f
114
115 density = -LOG_001 / (Game_ViewDistance * 0.99f);
116 Gfx_SetFogDensity(density);
117 } else {
118 Gfx_SetFogMode(FOG_LINEAR);
119 Gfx_SetFogEnd((float)Game_ViewDistance);
120 }
121 Gfx_SetFogCol(fogColor);
122 Game_SetViewDistance(Game_UserViewDistance);
123}
124
125void EnvRenderer_UpdateFog(void) {
126 float fogDensity;

Callers 1

EnvRenderer_UpdateFogFunction · 0.85

Calls 5

Game_SetViewDistanceFunction · 0.85
Gfx_SetFogModeFunction · 0.70
Gfx_SetFogDensityFunction · 0.70
Gfx_SetFogEndFunction · 0.70
Gfx_SetFogColFunction · 0.70

Tested by

no test coverage detected