enable water effects for 360 screenshots

0.6.3
Miloslav Číž 7 years ago
parent 319ed2f9b8
commit 1f49612ca3

@ -807,7 +807,7 @@ namespace MWRender
for (int i = 0; i < 6; i++) // for each cube side
{
osg::Image *sideImage = s.getImage(i);
screenshot(sideImage,cubeWidth,cubeWidth,directions[i],true);
screenshot(sideImage,cubeWidth,cubeWidth,directions[i]);
}
s.create(image,screenshotWidth,mapping != SphericalScreenshot::MAPPING_SMALL_PLANET ? screenshotHeight : screenshotWidth,mapping);
@ -818,7 +818,7 @@ namespace MWRender
return true;
}
void RenderingManager::screenshot(osg::Image *image, int w, int h, osg::Vec3 direction, bool disableWaterEffects)
void RenderingManager::screenshot(osg::Image *image, int w, int h, osg::Vec3 direction)
{
osg::ref_ptr<osg::Camera> rttCamera (new osg::Camera);
rttCamera->setNodeMask(Mask_RenderToTexture);
@ -844,6 +844,10 @@ namespace MWRender
rttCamera->setUpdateCallback(new NoTraverseCallback);
rttCamera->addChild(mSceneRoot);
rttCamera->addChild(mWater->getReflectionCamera());
rttCamera->addChild(mWater->getRefractionCamera());
rttCamera->setCullMask(mViewer->getCamera()->getCullMask() & (~Mask_GUI));
mRootNode->addChild(rttCamera);
@ -856,16 +860,10 @@ namespace MWRender
// so out of order calls are necessary to get a correct frameNumber for the next frame.
// refer to the advance() and frame() order in Engine::go()
if (disableWaterEffects)
mWater->setEffectsEnabled(false);
mViewer->eventTraversal();
mViewer->updateTraversal();
mViewer->renderingTraversals();
if (disableWaterEffects)
mWater->setEffectsEnabled(true);
callback->waitTillDone();
// now that we've "used up" the current frame, get a fresh framenumber for the next frame() following after the screenshot is completed

@ -125,7 +125,7 @@ namespace MWRender
void setWaterHeight(float level);
/// Take a screenshot of w*h onto the given image, not including the GUI.
void screenshot(osg::Image* image, int w, int h, osg::Vec3 direction=osg::Vec3(0,0,-1), bool disableWaterEffects=false);
void screenshot(osg::Image* image, int w, int h, osg::Vec3 direction=osg::Vec3(0,0,-1));
bool screenshot360(osg::Image* image);
struct RayResult

@ -476,6 +476,16 @@ void Water::updateWaterMaterial()
updateVisible();
}
osg::Camera *Water::getReflectionCamera()
{
return mReflection;
}
osg::Camera *Water::getRefractionCamera()
{
return mRefraction;
}
void Water::createSimpleWaterStateSet(osg::Node* node, float alpha)
{
osg::ref_ptr<osg::StateSet> stateset = SceneUtil::createSimpleWaterStateSet(alpha, MWRender::RenderBin_Water);

@ -7,6 +7,7 @@
#include <osg/ref_ptr>
#include <osg/Vec3f>
#include <osg/Uniform>
#include <osg/Camera>
#include <components/settings/settings.hpp>
@ -113,6 +114,9 @@ namespace MWRender
void update(float dt);
osg::Camera *getReflectionCamera();
osg::Camera *getRefractionCamera();
void processChangedSettings(const Settings::CategorySettingVector& settings);
osg::Uniform *getRainIntensityUniform();

Loading…
Cancel
Save