mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-15 18:39:51 +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
@ -20,7 +20,7 @@ using namespace Ogre;
|
|||||||
namespace MWRender {
|
namespace MWRender {
|
||||||
|
|
||||||
RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const boost::filesystem::path& resDir, OEngine::Physic::PhysicEngine* engine, MWWorld::Environment& environment)
|
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);
|
mRendering.createScene("PlayerCam", 55, 5);
|
||||||
|
|
||||||
@ -280,4 +280,22 @@ void RenderingManager::skipAnimation (const MWWorld::Ptr& ptr)
|
|||||||
mActors.skipAnimation(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
|
||||||
|
@ -86,7 +86,12 @@ class RenderingManager: private RenderingInterface {
|
|||||||
void moveObjectToCell (const MWWorld::Ptr& ptr, const Ogre::Vector3& position, MWWorld::Ptr::CellStore *store);
|
void moveObjectToCell (const MWWorld::Ptr& ptr, const Ogre::Vector3& position, MWWorld::Ptr::CellStore *store);
|
||||||
|
|
||||||
void update (float duration);
|
void update (float duration);
|
||||||
|
|
||||||
|
void setSunColour(const Ogre::ColourValue& colour);
|
||||||
|
void setSunDirection(const Ogre::Vector3& direction);
|
||||||
|
void sunEnable();
|
||||||
|
void sunDisable();
|
||||||
|
|
||||||
void skyEnable ();
|
void skyEnable ();
|
||||||
void skyDisable ();
|
void skyDisable ();
|
||||||
void skySetHour (double hour);
|
void skySetHour (double hour);
|
||||||
|
@ -14,7 +14,7 @@ using namespace MWRender;
|
|||||||
using namespace Ogre;
|
using namespace Ogre;
|
||||||
|
|
||||||
// the speed at which the clouds are animated
|
// 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
|
// this distance has to be set accordingly so that the
|
||||||
// celestial bodies are behind the clouds, but in front of the atmosphere
|
// 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 sampler2D secondTexture : TEXUNIT1, \n"
|
||||||
" uniform float transitionFactor, \n"
|
" uniform float transitionFactor, \n"
|
||||||
" uniform float time, \n"
|
" uniform float time, \n"
|
||||||
|
" uniform float speed, \n"
|
||||||
" uniform float opacity, \n"
|
" uniform float opacity, \n"
|
||||||
" uniform float4 emissive \n"
|
" uniform float4 emissive \n"
|
||||||
") \n"
|
") \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"
|
" float4 tex = lerp(tex2D(texture, uv), tex2D(secondTexture, uv), transitionFactor); \n"
|
||||||
" oColor = color * float4(emissive.xyz,1) * tex * float4(1,1,1,opacity); \n"
|
" oColor = color * float4(emissive.xyz,1) * tex * float4(1,1,1,opacity); \n"
|
||||||
"}";
|
"}";
|
||||||
@ -489,6 +490,17 @@ void SkyManager::setWeather(const MWWorld::WeatherResult& weather)
|
|||||||
mAtmosphereMaterial->getTechnique(0)->getPass(0)->setSelfIllumination(weather.mSkyColor);
|
mAtmosphereMaterial->getTechnique(0)->getPass(0)->setSelfIllumination(weather.mSkyColor);
|
||||||
mSkyColour = weather.mSkyColor;
|
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);
|
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,10 +144,11 @@ namespace MWRender
|
|||||||
Ogre::String mNextClouds;
|
Ogre::String mNextClouds;
|
||||||
float mCloudBlendFactor;
|
float mCloudBlendFactor;
|
||||||
float mCloudOpacity;
|
float mCloudOpacity;
|
||||||
|
float mCloudSpeed;
|
||||||
|
|
||||||
Ogre::ColourValue mCloudColour;
|
Ogre::ColourValue mCloudColour;
|
||||||
Ogre::ColourValue mSkyColour;
|
Ogre::ColourValue mSkyColour;
|
||||||
|
|
||||||
float mRemainingTransitionTime;
|
float mRemainingTransitionTime;
|
||||||
|
|
||||||
void ModVertexAlpha(Ogre::Entity* ent, unsigned int meshType);
|
void ModVertexAlpha(Ogre::Entity* ent, unsigned int meshType);
|
||||||
|
@ -113,11 +113,6 @@ WeatherResult WeatherManager::getResult(const String& weather)
|
|||||||
result.mGlareView = current.mGlareView;
|
result.mGlareView = current.mGlareView;
|
||||||
result.mAmbientLoopSoundID = current.mAmbientLoopSoundID;
|
result.mAmbientLoopSoundID = current.mAmbientLoopSoundID;
|
||||||
|
|
||||||
const float dayTime = 13.f;
|
|
||||||
const float nightTime = 1.f;
|
|
||||||
|
|
||||||
float factor;
|
|
||||||
|
|
||||||
/// \todo interpolation
|
/// \todo interpolation
|
||||||
|
|
||||||
// night
|
// night
|
||||||
@ -215,6 +210,8 @@ void WeatherManager::update(float duration)
|
|||||||
result = getResult(mCurrentWeather);
|
result = getResult(mCurrentWeather);
|
||||||
|
|
||||||
mRendering->getSkyManager()->setWeather(result);
|
mRendering->getSkyManager()->setWeather(result);
|
||||||
|
|
||||||
|
mRendering->setSunColour(result.mSunColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WeatherManager::setHour(const float hour)
|
void WeatherManager::setHour(const float hour)
|
||||||
@ -227,7 +224,7 @@ void WeatherManager::setHour(const float hour)
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
std::cout << "hour " << mHour << std::endl;
|
std::cout << "hour " << mHour << std::endl;
|
||||||
/**/
|
*/
|
||||||
|
|
||||||
mHour = hour;
|
mHour = hour;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user