mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-03 21:49:41 +00:00
Water: pass the near and far planes
This commit is contained in:
parent
37c9c12962
commit
9f2f503d37
2 changed files with 7 additions and 3 deletions
|
@ -198,6 +198,9 @@ namespace MWRender
|
||||||
mFieldOfView = Settings::Manager::getFloat("field of view", "General");
|
mFieldOfView = Settings::Manager::getFloat("field of view", "General");
|
||||||
updateProjectionMatrix();
|
updateProjectionMatrix();
|
||||||
mStateUpdater->setFogEnd(mViewDistance);
|
mStateUpdater->setFogEnd(mViewDistance);
|
||||||
|
|
||||||
|
mRootNode->getOrCreateStateSet()->addUniform(new osg::Uniform("near", mNearClip));
|
||||||
|
mRootNode->getOrCreateStateSet()->addUniform(new osg::Uniform("far", mViewDistance));
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderingManager::~RenderingManager()
|
RenderingManager::~RenderingManager()
|
||||||
|
|
|
@ -68,6 +68,9 @@ uniform sampler2D normalMap;
|
||||||
|
|
||||||
uniform float osg_SimulationTime;
|
uniform float osg_SimulationTime;
|
||||||
|
|
||||||
|
uniform float near;
|
||||||
|
uniform float far;
|
||||||
|
|
||||||
void main(void)
|
void main(void)
|
||||||
{
|
{
|
||||||
// FIXME
|
// FIXME
|
||||||
|
@ -160,10 +163,8 @@ void main(void)
|
||||||
#if REFRACTION
|
#if REFRACTION
|
||||||
float refractionDepth = texture2D(refractionDepthMap, screenCoords-(normal.xy*REFR_BUMP)).x;
|
float refractionDepth = texture2D(refractionDepthMap, screenCoords-(normal.xy*REFR_BUMP)).x;
|
||||||
// make linear
|
// make linear
|
||||||
float zNear = 5; // FIXME
|
|
||||||
float zFar = 6666; // FIXME
|
|
||||||
float z_n = 2.0 * refractionDepth - 1.0;
|
float z_n = 2.0 * refractionDepth - 1.0;
|
||||||
refractionDepth = 2.0 * zNear * zFar / (zFar + zNear - z_n * (zFar - zNear));
|
refractionDepth = 2.0 * near * far / (far + near - z_n * (far - near));
|
||||||
|
|
||||||
float waterDepth = refractionDepth - depthPassthrough;
|
float waterDepth = refractionDepth - depthPassthrough;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue