|
|
@ -247,8 +247,7 @@ namespace MWRender
|
|
|
|
void setDefaults(osg::Camera* camera) override
|
|
|
|
void setDefaults(osg::Camera* camera) override
|
|
|
|
{
|
|
|
|
{
|
|
|
|
camera->setReferenceFrame(osg::Camera::RELATIVE_RF);
|
|
|
|
camera->setReferenceFrame(osg::Camera::RELATIVE_RF);
|
|
|
|
camera->setSmallFeatureCullingPixelSize(
|
|
|
|
camera->setSmallFeatureCullingPixelSize(Settings::water().mSmallFeatureCullingPixelSize);
|
|
|
|
Settings::Manager::getInt("small feature culling pixel size", "Water"));
|
|
|
|
|
|
|
|
camera->setName("RefractionCamera");
|
|
|
|
camera->setName("RefractionCamera");
|
|
|
|
camera->addCullCallback(new InheritViewPointCallback);
|
|
|
|
camera->addCullCallback(new InheritViewPointCallback);
|
|
|
|
camera->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR);
|
|
|
|
camera->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR);
|
|
|
@ -265,7 +264,7 @@ namespace MWRender
|
|
|
|
camera->addChild(mClipCullNode);
|
|
|
|
camera->addChild(mClipCullNode);
|
|
|
|
camera->setNodeMask(Mask_RenderToTexture);
|
|
|
|
camera->setNodeMask(Mask_RenderToTexture);
|
|
|
|
|
|
|
|
|
|
|
|
if (Settings::Manager::getFloat("refraction scale", "Water") != 1) // TODO: to be removed with issue #5709
|
|
|
|
if (Settings::water().mRefractionScale != 1) // TODO: to be removed with issue #5709
|
|
|
|
SceneUtil::ShadowManager::disableShadowsForStateSet(camera->getOrCreateStateSet());
|
|
|
|
SceneUtil::ShadowManager::disableShadowsForStateSet(camera->getOrCreateStateSet());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -285,8 +284,7 @@ namespace MWRender
|
|
|
|
|
|
|
|
|
|
|
|
void setWaterLevel(float waterLevel)
|
|
|
|
void setWaterLevel(float waterLevel)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const float refractionScale
|
|
|
|
const float refractionScale = Settings::water().mRefractionScale;
|
|
|
|
= std::clamp(Settings::Manager::getFloat("refraction scale", "Water"), 0.f, 1.f);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mViewMatrix = osg::Matrix::scale(1, 1, refractionScale)
|
|
|
|
mViewMatrix = osg::Matrix::scale(1, 1, refractionScale)
|
|
|
|
* osg::Matrix::translate(0, 0, (1.0 - refractionScale) * waterLevel);
|
|
|
|
* osg::Matrix::translate(0, 0, (1.0 - refractionScale) * waterLevel);
|
|
|
@ -328,8 +326,7 @@ namespace MWRender
|
|
|
|
void setDefaults(osg::Camera* camera) override
|
|
|
|
void setDefaults(osg::Camera* camera) override
|
|
|
|
{
|
|
|
|
{
|
|
|
|
camera->setReferenceFrame(osg::Camera::RELATIVE_RF);
|
|
|
|
camera->setReferenceFrame(osg::Camera::RELATIVE_RF);
|
|
|
|
camera->setSmallFeatureCullingPixelSize(
|
|
|
|
camera->setSmallFeatureCullingPixelSize(Settings::water().mSmallFeatureCullingPixelSize);
|
|
|
|
Settings::Manager::getInt("small feature culling pixel size", "Water"));
|
|
|
|
|
|
|
|
camera->setName("ReflectionCamera");
|
|
|
|
camera->setName("ReflectionCamera");
|
|
|
|
camera->addCullCallback(new InheritViewPointCallback);
|
|
|
|
camera->addCullCallback(new InheritViewPointCallback);
|
|
|
|
|
|
|
|
|
|
|
@ -384,7 +381,7 @@ namespace MWRender
|
|
|
|
private:
|
|
|
|
private:
|
|
|
|
unsigned int calcNodeMask()
|
|
|
|
unsigned int calcNodeMask()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int reflectionDetail = Settings::Manager::getInt("reflection detail", "Water");
|
|
|
|
int reflectionDetail = Settings::water().mReflectionDetail;
|
|
|
|
reflectionDetail = std::clamp(reflectionDetail, mInterior ? 2 : 0, 5);
|
|
|
|
reflectionDetail = std::clamp(reflectionDetail, mInterior ? 2 : 0, 5);
|
|
|
|
unsigned int extraMask = 0;
|
|
|
|
unsigned int extraMask = 0;
|
|
|
|
if (reflectionDetail >= 1)
|
|
|
|
if (reflectionDetail >= 1)
|
|
|
@ -525,9 +522,9 @@ namespace MWRender
|
|
|
|
mWaterGeom->setStateSet(nullptr);
|
|
|
|
mWaterGeom->setStateSet(nullptr);
|
|
|
|
mWaterGeom->setUpdateCallback(nullptr);
|
|
|
|
mWaterGeom->setUpdateCallback(nullptr);
|
|
|
|
|
|
|
|
|
|
|
|
if (Settings::Manager::getBool("shader", "Water"))
|
|
|
|
if (Settings::water().mShader)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
unsigned int rttSize = Settings::Manager::getInt("rtt size", "Water");
|
|
|
|
const unsigned int rttSize = Settings::water().mRttSize;
|
|
|
|
|
|
|
|
|
|
|
|
mReflection = new Reflection(rttSize, mInterior);
|
|
|
|
mReflection = new Reflection(rttSize, mInterior);
|
|
|
|
mReflection->setWaterLevel(mTop);
|
|
|
|
mReflection->setWaterLevel(mTop);
|
|
|
@ -536,7 +533,7 @@ namespace MWRender
|
|
|
|
mReflection->addCullCallback(mCullCallback);
|
|
|
|
mReflection->addCullCallback(mCullCallback);
|
|
|
|
mParent->addChild(mReflection);
|
|
|
|
mParent->addChild(mReflection);
|
|
|
|
|
|
|
|
|
|
|
|
if (Settings::Manager::getBool("refraction", "Water"))
|
|
|
|
if (Settings::water().mRefraction)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mRefraction = new Refraction(rttSize);
|
|
|
|
mRefraction = new Refraction(rttSize);
|
|
|
|
mRefraction->setWaterLevel(mTop);
|
|
|
|
mRefraction->setWaterLevel(mTop);
|
|
|
@ -693,7 +690,7 @@ namespace MWRender
|
|
|
|
// use a define map to conditionally compile the shader
|
|
|
|
// use a define map to conditionally compile the shader
|
|
|
|
std::map<std::string, std::string> defineMap;
|
|
|
|
std::map<std::string, std::string> defineMap;
|
|
|
|
defineMap["refraction_enabled"] = std::string(mRefraction ? "1" : "0");
|
|
|
|
defineMap["refraction_enabled"] = std::string(mRefraction ? "1" : "0");
|
|
|
|
const auto rippleDetail = std::clamp(Settings::Manager::getInt("rain ripple detail", "Water"), 0, 2);
|
|
|
|
const int rippleDetail = Settings::water().mRainRippleDetail;
|
|
|
|
defineMap["rain_ripple_detail"] = std::to_string(rippleDetail);
|
|
|
|
defineMap["rain_ripple_detail"] = std::to_string(rippleDetail);
|
|
|
|
defineMap["ripple_map_world_scale"] = std::to_string(RipplesSurface::mWorldScaleFactor);
|
|
|
|
defineMap["ripple_map_world_scale"] = std::to_string(RipplesSurface::mWorldScaleFactor);
|
|
|
|
defineMap["ripple_map_size"] = std::to_string(RipplesSurface::mRTTSize) + ".0";
|
|
|
|
defineMap["ripple_map_size"] = std::to_string(RipplesSurface::mRTTSize) + ".0";
|
|
|
|