mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-30 03:32:36 +00:00
Re-fix water reflections while making a no-GUI screenshot
This commit is contained in:
parent
2d87d1d9d2
commit
47b1b0ac39
@ -169,19 +169,18 @@ namespace MWGui
|
|||||||
// We are already using node masks to avoid the scene from being updated/rendered, but node masks don't work for computeBound()
|
// We are already using node masks to avoid the scene from being updated/rendered, but node masks don't work for computeBound()
|
||||||
mViewer->getSceneData()->setComputeBoundingSphereCallback(new DontComputeBoundCallback);
|
mViewer->getSceneData()->setComputeBoundingSphereCallback(new DontComputeBoundCallback);
|
||||||
|
|
||||||
mShowWallpaper = visible && (MWBase::Environment::get().getStateManager()->getState()
|
mVisible = visible;
|
||||||
== MWBase::StateManager::State_NoGame);
|
mLoadingBox->setVisible(mVisible);
|
||||||
|
setVisible(true);
|
||||||
|
|
||||||
if (!visible)
|
if (!mVisible)
|
||||||
{
|
{
|
||||||
|
mShowWallpaper = false;
|
||||||
draw();
|
draw();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mVisible = visible;
|
mShowWallpaper = MWBase::Environment::get().getStateManager()->getState() == MWBase::StateManager::State_NoGame;
|
||||||
mLoadingBox->setVisible(mVisible);
|
|
||||||
|
|
||||||
setVisible(true);
|
|
||||||
|
|
||||||
if (mShowWallpaper)
|
if (mShowWallpaper)
|
||||||
{
|
{
|
||||||
|
@ -805,7 +805,7 @@ namespace MWRender
|
|||||||
|
|
||||||
cubeTexture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::NEAREST);
|
cubeTexture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::NEAREST);
|
||||||
cubeTexture->setFilter(osg::Texture::MAG_FILTER,osg::Texture::NEAREST);
|
cubeTexture->setFilter(osg::Texture::MAG_FILTER,osg::Texture::NEAREST);
|
||||||
|
|
||||||
cubeTexture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
|
cubeTexture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
|
||||||
cubeTexture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
|
cubeTexture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
|
||||||
|
|
||||||
@ -830,19 +830,14 @@ namespace MWRender
|
|||||||
stateset->addUniform(new osg::Uniform("cubeMap",0));
|
stateset->addUniform(new osg::Uniform("cubeMap",0));
|
||||||
stateset->addUniform(new osg::Uniform("mapping",screenshotMapping));
|
stateset->addUniform(new osg::Uniform("mapping",screenshotMapping));
|
||||||
stateset->setTextureAttributeAndModes(0,cubeTexture,osg::StateAttribute::ON);
|
stateset->setTextureAttributeAndModes(0,cubeTexture,osg::StateAttribute::ON);
|
||||||
|
|
||||||
quad->setStateSet(stateset);
|
quad->setStateSet(stateset);
|
||||||
quad->setUpdateCallback(nullptr);
|
quad->setUpdateCallback(nullptr);
|
||||||
|
|
||||||
screenshotCamera->addChild(quad);
|
screenshotCamera->addChild(quad);
|
||||||
|
|
||||||
mRootNode->addChild(screenshotCamera);
|
|
||||||
|
|
||||||
renderCameraToImage(screenshotCamera,image,screenshotW,screenshotH);
|
renderCameraToImage(screenshotCamera,image,screenshotW,screenshotH);
|
||||||
|
|
||||||
screenshotCamera->removeChildren(0,screenshotCamera->getNumChildren());
|
|
||||||
mRootNode->removeChild(screenshotCamera);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -867,6 +862,8 @@ namespace MWRender
|
|||||||
image->setDataType(GL_UNSIGNED_BYTE);
|
image->setDataType(GL_UNSIGNED_BYTE);
|
||||||
image->setPixelFormat(texture->getInternalFormat());
|
image->setPixelFormat(texture->getInternalFormat());
|
||||||
|
|
||||||
|
mRootNode->addChild(camera);
|
||||||
|
|
||||||
// The draw needs to complete before we can copy back our image.
|
// The draw needs to complete before we can copy back our image.
|
||||||
osg::ref_ptr<NotifyDrawCompletedCallback> callback (new NotifyDrawCompletedCallback);
|
osg::ref_ptr<NotifyDrawCompletedCallback> callback (new NotifyDrawCompletedCallback);
|
||||||
camera->setFinalDrawCallback(callback);
|
camera->setFinalDrawCallback(callback);
|
||||||
@ -882,32 +879,17 @@ namespace MWRender
|
|||||||
|
|
||||||
// now that we've "used up" the current frame, get a fresh framenumber for the next frame() following after the screenshot is completed
|
// now that we've "used up" the current frame, get a fresh framenumber for the next frame() following after the screenshot is completed
|
||||||
mViewer->advance(mViewer->getFrameStamp()->getSimulationTime());
|
mViewer->advance(mViewer->getFrameStamp()->getSimulationTime());
|
||||||
|
|
||||||
|
camera->removeChildren(0, camera->getNumChildren());
|
||||||
|
mRootNode->removeChild(camera);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderingManager::screenshot(osg::Image *image, int w, int h, osg::Matrixd cameraTransform)
|
void RenderingManager::screenshot(osg::Image *image, int w, int h, osg::Matrixd cameraTransform)
|
||||||
{
|
{
|
||||||
osg::ref_ptr<osg::Camera> rttCamera (new osg::Camera);
|
osg::ref_ptr<osg::Camera> rttCamera (new osg::Camera);
|
||||||
rttCamera->setNodeMask(Mask_RenderToTexture);
|
|
||||||
rttCamera->attach(osg::Camera::COLOR_BUFFER, image);
|
|
||||||
rttCamera->setRenderOrder(osg::Camera::PRE_RENDER);
|
|
||||||
rttCamera->setReferenceFrame(osg::Camera::ABSOLUTE_RF);
|
|
||||||
rttCamera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT, osg::Camera::PIXEL_BUFFER_RTT);
|
|
||||||
rttCamera->setProjectionMatrixAsPerspective(mFieldOfView, w/float(h), mNearClip, mViewDistance);
|
rttCamera->setProjectionMatrixAsPerspective(mFieldOfView, w/float(h), mNearClip, mViewDistance);
|
||||||
rttCamera->setViewMatrix(mViewer->getCamera()->getViewMatrix() * cameraTransform);
|
rttCamera->setViewMatrix(mViewer->getCamera()->getViewMatrix() * cameraTransform);
|
||||||
|
|
||||||
rttCamera->setViewport(0, 0, w, h);
|
|
||||||
|
|
||||||
osg::ref_ptr<osg::Texture2D> texture (new osg::Texture2D);
|
|
||||||
texture->setInternalFormat(GL_RGB);
|
|
||||||
texture->setTextureSize(w, h);
|
|
||||||
texture->setResizeNonPowerOfTwoHint(false);
|
|
||||||
texture->setFilter(osg::Texture::MIN_FILTER, osg::Texture::LINEAR);
|
|
||||||
texture->setFilter(osg::Texture::MAG_FILTER, osg::Texture::LINEAR);
|
|
||||||
rttCamera->attach(osg::Camera::COLOR_BUFFER, texture);
|
|
||||||
|
|
||||||
image->setDataType(GL_UNSIGNED_BYTE);
|
|
||||||
image->setPixelFormat(texture->getInternalFormat());
|
|
||||||
|
|
||||||
rttCamera->setUpdateCallback(new NoTraverseCallback);
|
rttCamera->setUpdateCallback(new NoTraverseCallback);
|
||||||
rttCamera->addChild(mSceneRoot);
|
rttCamera->addChild(mSceneRoot);
|
||||||
|
|
||||||
@ -916,14 +898,9 @@ namespace MWRender
|
|||||||
|
|
||||||
rttCamera->setCullMask(mViewer->getCamera()->getCullMask() & (~Mask_GUI));
|
rttCamera->setCullMask(mViewer->getCamera()->getCullMask() & (~Mask_GUI));
|
||||||
|
|
||||||
mRootNode->addChild(rttCamera);
|
|
||||||
|
|
||||||
rttCamera->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
rttCamera->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
renderCameraToImage(rttCamera.get(),image,w,h);
|
renderCameraToImage(rttCamera.get(),image,w,h);
|
||||||
|
|
||||||
rttCamera->removeChildren(0, rttCamera->getNumChildren());
|
|
||||||
mRootNode->removeChild(rttCamera);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::Vec4f RenderingManager::getScreenBounds(const MWWorld::Ptr& ptr)
|
osg::Vec4f RenderingManager::getScreenBounds(const MWWorld::Ptr& ptr)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user