Bug is fixed, but appears to have broken vision underwater. Notes:

+ basically fixed by darkening the colour of water such that it is
darker than refracted terrain
+ also disabled sunlight scattering at night. This may actually be
desirable, but given there is no visible moon it seems unlikely to make
much sense, and blends a lot of green into the water colour appearing
luminescent at night
deque
Fil Krynicki 11 years ago
parent 013916fca3
commit cfea7736d9

@ -35,7 +35,7 @@ namespace MWRender
vp->setShadowsEnabled(false);
vp->setVisibilityMask(RV_Actors + RV_Misc + RV_Statics + RV_StaticsSmall + RV_Terrain + RV_Sky);
vp->setMaterialScheme("water_refraction");
vp->setBackgroundColour (Ogre::ColourValue(0.18039, 0.23137, 0.25490));
vp->setBackgroundColour (Ogre::ColourValue(0.090195, 0.115685, 0.12745));
mRenderTarget->setAutoUpdated(true);
mRenderTarget->addListener(this);
}

@ -522,9 +522,10 @@ void RenderingManager::applyFog (bool underwater)
}
else
{
mRendering.getScene()->setFog (FOG_LINEAR, Ogre::ColourValue(0.18039, 0.23137, 0.25490), 0, 0, 1000);
mRendering.getViewport()->setBackgroundColour (Ogre::ColourValue(0.18039, 0.23137, 0.25490));
mWater->setViewportBackground (Ogre::ColourValue(0.18039, 0.23137, 0.25490));
//Ogre::ColourValue clv(0.090195, 0.115685, 0.12745);
mRendering.getScene()->setFog (FOG_LINEAR, Ogre::ColourValue(clv));
mRendering.getViewport()->setBackgroundColour (Ogre::ColourValue(clv));
mWater->setViewportBackground (Ogre::ColourValue(clv));
}
}
@ -631,12 +632,12 @@ void RenderingManager::sunDisable(bool real)
}
}
void RenderingManager::setSunDirection(const Ogre::Vector3& direction)
void RenderingManager::setSunDirection(const Ogre::Vector3& direction, bool is_moon)
{
// direction * -1 (because 'direction' is camera to sun vector and not sun to camera),
if (mSun) mSun->setDirection(Vector3(-direction.x, -direction.y, -direction.z));
mSkyManager->setSunDirection(direction);
mSkyManager->setSunDirection(direction, is_moon);
}
void RenderingManager::setGlare(bool glare)

@ -145,7 +145,7 @@ public:
void setAmbientColour(const Ogre::ColourValue& colour);
void setSunColour(const Ogre::ColourValue& colour);
void setSunDirection(const Ogre::Vector3& direction);
void setSunDirection(const Ogre::Vector3& direction, bool is_moon);
void sunEnable(bool real); ///< @param real whether or not to really disable the sunlight (otherwise just set diffuse to 0)
void sunDisable(bool real);

@ -546,14 +546,14 @@ void SkyManager::sunDisable()
mSunEnabled = false;
}
void SkyManager::setSunDirection(const Vector3& direction)
void SkyManager::setSunDirection(const Vector3& direction, bool is_moon)
{
if (!mCreated) return;
mSun->setPosition(direction);
mSunGlare->setPosition(direction);
float height = direction.z;
float fade = ( height > 0.5) ? 1.0 : height * 2;
float fade = is_moon ? 0.0 : (( height > 0.5) ? 1.0 : height * 2);
sh::Factory::getInstance ().setSharedParameter ("waterSunFade_sunHeight", sh::makeProperty<sh::Vector2>(new sh::Vector2(fade, height)));
}

@ -148,7 +148,7 @@ namespace MWRender
void sunDisable();
void setSunDirection(const Ogre::Vector3& direction);
void setSunDirection(const Ogre::Vector3& direction, bool is_moon);
void setMasserDirection(const Ogre::Vector3& direction);

@ -378,11 +378,13 @@ void WeatherManager::update(float duration)
int facing = (mHour > 13.f) ? 1 : -1;
bool sun_is_moon = mHour >= mNightStart || mHour <= mSunriseTime;
Vector3 final(
(height - 1) * facing,
(height - 1) * facing,
height);
mRendering->setSunDirection(final);
mRendering->setSunDirection(final, sun_is_moon);
/*
* TODO: import separated fadeInStart/Finish, fadeOutStart/Finish

@ -1,4 +1,4 @@
#define UNDERWATER_COLOUR float3(0.18039, 0.23137, 0.25490)
#define UNDERWATER_COLOUR float3(0.090195, 0.115685, 0.12745)
#define VISIBILITY 1000.0 // how far you can look through water

@ -340,7 +340,7 @@
#if REFRACTION
float3 refraction = shSample(refractionMap, (screenCoords-(normal.xy*REFR_BUMP))*1.0).rgb;
// brighten up the refraction underwater
refraction = (cameraPos.z < 0) ? shSaturate(refraction * 1.5) : refraction;
#endif
@ -351,7 +351,7 @@
#if REFRACTION
shOutputColour(0).xyz = shLerp( shLerp(refraction, scatterColour, lightScatter), reflection, fresnel) + specular * sunSpecular.xyz;
#else
shOutputColour(0).xyz = shLerp(reflection, float3(0.18039, 0.23137, 0.25490), (1.0-fresnel)*0.5) + specular * sunSpecular.xyz;
shOutputColour(0).xyz = shLerp(reflection, float3(0.090195, 0.115685, 0.12745), (1.0-fresnel)*0.5) + specular * sunSpecular.xyz;
#endif
// fog
float fogValue = shSaturate((depthPassthrough - fogParams.y) * fogParams.w);

Loading…
Cancel
Save