more or less fixed the sky for normal viewing angles, still disappears at a certain height though

actorid
scrawl 13 years ago
parent a41eee9a72
commit 393530e671

@ -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;
@ -183,21 +184,21 @@ namespace MWRender
BillboardObject* mSunGlare;
Moon* mMasser;
Moon* mSecunda;
Ogre::Viewport* mViewport;
Ogre::SceneNode* mRootNode;
Ogre::SceneManager* mSceneMgr;
Ogre::SceneNode* mAtmosphereDay;
Ogre::SceneNode* mAtmosphereNight;
Ogre::MaterialPtr mCloudMaterial;
Ogre::MaterialPtr mAtmosphereMaterial;
Ogre::MaterialPtr mStarsMaterials[7];
Ogre::HighLevelGpuProgramPtr mCloudFragmentShader;
// remember some settings so we don't have to apply them again if they didnt change
Ogre::String mClouds;
Ogre::String mNextClouds;
@ -207,17 +208,17 @@ namespace MWRender
float mStarsOpacity;
Ogre::ColourValue mCloudColour;
Ogre::ColourValue mSkyColour;
Ogre::Overlay* mThunderOverlay;
Ogre::TextureUnitState* mThunderTextureUnit;
float mRemainingTransitionTime;
float mGlare; // target
float mGlareFade; // actual
void ModVertexAlpha(Ogre::Entity* ent, unsigned int meshType);
bool mEnabled;
bool mSunEnabled;
bool mMasserEnabled;

@ -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…
Cancel
Save