Fix fog disable (#24)
This commit is contained in:
parent
e3636b43bf
commit
5eab298e51
@ -1,6 +1,7 @@
|
||||
uniform sampler2D baseTexture;
|
||||
|
||||
uniform vec4 skyBgColor;
|
||||
uniform mediump float fogDistance;
|
||||
uniform vec3 eyePosition;
|
||||
|
||||
// The cameraOffset is the current center of the visible world.
|
||||
@ -89,9 +90,11 @@ void main(void)
|
||||
// As additions usually come for free following a multiplication, the new formula
|
||||
// should be more efficient as well.
|
||||
// Note: clarity = (1 - fogginess)
|
||||
float clarity = clamp(fogShadingParameter
|
||||
- fogShadingParameter * length(eyeVec), 0.0, 1.0);
|
||||
col = mix(skyBgColor, col, clarity);
|
||||
if (fogDistance > 0.0) { // -1.0 means disabled
|
||||
float clarity = clamp(fogShadingParameter
|
||||
- fogShadingParameter * length(eyeVec), 0.0, 1.0);
|
||||
col = mix(skyBgColor, col, clarity);
|
||||
}
|
||||
col = vec4(col.rgb, base.a);
|
||||
|
||||
gl_FragColor = col;
|
||||
|
@ -3,7 +3,7 @@ uniform mat4 mWorld;
|
||||
// Color of the light emitted by the sun.
|
||||
uniform vec3 dayLight;
|
||||
uniform vec3 eyePosition;
|
||||
uniform float fogDistance;
|
||||
uniform mediump float fogDistance;
|
||||
|
||||
// The cameraOffset is the current center of the visible world.
|
||||
uniform vec3 cameraOffset;
|
||||
|
@ -2,7 +2,7 @@ uniform sampler2D baseTexture;
|
||||
|
||||
uniform vec4 emissiveColor;
|
||||
uniform vec4 skyBgColor;
|
||||
uniform float fogDistance;
|
||||
uniform mediump float fogDistance;
|
||||
uniform vec3 eyePosition;
|
||||
|
||||
varying vec3 vNormal;
|
||||
@ -15,7 +15,7 @@ varying mediump vec2 varTexCoord;
|
||||
centroid varying vec2 varTexCoord;
|
||||
#endif
|
||||
|
||||
varying vec3 eyeVec;
|
||||
varying mediump vec3 eyeVec;
|
||||
varying float vIDiff;
|
||||
|
||||
const float e = 2.718281828459;
|
||||
@ -92,9 +92,11 @@ void main(void)
|
||||
// As additions usually come for free following a multiplication, the new formula
|
||||
// should be more efficient as well.
|
||||
// Note: clarity = (1 - fogginess)
|
||||
float clarity = clamp(fogShadingParameter
|
||||
- fogShadingParameter * length(eyeVec) / fogDistance, 0.0, 1.0);
|
||||
col = mix(skyBgColor, col, clarity);
|
||||
if (fogDistance > 0.0) { // -1.0 means disabled
|
||||
float clarity = clamp(fogShadingParameter
|
||||
- fogShadingParameter * length(eyeVec), 0.0, 1.0);
|
||||
col = mix(skyBgColor, col, clarity);
|
||||
}
|
||||
|
||||
gl_FragColor = vec4(col.rgb, base.a);
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
uniform mat4 mWorld;
|
||||
|
||||
uniform vec3 eyePosition;
|
||||
uniform mediump float fogDistance;
|
||||
|
||||
uniform float animationTimer;
|
||||
|
||||
varying vec3 vNormal;
|
||||
@ -13,7 +15,7 @@ varying mediump vec2 varTexCoord;
|
||||
centroid varying vec2 varTexCoord;
|
||||
#endif
|
||||
|
||||
varying vec3 eyeVec;
|
||||
varying mediump vec3 eyeVec;
|
||||
varying float vIDiff;
|
||||
|
||||
const float e = 2.718281828459;
|
||||
@ -37,7 +39,7 @@ void main(void)
|
||||
vPosition = gl_Position.xyz;
|
||||
vNormal = inVertexNormal;
|
||||
worldPosition = (mWorld * inVertexPosition).xyz;
|
||||
eyeVec = -(mWorldView * inVertexPosition).xyz;
|
||||
eyeVec = -(mWorldView * inVertexPosition).xyz / fogDistance;
|
||||
|
||||
#if (MATERIAL_TYPE == TILE_MATERIAL_PLAIN) || (MATERIAL_TYPE == TILE_MATERIAL_PLAIN_ALPHA)
|
||||
vIDiff = 1.0;
|
||||
|
@ -635,12 +635,11 @@ void Camera::updateViewingRange()
|
||||
m_cameranode->setNearValue(0.1f * BS);
|
||||
#endif
|
||||
|
||||
m_draw_control.wanted_range = std::fmin(adjustDist(viewing_range, getFovMax()), 4000);
|
||||
if (m_draw_control.range_all) {
|
||||
m_cameranode->setFarValue(100000.0);
|
||||
return;
|
||||
}
|
||||
m_cameranode->setFarValue((viewing_range < 2000) ? 2000 * BS : viewing_range * BS);
|
||||
if (m_draw_control.extended_range)
|
||||
viewing_range *= 3;
|
||||
viewing_range = std::fmin(adjustDist(viewing_range, getFovMax()), 4000);
|
||||
m_draw_control.wanted_range = viewing_range;
|
||||
m_cameranode->setFarValue(m_draw_control.range_all ? 100000.0 : std::max(2000.0f, viewing_range) * BS);
|
||||
}
|
||||
|
||||
void Camera::setDigging(s32 button)
|
||||
|
@ -29,6 +29,7 @@ struct MapDrawControl
|
||||
{
|
||||
// Overrides limits by drawing everything
|
||||
bool range_all = false;
|
||||
bool extended_range = false;
|
||||
// Wanted drawing range
|
||||
float wanted_range = 0.0f;
|
||||
// show a wire frame for debugging
|
||||
|
@ -486,7 +486,7 @@ public:
|
||||
m_sky_bg_color.set(bgcolorfa, services);
|
||||
|
||||
// Fog distance
|
||||
float fog_distance = 10000 * BS;
|
||||
float fog_distance = -1.0f; // sentinel for disabled fog
|
||||
|
||||
if (m_fog_enabled && !*m_force_fog_off)
|
||||
fog_distance = *m_fog_range;
|
||||
@ -617,6 +617,7 @@ struct GameRunData {
|
||||
bool dig_instantly;
|
||||
bool digging_blocked;
|
||||
bool reset_jump_timer;
|
||||
bool disable_fog;
|
||||
float nodig_delay_timer;
|
||||
float noplace_delay_timer;
|
||||
float dig_time;
|
||||
@ -1371,7 +1372,7 @@ bool Game::createClient(const GameStartData &start_data)
|
||||
}
|
||||
|
||||
auto *scsf = new GameGlobalShaderConstantSetterFactory(
|
||||
&m_flags.force_fog_off, &runData.fog_range, client);
|
||||
&runData.disable_fog, &runData.fog_range, client);
|
||||
shader_src->addShaderConstantSetterFactory(scsf);
|
||||
|
||||
// Update cached textures, meshes and materials
|
||||
@ -2399,14 +2400,15 @@ void Game::decreaseViewRange()
|
||||
|
||||
void Game::toggleFullViewRange()
|
||||
{
|
||||
draw_control->range_all = !draw_control->range_all;
|
||||
#if !defined(__ANDROID__) && !defined(__IOS__)
|
||||
draw_control->range_all = !draw_control->range_all;
|
||||
if (draw_control->range_all)
|
||||
m_game_ui->showTranslatedStatusText("Enabled unlimited viewing range");
|
||||
else
|
||||
m_game_ui->showTranslatedStatusText("Disabled unlimited viewing range");
|
||||
#else
|
||||
if (draw_control->range_all)
|
||||
draw_control->extended_range = !draw_control->extended_range;
|
||||
if (draw_control->extended_range)
|
||||
m_game_ui->showTranslatedStatusText("Enabled far viewing range");
|
||||
else
|
||||
m_game_ui->showTranslatedStatusText("Disabled far viewing range");
|
||||
@ -3833,15 +3835,8 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
|
||||
Fog range
|
||||
*/
|
||||
|
||||
if (draw_control->range_all) {
|
||||
#if !defined(__ANDROID__) && !defined(__IOS__)
|
||||
runData.fog_range = 100000 * BS;
|
||||
#else
|
||||
runData.fog_range = draw_control->wanted_range * BS * 4;
|
||||
#endif
|
||||
} else {
|
||||
runData.fog_range = draw_control->wanted_range * BS;
|
||||
}
|
||||
runData.disable_fog = !m_cache_enable_fog || m_flags.force_fog_off || draw_control->range_all;
|
||||
runData.fog_range = draw_control->wanted_range * BS;
|
||||
|
||||
/*
|
||||
Calculate general brightness
|
||||
@ -3926,27 +3921,16 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
|
||||
Fog
|
||||
*/
|
||||
|
||||
if (m_cache_enable_fog) {
|
||||
driver->setFog(
|
||||
sky->getBgColor(),
|
||||
video::EFT_FOG_LINEAR,
|
||||
runData.fog_range * m_cache_fog_start,
|
||||
runData.fog_range * 1.0,
|
||||
0.01,
|
||||
false, // pixel fog
|
||||
true // range fog
|
||||
);
|
||||
} else {
|
||||
driver->setFog(
|
||||
sky->getBgColor(),
|
||||
video::EFT_FOG_LINEAR,
|
||||
100000 * BS,
|
||||
110000 * BS,
|
||||
0.01f,
|
||||
false, // pixel fog
|
||||
false // range fog
|
||||
);
|
||||
}
|
||||
driver->setFog(
|
||||
sky->getBgColor(),
|
||||
video::EFT_FOG_LINEAR,
|
||||
runData.fog_range * m_cache_fog_start,
|
||||
runData.fog_range * 1.0,
|
||||
0.01,
|
||||
false, // pixel fog
|
||||
true // range fog
|
||||
);
|
||||
|
||||
|
||||
/*
|
||||
Get chat messages from client
|
||||
@ -4041,9 +4025,30 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
|
||||
} catch (SettingNotFoundException) {
|
||||
}
|
||||
#endif
|
||||
|
||||
video::SOverrideMaterial &mat = driver->getOverrideMaterial();
|
||||
#if IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR < 9
|
||||
mat.EnableFlags = 0;
|
||||
#else
|
||||
mat.reset();
|
||||
#endif
|
||||
if (runData.disable_fog) {
|
||||
mat.Material.FogEnable = false;
|
||||
mat.EnableFlags |= video::EMF_FOG_ENABLE;
|
||||
mat.EnablePasses = scene::ESNRP_SKY_BOX | scene::ESNRP_SOLID |
|
||||
scene::ESNRP_TRANSPARENT | scene::ESNRP_TRANSPARENT_EFFECT |
|
||||
scene::ESNRP_SHADOW;
|
||||
}
|
||||
|
||||
RenderingEngine::draw_scene(skycolor, m_game_ui->m_flags.show_hud,
|
||||
m_game_ui->m_flags.show_minimap, draw_wield_tool, draw_crosshair);
|
||||
|
||||
#if IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR < 9
|
||||
mat.EnableFlags = 0;
|
||||
#else
|
||||
mat.reset();
|
||||
#endif
|
||||
|
||||
/*
|
||||
Profiler graph
|
||||
*/
|
||||
|
@ -31,7 +31,7 @@ void RenderingCoreAnaglyph::setupMaterial(int color_mask)
|
||||
{
|
||||
video::SOverrideMaterial &mat = driver->getOverrideMaterial();
|
||||
mat.Material.ColorMask = color_mask;
|
||||
mat.EnableFlags = video::EMF_COLOR_MASK;
|
||||
mat.EnableFlags |= video::EMF_COLOR_MASK;
|
||||
mat.EnablePasses = scene::ESNRP_SKY_BOX | scene::ESNRP_SOLID |
|
||||
scene::ESNRP_TRANSPARENT | scene::ESNRP_TRANSPARENT_EFFECT |
|
||||
scene::ESNRP_SHADOW;
|
||||
|
Loading…
x
Reference in New Issue
Block a user