mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 07:53:53 +00:00
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;
|
strength = 1.f;
|
||||||
|
|
||||||
mSunGlare->setVisibility(weather.mGlareView * mGlareFade * strength);
|
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);
|
mAtmosphereNight->setVisible(weather.mNight && mEnabled);
|
||||||
}
|
}
|
||||||
|
@ -923,3 +925,8 @@ void SkyManager::resetSkyPosition()
|
||||||
{
|
{
|
||||||
mRootNode->setPosition(0,0,0);
|
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 setSkyPosition(const Ogre::Vector3& position);
|
||||||
void resetSkyPosition();
|
void resetSkyPosition();
|
||||||
|
void scaleSky(float scale);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool mCreated;
|
bool mCreated;
|
||||||
|
|
|
@ -141,15 +141,16 @@ void Water::preRenderTargetUpdate(const RenderTargetEvent& evt)
|
||||||
{
|
{
|
||||||
mWater->setVisible(false);
|
mWater->setVisible(false);
|
||||||
|
|
||||||
mOldCameraFarClip = mCamera->getFarClipDistance();
|
//mOldCameraFarClip = mCamera->getFarClipDistance();
|
||||||
if (mReflectDistance != 0)
|
//if (mReflectDistance != 0)
|
||||||
mCamera->setFarClipDistance(mReflectDistance);
|
// mCamera->setFarClipDistance(mReflectDistance);
|
||||||
|
|
||||||
if (evt.source == mReflectionTarget)
|
if (evt.source == mReflectionTarget)
|
||||||
{
|
{
|
||||||
Vector3 pos = mCamera->getRealPosition();
|
Vector3 pos = mCamera->getRealPosition();
|
||||||
pos.y = mTop*2 - pos.y;
|
pos.y = mTop*2 - pos.y;
|
||||||
mSky->setSkyPosition(pos);
|
mSky->setSkyPosition(pos);
|
||||||
|
mSky->scaleSky(mCamera->getFarClipDistance() / 1000.f);
|
||||||
mCamera->enableCustomNearClipPlane(Plane(Vector3::UNIT_Y, mTop));
|
mCamera->enableCustomNearClipPlane(Plane(Vector3::UNIT_Y, mTop));
|
||||||
mCamera->enableReflection(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);
|
mWater->setVisible(true);
|
||||||
|
|
||||||
mCamera->setFarClipDistance(mOldCameraFarClip);
|
//mCamera->setFarClipDistance(mOldCameraFarClip);
|
||||||
|
|
||||||
if (evt.source == mReflectionTarget)
|
if (evt.source == mReflectionTarget)
|
||||||
{
|
{
|
||||||
mSky->resetSkyPosition();
|
mSky->resetSkyPosition();
|
||||||
|
mSky->scaleSky(1);
|
||||||
mCamera->disableReflection();
|
mCamera->disableReflection();
|
||||||
mCamera->disableCustomNearClipPlane();
|
mCamera->disableCustomNearClipPlane();
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace MWRender {
|
||||||
class SkyManager;
|
class SkyManager;
|
||||||
|
|
||||||
/// Water rendering
|
/// Water rendering
|
||||||
class Water : Ogre::RenderTargetListener
|
class Water : public Ogre::RenderTargetListener
|
||||||
{
|
{
|
||||||
static const int CELL_SIZE = 8192;
|
static const int CELL_SIZE = 8192;
|
||||||
Ogre::Camera *mCamera;
|
Ogre::Camera *mCamera;
|
||||||
|
|
|
@ -54,6 +54,9 @@ void main_fp
|
||||||
float2 screenCoords = iScreenCoords.xy / iScreenCoords.z;
|
float2 screenCoords = iScreenCoords.xy / iScreenCoords.z;
|
||||||
screenCoords.y = (1-saturate(renderTargetFlipping))+renderTargetFlipping*screenCoords.y;
|
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
|
// Sample screen-space depth map and subtract pixel depth to get the real water depth
|
||||||
float depth1 = tex2D(depthMap, screenCoords).r * far - iDepth;
|
float depth1 = tex2D(depthMap, screenCoords).r * far - iDepth;
|
||||||
depth1 = saturate(depth1 / 500.f);
|
depth1 = saturate(depth1 / 500.f);
|
||||||
|
@ -93,7 +96,7 @@ void main_fp
|
||||||
|
|
||||||
oColor.xyz = lerp(refraction.xyz, reflection.xyz, opacity);
|
oColor.xyz = lerp(refraction.xyz, reflection.xyz, opacity);
|
||||||
|
|
||||||
|
// add fog
|
||||||
float fogValue = saturate((iDepth - fogParams.y) * fogParams.w);
|
float fogValue = saturate((iDepth - fogParams.y) * fogParams.w);
|
||||||
oColor.xyz = lerp(oColor.xyz, fogColour, fogValue);
|
oColor.xyz = lerp(oColor.xyz, fogColour, fogValue);
|
||||||
oColor.a = 1;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue