mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 22:53:50 +00:00
attempt to fix openmw's lighting (restored the sun, set proper ambient value outside)
- the fix should remain in this branch since the main branch still has the lighting by caelum
This commit is contained in:
parent
a5720e9a4f
commit
90af78e3b8
5 changed files with 44 additions and 11 deletions
|
@ -20,7 +20,7 @@ using namespace Ogre;
|
|||
namespace MWRender {
|
||||
|
||||
RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const boost::filesystem::path& resDir, OEngine::Physic::PhysicEngine* engine, MWWorld::Environment& environment)
|
||||
:mRendering(_rend), mObjects(mRendering), mActors(mRendering, environment), mDebugging(engine)
|
||||
:mRendering(_rend), mObjects(mRendering), mActors(mRendering, environment), mAmbientMode(0), mDebugging(engine)
|
||||
{
|
||||
mRendering.createScene("PlayerCam", 55, 5);
|
||||
|
||||
|
@ -280,4 +280,22 @@ void RenderingManager::skipAnimation (const MWWorld::Ptr& ptr)
|
|||
mActors.skipAnimation(ptr);
|
||||
}
|
||||
|
||||
void RenderingManager::setSunColour(const Ogre::ColourValue& colour)
|
||||
{
|
||||
mSun->setDiffuseColour(colour);
|
||||
}
|
||||
void RenderingManager::sunEnable()
|
||||
{
|
||||
/// \todo
|
||||
}
|
||||
void RenderingManager::sunDisable()
|
||||
{
|
||||
/// \todo
|
||||
}
|
||||
|
||||
void RenderingManager::setSunDirection(const Ogre::Vector3& direction)
|
||||
{
|
||||
/// \todo
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -87,6 +87,11 @@ class RenderingManager: private RenderingInterface {
|
|||
|
||||
void update (float duration);
|
||||
|
||||
void setSunColour(const Ogre::ColourValue& colour);
|
||||
void setSunDirection(const Ogre::Vector3& direction);
|
||||
void sunEnable();
|
||||
void sunDisable();
|
||||
|
||||
void skyEnable ();
|
||||
void skyDisable ();
|
||||
void skySetHour (double hour);
|
||||
|
|
|
@ -14,7 +14,7 @@ using namespace MWRender;
|
|||
using namespace Ogre;
|
||||
|
||||
// the speed at which the clouds are animated
|
||||
#define CLOUD_SPEED 0.0025
|
||||
#define CLOUD_SPEED 0.001
|
||||
|
||||
// this distance has to be set accordingly so that the
|
||||
// celestial bodies are behind the clouds, but in front of the atmosphere
|
||||
|
@ -371,11 +371,12 @@ SkyManager::SkyManager (SceneNode* pMwRoot, Camera* pCamera)
|
|||
" uniform sampler2D secondTexture : TEXUNIT1, \n"
|
||||
" uniform float transitionFactor, \n"
|
||||
" uniform float time, \n"
|
||||
" uniform float speed, \n"
|
||||
" uniform float opacity, \n"
|
||||
" uniform float4 emissive \n"
|
||||
") \n"
|
||||
"{ \n"
|
||||
" uv += float2(1,1) * time * "<<CLOUD_SPEED<<"; \n" // Scroll in x,y direction
|
||||
" uv += float2(1,1) * time * speed * "<<CLOUD_SPEED<<"; \n" // Scroll in x,y direction
|
||||
" float4 tex = lerp(tex2D(texture, uv), tex2D(secondTexture, uv), transitionFactor); \n"
|
||||
" oColor = color * float4(emissive.xyz,1) * tex * float4(1,1,1,opacity); \n"
|
||||
"}";
|
||||
|
@ -490,5 +491,16 @@ void SkyManager::setWeather(const MWWorld::WeatherResult& weather)
|
|||
mSkyColour = weather.mSkyColor;
|
||||
}
|
||||
|
||||
if (mCloudSpeed != weather.mCloudSpeed)
|
||||
{
|
||||
mCloudMaterial->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstant("speed", Real(weather.mCloudSpeed));
|
||||
mCloudSpeed = weather.mCloudSpeed;
|
||||
}
|
||||
|
||||
mViewport->setBackgroundColour(weather.mFogColor);
|
||||
|
||||
/// \todo
|
||||
// only set ambient light if we're in an exterior cell
|
||||
// (interior cell lights are not managed by SkyManager)
|
||||
mSceneMgr->setAmbientLight(weather.mAmbientColor);
|
||||
}
|
||||
|
|
|
@ -144,6 +144,7 @@ namespace MWRender
|
|||
Ogre::String mNextClouds;
|
||||
float mCloudBlendFactor;
|
||||
float mCloudOpacity;
|
||||
float mCloudSpeed;
|
||||
|
||||
Ogre::ColourValue mCloudColour;
|
||||
Ogre::ColourValue mSkyColour;
|
||||
|
|
|
@ -113,11 +113,6 @@ WeatherResult WeatherManager::getResult(const String& weather)
|
|||
result.mGlareView = current.mGlareView;
|
||||
result.mAmbientLoopSoundID = current.mAmbientLoopSoundID;
|
||||
|
||||
const float dayTime = 13.f;
|
||||
const float nightTime = 1.f;
|
||||
|
||||
float factor;
|
||||
|
||||
/// \todo interpolation
|
||||
|
||||
// night
|
||||
|
@ -215,6 +210,8 @@ void WeatherManager::update(float duration)
|
|||
result = getResult(mCurrentWeather);
|
||||
|
||||
mRendering->getSkyManager()->setWeather(result);
|
||||
|
||||
mRendering->setSunColour(result.mSunColor);
|
||||
}
|
||||
|
||||
void WeatherManager::setHour(const float hour)
|
||||
|
@ -227,7 +224,7 @@ void WeatherManager::setHour(const float hour)
|
|||
|
||||
#include <iostream>
|
||||
std::cout << "hour " << mHour << std::endl;
|
||||
/**/
|
||||
*/
|
||||
|
||||
mHour = hour;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue