forked from mirror/openmw-tes3mp
more or less fixed the sky for normal viewing angles, still disappears at a certain height though
This commit is contained in:
parent
a41eee9a72
commit
393530e671
5 changed files with 31 additions and 18 deletions
|
@ -810,7 +810,9 @@ void SkyManager::setWeather(const MWWorld::WeatherResult& weather)
|
|||
strength = 1.f;
|
||||
|
||||
mSunGlare->setVisibility(weather.mGlareView * mGlareFade * strength);
|
||||
mSun->setVisibility(weather.mGlareView);
|
||||
|
||||
if (strength < 0.4) strength = 0.4;
|
||||
mSun->setVisibility(weather.mGlareView * strength);
|
||||
|
||||
mAtmosphereNight->setVisible(weather.mNight && mEnabled);
|
||||
}
|
||||
|
@ -923,3 +925,8 @@ void SkyManager::resetSkyPosition()
|
|||
{
|
||||
mRootNode->setPosition(0,0,0);
|
||||
}
|
||||
|
||||
void SkyManager::scaleSky(float scale)
|
||||
{
|
||||
mRootNode->setScale(scale, scale, scale);
|
||||
}
|
||||
|
|
|
@ -170,6 +170,7 @@ namespace MWRender
|
|||
|
||||
void setSkyPosition(const Ogre::Vector3& position);
|
||||
void resetSkyPosition();
|
||||
void scaleSky(float scale);
|
||||
|
||||
private:
|
||||
bool mCreated;
|
||||
|
|
|
@ -141,15 +141,16 @@ void Water::preRenderTargetUpdate(const RenderTargetEvent& evt)
|
|||
{
|
||||
mWater->setVisible(false);
|
||||
|
||||
mOldCameraFarClip = mCamera->getFarClipDistance();
|
||||
if (mReflectDistance != 0)
|
||||
mCamera->setFarClipDistance(mReflectDistance);
|
||||
//mOldCameraFarClip = mCamera->getFarClipDistance();
|
||||
//if (mReflectDistance != 0)
|
||||
// mCamera->setFarClipDistance(mReflectDistance);
|
||||
|
||||
if (evt.source == mReflectionTarget)
|
||||
{
|
||||
Vector3 pos = mCamera->getRealPosition();
|
||||
pos.y = mTop*2 - pos.y;
|
||||
mSky->setSkyPosition(pos);
|
||||
mSky->scaleSky(mCamera->getFarClipDistance() / 1000.f);
|
||||
mCamera->enableCustomNearClipPlane(Plane(Vector3::UNIT_Y, mTop));
|
||||
mCamera->enableReflection(Plane(Vector3::UNIT_Y, mTop));
|
||||
}
|
||||
|
@ -159,11 +160,12 @@ void Water::postRenderTargetUpdate(const RenderTargetEvent& evt)
|
|||
{
|
||||
mWater->setVisible(true);
|
||||
|
||||
mCamera->setFarClipDistance(mOldCameraFarClip);
|
||||
//mCamera->setFarClipDistance(mOldCameraFarClip);
|
||||
|
||||
if (evt.source == mReflectionTarget)
|
||||
{
|
||||
mSky->resetSkyPosition();
|
||||
mSky->scaleSky(1);
|
||||
mCamera->disableReflection();
|
||||
mCamera->disableCustomNearClipPlane();
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace MWRender {
|
|||
class SkyManager;
|
||||
|
||||
/// Water rendering
|
||||
class Water : Ogre::RenderTargetListener
|
||||
class Water : public Ogre::RenderTargetListener
|
||||
{
|
||||
static const int CELL_SIZE = 8192;
|
||||
Ogre::Camera *mCamera;
|
||||
|
|
|
@ -54,6 +54,9 @@ void main_fp
|
|||
float2 screenCoords = iScreenCoords.xy / iScreenCoords.z;
|
||||
screenCoords.y = (1-saturate(renderTargetFlipping))+renderTargetFlipping*screenCoords.y;
|
||||
|
||||
// No need for transparency since we are using a refraction map
|
||||
oColor.a = 1;
|
||||
|
||||
// Sample screen-space depth map and subtract pixel depth to get the real water depth
|
||||
float depth1 = tex2D(depthMap, screenCoords).r * far - iDepth;
|
||||
depth1 = saturate(depth1 / 500.f);
|
||||
|
@ -93,7 +96,7 @@ void main_fp
|
|||
|
||||
oColor.xyz = lerp(refraction.xyz, reflection.xyz, opacity);
|
||||
|
||||
// add fog
|
||||
float fogValue = saturate((iDepth - fogParams.y) * fogParams.w);
|
||||
oColor.xyz = lerp(oColor.xyz, fogColour, fogValue);
|
||||
oColor.a = 1;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue