mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-03 21:45:34 +00:00
Merge branch 'bzzt_8_shadows_in_refraction' into 'master'
shadows enabled in refraction See merge request OpenMW/openmw!340
This commit is contained in:
commit
a98847e670
4 changed files with 10 additions and 5 deletions
|
@ -305,7 +305,7 @@ namespace MWRender
|
||||||
mTerrain->setWorkQueue(mWorkQueue.get());
|
mTerrain->setWorkQueue(mWorkQueue.get());
|
||||||
|
|
||||||
// water goes after terrain for correct waterculling order
|
// water goes after terrain for correct waterculling order
|
||||||
mWater.reset(new Water(mRootNode, sceneRoot, mResourceSystem, mViewer->getIncrementalCompileOperation(), resourcePath));
|
mWater.reset(new Water(sceneRoot->getParent(0), sceneRoot, mResourceSystem, mViewer->getIncrementalCompileOperation(), resourcePath));
|
||||||
|
|
||||||
mCamera.reset(new Camera(mViewer->getCamera()));
|
mCamera.reset(new Camera(mViewer->getCamera()));
|
||||||
if (Settings::Manager::getBool("view over shoulder", "Camera"))
|
if (Settings::Manager::getBool("view over shoulder", "Camera"))
|
||||||
|
|
|
@ -235,13 +235,14 @@ public:
|
||||||
Refraction()
|
Refraction()
|
||||||
{
|
{
|
||||||
unsigned int rttSize = Settings::Manager::getInt("rtt size", "Water");
|
unsigned int rttSize = Settings::Manager::getInt("rtt size", "Water");
|
||||||
setRenderOrder(osg::Camera::PRE_RENDER);
|
setRenderOrder(osg::Camera::PRE_RENDER, 1);
|
||||||
setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
|
setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
|
||||||
setReferenceFrame(osg::Camera::RELATIVE_RF);
|
setReferenceFrame(osg::Camera::RELATIVE_RF);
|
||||||
setSmallFeatureCullingPixelSize(Settings::Manager::getInt("small feature culling pixel size", "Water"));
|
setSmallFeatureCullingPixelSize(Settings::Manager::getInt("small feature culling pixel size", "Water"));
|
||||||
setName("RefractionCamera");
|
setName("RefractionCamera");
|
||||||
setCullCallback(new InheritViewPointCallback);
|
setCullCallback(new InheritViewPointCallback);
|
||||||
|
setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR);
|
||||||
|
|
||||||
setCullMask(Mask_Effect|Mask_Scene|Mask_Object|Mask_Static|Mask_Terrain|Mask_Actor|Mask_ParticleSystem|Mask_Sky|Mask_Sun|Mask_Player|Mask_Lighting);
|
setCullMask(Mask_Effect|Mask_Scene|Mask_Object|Mask_Static|Mask_Terrain|Mask_Actor|Mask_ParticleSystem|Mask_Sky|Mask_Sun|Mask_Player|Mask_Lighting);
|
||||||
setNodeMask(Mask_RenderToTexture);
|
setNodeMask(Mask_RenderToTexture);
|
||||||
|
@ -284,7 +285,8 @@ public:
|
||||||
|
|
||||||
attach(osg::Camera::DEPTH_BUFFER, mRefractionDepthTexture);
|
attach(osg::Camera::DEPTH_BUFFER, mRefractionDepthTexture);
|
||||||
|
|
||||||
SceneUtil::ShadowManager::disableShadowsForStateSet(getOrCreateStateSet());
|
if (Settings::Manager::getFloat("refraction scale", "Water") != 1) // TODO: to be removed with issue #5709
|
||||||
|
SceneUtil::ShadowManager::disableShadowsForStateSet(getOrCreateStateSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
void setScene(osg::Node* scene)
|
void setScene(osg::Node* scene)
|
||||||
|
|
|
@ -59,7 +59,7 @@ This setting has no effect if the shader setting is false.
|
||||||
This setting can be toggled with the 'Refraction' button in the Water tab of the Video panel of the Options menu.
|
This setting can be toggled with the 'Refraction' button in the Water tab of the Video panel of the Options menu.
|
||||||
|
|
||||||
reflection detail
|
reflection detail
|
||||||
--------------
|
-----------------
|
||||||
|
|
||||||
:Type: integer
|
:Type: integer
|
||||||
:Range: 0, 1, 2, 3, 4
|
:Range: 0, 1, 2, 3, 4
|
||||||
|
@ -111,3 +111,6 @@ This setting only applies if water shader is on and refractions are enabled. Not
|
||||||
setting if off, there will still be small refractions caused by the water waves, which however do not cause such significant
|
setting if off, there will still be small refractions caused by the water waves, which however do not cause such significant
|
||||||
distortion.
|
distortion.
|
||||||
|
|
||||||
|
.. warning::
|
||||||
|
The `refraction scale` is currently mutually exclusive to underwater shadows. Setting this to any value except 1.0
|
||||||
|
will cause underwater shadows to be disabled. This will be addressed in issue https://gitlab.com/OpenMW/openmw/-/issues/5709
|
||||||
|
|
|
@ -246,7 +246,7 @@ void main(void)
|
||||||
float sunHeight = lVec.z;
|
float sunHeight = lVec.z;
|
||||||
vec3 scatterColour = mix(SCATTER_COLOUR*vec3(1.0,0.4,0.0), SCATTER_COLOUR, clamp(1.0-exp(-sunHeight*SUN_EXT), 0.0, 1.0));
|
vec3 scatterColour = mix(SCATTER_COLOUR*vec3(1.0,0.4,0.0), SCATTER_COLOUR, clamp(1.0-exp(-sunHeight*SUN_EXT), 0.0, 1.0));
|
||||||
vec3 lR = reflect(lVec, lNormal);
|
vec3 lR = reflect(lVec, lNormal);
|
||||||
float lightScatter = shadow * clamp(dot(lVec,lNormal)*0.7+0.3, 0.0, 1.0) * clamp(dot(lR, vVec)*2.0-1.2, 0.0, 1.0) * SCATTER_AMOUNT * sunFade * clamp(1.0-exp(-sunHeight), 0.0, 1.0);
|
float lightScatter = clamp(dot(lVec,lNormal)*0.7+0.3, 0.0, 1.0) * clamp(dot(lR, vVec)*2.0-1.2, 0.0, 1.0) * SCATTER_AMOUNT * sunFade * clamp(1.0-exp(-sunHeight), 0.0, 1.0);
|
||||||
gl_FragData[0].xyz = mix( mix(refraction, scatterColour, lightScatter), reflection, fresnel) + specular * gl_LightSource[0].specular.xyz + vec3(rainRipple.w) * 0.2;
|
gl_FragData[0].xyz = mix( mix(refraction, scatterColour, lightScatter), reflection, fresnel) + specular * gl_LightSource[0].specular.xyz + vec3(rainRipple.w) * 0.2;
|
||||||
gl_FragData[0].w = 1.0;
|
gl_FragData[0].w = 1.0;
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Reference in a new issue