Skip to content

Commit

Permalink
Undo changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ibesora committed Nov 25, 2024
1 parent 2936003 commit 0c208b3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
5 changes: 1 addition & 4 deletions src/render/program/terrain_program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export type TerrainUniformsType = {
'u_fog_ground_blend_opacity': Uniform1f;
'u_horizon_color': UniformColor;
'u_horizon_fog_blend': Uniform1f;
'u_is_globe_mode': Uniform1f;
};

export type TerrainDepthUniformsType = {
Expand Down Expand Up @@ -60,7 +59,6 @@ const terrainUniforms = (context: Context, locations: UniformLocations): Terrain
'u_fog_ground_blend_opacity': new Uniform1f(context, locations.u_fog_ground_blend_opacity),
'u_horizon_color': new UniformColor(context, locations.u_horizon_color),
'u_horizon_fog_blend': new Uniform1f(context, locations.u_horizon_fog_blend),
'u_is_globe_mode': new Uniform1f(context, locations.u_is_globe_mode)
});

const terrainDepthUniforms = (context: Context, locations: UniformLocations): TerrainDepthUniformsType => ({
Expand All @@ -87,8 +85,7 @@ const terrainUniformValues = (
// Set opacity to 0 when in globe mode to disable fog
'u_fog_ground_blend_opacity': isGlobeMode ? 0 : (sky ? sky.calculateFogBlendOpacity(pitch) : 0),
'u_horizon_color': sky ? sky.properties.get('horizon-color') : Color.white,
'u_horizon_fog_blend': sky ? sky.properties.get('horizon-fog-blend') : 1,
'u_is_globe_mode': isGlobeMode ? 1 : 0
'u_horizon_fog_blend': sky ? sky.properties.get('horizon-fog-blend') : 1
});

const terrainDepthUniformValues = (
Expand Down
7 changes: 2 additions & 5 deletions src/shaders/terrain.fragment.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ uniform vec4 u_horizon_color;
uniform float u_fog_ground_blend;
uniform float u_fog_ground_blend_opacity;
uniform float u_horizon_fog_blend;
uniform bool u_is_globe_mode;

in vec2 v_texture_pos;
in float v_fog_depth;
Expand All @@ -22,11 +21,9 @@ vec4 linearToGamma(vec4 color) {
void main() {
vec4 surface_color = texture(u_texture, vec2(v_texture_pos.x, 1.0 - v_texture_pos.y));

// Skip fog blending in globe mode
if (!u_is_globe_mode && v_fog_depth > u_fog_ground_blend) {
// v_fog_depth should be in the range [0, 1] but it can be outside of this range due to precision issues
//float clamped_fog_depth = clamp(v_fog_depth, 0.0, 1.0);
//if (clamped_fog_depth > u_fog_ground_blend) {
float clamped_fog_depth = clamp(v_fog_depth, 0.0, 1.0);
if (clamped_fog_depth > u_fog_ground_blend) {
vec4 surface_color_linear = gammaToLinear(surface_color);
float blend_color = smoothstep(0.0, 1.0, max((clamped_fog_depth - u_horizon_fog_blend) / (1.0 - u_horizon_fog_blend), 0.0));
vec4 fog_horizon_color_linear = mix(gammaToLinear(u_fog_color), gammaToLinear(u_horizon_color), blend_color);
Expand Down

0 comments on commit 0c208b3

Please sign in to comment.