1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-20 05:23:51 +00:00

- disable the sky renderer completely in interior cells

- SkyManager update (initial sun glare effect, no raycast)
This commit is contained in:
scrawl 2012-02-23 21:44:56 +01:00
parent d9c02ca526
commit af83742e6f
3 changed files with 59 additions and 44 deletions

View file

@ -20,58 +20,63 @@ using namespace Ogre;
// celestial bodies are behind the clouds, but in front of the atmosphere // celestial bodies are behind the clouds, but in front of the atmosphere
#define CELESTIAL_BODY_DISTANCE 1000.f #define CELESTIAL_BODY_DISTANCE 1000.f
CelestialBody::CelestialBody( const String& textureName, BillboardObject::BillboardObject( const String& textureName,
const unsigned int initialSize, const unsigned int initialSize,
const Vector3& pInitialPosition, const Vector3& position,
SceneNode* pRootNode) SceneNode* rootNode)
{ {
init(textureName, initialSize, pInitialPosition, pRootNode); init(textureName, initialSize, position, rootNode);
} }
CelestialBody::CelestialBody() BillboardObject::BillboardObject()
{ {
} }
void CelestialBody::setVisible(const bool visible) void BillboardObject::setVisible(const bool visible)
{ {
mNode->setVisible(visible); mNode->setVisible(visible);
} }
void CelestialBody::setPosition(const Vector3& pPosition) void BillboardObject::setPosition(const Vector3& pPosition)
{ {
Vector3 finalPosition = pPosition.normalisedCopy() * CELESTIAL_BODY_DISTANCE; Vector3 finalPosition = pPosition.normalisedCopy() * CELESTIAL_BODY_DISTANCE;
mNode->setPosition(finalPosition); mNode->setPosition(finalPosition);
} }
void CelestialBody::setColour(const ColourValue& pColour) void BillboardObject::setColour(const ColourValue& pColour)
{ {
mMaterial->getTechnique(0)->getPass(0)->setSelfIllumination(pColour); mMaterial->getTechnique(0)->getPass(0)->setSelfIllumination(pColour);
} }
void CelestialBody::init(const String& textureName, void BillboardObject::setRenderQueue(unsigned int id)
const unsigned int initialSize,
const Vector3& pInitialPosition,
SceneNode* pRootNode)
{ {
SceneManager* sceneMgr = pRootNode->getCreator(); mBBSet->setRenderQueueGroup(id);
}
void BillboardObject::init(const String& textureName,
const unsigned int initialSize,
const Vector3& position,
SceneNode* rootNode)
{
SceneManager* sceneMgr = rootNode->getCreator();
const float scale = initialSize*550.f; const float scale = initialSize*550.f;
Vector3 finalPosition = pInitialPosition.normalisedCopy() * CELESTIAL_BODY_DISTANCE; Vector3 finalPosition = position.normalisedCopy() * CELESTIAL_BODY_DISTANCE;
static unsigned int bodyCount=0; static unsigned int bodyCount=0;
/// \todo These billboards are not 100% correct, might want to revisit them later /// \todo These billboards are not 100% correct, might want to revisit them later
BillboardSet* bbSet = sceneMgr->createBillboardSet("SkyBillboardSet"+StringConverter::toString(bodyCount), 1); mBBSet = sceneMgr->createBillboardSet("SkyBillboardSet"+StringConverter::toString(bodyCount), 1);
bbSet->setDefaultDimensions(scale, scale); mBBSet->setDefaultDimensions(scale, scale);
bbSet->setRenderQueueGroup(RENDER_QUEUE_SKIES_EARLY+1); mBBSet->setRenderQueueGroup(RENDER_QUEUE_SKIES_EARLY+1);
bbSet->setBillboardType(BBT_PERPENDICULAR_COMMON); mBBSet->setBillboardType(BBT_PERPENDICULAR_COMMON);
bbSet->setCommonDirection( -pInitialPosition.normalisedCopy() ); mBBSet->setCommonDirection( -position.normalisedCopy() );
mNode = pRootNode->createChildSceneNode(); mNode = rootNode->createChildSceneNode();
mNode->setPosition(finalPosition); mNode->setPosition(finalPosition);
mNode->attachObject(bbSet); mNode->attachObject(mBBSet);
bbSet->createBillboard(0,0,0); mBBSet->createBillboard(0,0,0);
mMaterial = MaterialManager::getSingleton().create("BillboardMaterial"+StringConverter::toString(bodyCount), ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); mMaterial = MaterialManager::getSingleton().create("BillboardMaterial"+StringConverter::toString(bodyCount), ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
mMaterial->removeAllTechniques(); mMaterial->removeAllTechniques();
@ -83,17 +88,17 @@ void CelestialBody::init(const String& textureName,
p->setDiffuse(0.0,0.0,0.0,1.0); p->setDiffuse(0.0,0.0,0.0,1.0);
p->setAmbient(0.0,0.0,0.0); p->setAmbient(0.0,0.0,0.0);
p->createTextureUnitState(textureName); p->createTextureUnitState(textureName);
bbSet->setMaterialName("BillboardMaterial"+StringConverter::toString(bodyCount)); mBBSet->setMaterialName("BillboardMaterial"+StringConverter::toString(bodyCount));
bodyCount++; bodyCount++;
} }
Moon::Moon( const String& textureName, Moon::Moon( const String& textureName,
const unsigned int initialSize, const unsigned int initialSize,
const Vector3& pInitialPosition, const Vector3& position,
SceneNode* pRootNode) SceneNode* rootNode)
{ {
init(textureName, initialSize, pInitialPosition, pRootNode); init(textureName, initialSize, position, rootNode);
HighLevelGpuProgramManager& mgr = HighLevelGpuProgramManager::getSingleton(); HighLevelGpuProgramManager& mgr = HighLevelGpuProgramManager::getSingleton();
HighLevelGpuProgramPtr vshader; HighLevelGpuProgramPtr vshader;
@ -271,7 +276,9 @@ SkyManager::SkyManager (SceneNode* pMwRoot, Camera* pCamera)
mViewport->setBackgroundColour(ColourValue(0.87, 0.87, 0.87)); mViewport->setBackgroundColour(ColourValue(0.87, 0.87, 0.87));
mSun = new CelestialBody("textures\\tx_sun_05.dds", 1, Vector3(0.4, 0.4, 1.0), mRootNode); mSun = new BillboardObject("textures\\tx_sun_05.dds", 1, Vector3(0.4, 0.4, 1.0), mRootNode);
mSunGlare = new BillboardObject("textures\\tx_sun_flash_grey_05.dds", 3, Vector3(0.4, 0.4, 1.0), mRootNode);
mSunGlare->setRenderQueue(RENDER_QUEUE_SKIES_LATE);
mMasser = new Moon("textures\\tx_masser_full.dds", 1, Vector3(-0.4, -0.4, 0.5), mRootNode); mMasser = new Moon("textures\\tx_masser_full.dds", 1, Vector3(-0.4, -0.4, 0.5), mRootNode);
mSecunda = new Moon("textures\\tx_secunda_full.dds", 0.5, Vector3(0.4, -0.4, 0.5), mRootNode); mSecunda = new Moon("textures\\tx_secunda_full.dds", 0.5, Vector3(0.4, -0.4, 0.5), mRootNode);
mMasser->setType(Moon::Type_Masser); mMasser->setType(Moon::Type_Masser);
@ -411,6 +418,7 @@ SkyManager::SkyManager (SceneNode* pMwRoot, Camera* pCamera)
SkyManager::~SkyManager() SkyManager::~SkyManager()
{ {
delete mSun; delete mSun;
delete mSunGlare;
delete mMasser; delete mMasser;
delete mSecunda; delete mSecunda;
} }

View file

@ -18,45 +18,48 @@ namespace Ogre
class Viewport; class Viewport;
class SceneManager; class SceneManager;
class Entity; class Entity;
class BillboardSet;
} }
namespace MWRender namespace MWRender
{ {
class CelestialBody class BillboardObject
{ {
public: public:
CelestialBody( const Ogre::String& pTextureName, BillboardObject( const Ogre::String& textureName,
const unsigned int pInitialSize, const unsigned int size,
const Ogre::Vector3& pInitialPosition, const Ogre::Vector3& position,
Ogre::SceneNode* pRootNode Ogre::SceneNode* rootNode
); );
CelestialBody(); BillboardObject();
void setColour(const Ogre::ColourValue& pColour); void setColour(const Ogre::ColourValue& pColour);
void setPosition(const Ogre::Vector3& pPosition); void setPosition(const Ogre::Vector3& pPosition);
void setVisible(const bool visible); void setVisible(const bool visible);
void setRenderQueue(unsigned int id);
protected: protected:
virtual void init(const Ogre::String& pTextureName, virtual void init(const Ogre::String& textureName,
const unsigned int pInitialSize, const unsigned int size,
const Ogre::Vector3& pInitialPosition, const Ogre::Vector3& position,
Ogre::SceneNode* pRootNode); Ogre::SceneNode* rootNode);
Ogre::SceneNode* mNode; Ogre::SceneNode* mNode;
Ogre::MaterialPtr mMaterial; Ogre::MaterialPtr mMaterial;
Ogre::BillboardSet* mBBSet;
}; };
/* /*
* The moons need a seperate class because of their shader (which allows them to be partially transparent) * The moons need a seperate class because of their shader (which allows them to be partially transparent)
*/ */
class Moon : public CelestialBody class Moon : public BillboardObject
{ {
public: public:
Moon( const Ogre::String& pTextureName, Moon( const Ogre::String& textureName,
const unsigned int pInitialSize, const unsigned int size,
const Ogre::Vector3& pInitialPosition, const Ogre::Vector3& position,
Ogre::SceneNode* pRootNode Ogre::SceneNode* rootNode
); );
void setVisibility(const float pVisibility); void setVisibility(const float pVisibility);
@ -126,7 +129,8 @@ namespace MWRender
void setWeather(const MWWorld::WeatherResult& weather); void setWeather(const MWWorld::WeatherResult& weather);
private: private:
CelestialBody* mSun; BillboardObject* mSun;
BillboardObject* mSunGlare;
Moon* mMasser; Moon* mMasser;
Moon* mSecunda; Moon* mSecunda;

View file

@ -211,17 +211,20 @@ void WeatherManager::update(float duration)
else else
result = getResult(mCurrentWeather); result = getResult(mCurrentWeather);
mRendering->getSkyManager()->setWeather(result);
if (mWorld->isCellExterior() || mWorld->isCellQuasiExterior()) if (mWorld->isCellExterior() || mWorld->isCellQuasiExterior())
{ {
mRendering->setAmbientColour(result.mAmbientColor); mRendering->setAmbientColour(result.mAmbientColor);
mRendering->sunEnable(); mRendering->sunEnable();
mRendering->setSunColour(result.mSunColor); mRendering->setSunColour(result.mSunColor);
mRendering->skyEnable();
mRendering->getSkyManager()->setWeather(result);
} }
else else
{ {
mRendering->sunDisable(); mRendering->sunDisable();
mRendering->skyDisable();
} }
} }