1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-21 10:23:52 +00:00

Merge pull request #2 from scrawl/shadows

Enable shadows for terrain & restore cull mask
This commit is contained in:
AnyOldName3 2017-11-03 00:38:57 +00:00 committed by GitHub
commit 2bfd45fb40
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 6 deletions

View file

@ -206,7 +206,7 @@ namespace MWRender
osgShadow::ShadowSettings* settings = shadowedScene->getShadowSettings();
settings->setLightNum(0);
settings->setCastsShadowTraversalMask(Mask_Scene|Mask_Actor|Mask_Player);
settings->setCastsShadowTraversalMask(Mask_Scene|Mask_Actor|Mask_Player|Mask_Terrain);
settings->setReceivesShadowTraversalMask(~0u);
//settings->setShadowMapProjectionHint(osgShadow::ShadowSettings::PERSPECTIVE_SHADOW_MAP);
@ -268,7 +268,7 @@ namespace MWRender
mViewer->setLightingMode(osgViewer::View::NO_LIGHT);
osg::ref_ptr<osg::LightSource> source = new osg::LightSource;
//source->setNodeMask(Mask_Lighting);
source->setNodeMask(Mask_Lighting);
mSunLight = new osg::Light;
source->setLight(mSunLight);
mSunLight->setDiffuse(osg::Vec4f(0,0,0,1));
@ -315,8 +315,7 @@ namespace MWRender
mViewer->getCamera()->setComputeNearFarMode(osg::Camera::DO_NOT_COMPUTE_NEAR_FAR);
mViewer->getCamera()->setCullingMode(cullingMode);
//mViewer->getCamera()->setCullMask(~(Mask_UpdateVisitor|Mask_SimpleWater));
mViewer->getCamera()->setCullMask(~(Mask_Lighting));
mViewer->getCamera()->setCullMask(~(Mask_UpdateVisitor|Mask_SimpleWater));
mNearClip = Settings::Manager::getFloat("near clip", "Camera");
mViewDistance = Settings::Manager::getFloat("viewing distance", "Camera");

View file

@ -18,7 +18,7 @@ namespace MWRender
"void main(void) \n"
"{ \n"
#if 1
" float f = texture2D( texture, gl_TexCoord[0] ).r; \n"
" float f = texture2D( texture, gl_TexCoord[0].xy ).r; \n"
" \n"
" f = 256.0 * f; \n"
" float fC = floor( f ) / 256.0; \n"
@ -45,7 +45,7 @@ namespace MWRender
" \n"
" gl_FragColor = vec4( fS + fH * color, 1 ); \n"
#else
" gl_FragColor = texture2D(texture, gl_TexCoord[0]); \n"
" gl_FragColor = texture2D(texture, gl_TexCoord[0].xy); \n"
" //gl_FragColor = vec4(1.0, 0.5, 0.5, 1.0); \n"
#endif
"} \n";

View file

@ -51,6 +51,12 @@ void TerrainDrawable::cull(osgUtil::CullVisitor *cv)
if (osg::isNaN(depth))
return;
if (cv->getCurrentCamera()->getName() == "ShadowCamera")
{
cv->addDrawableAndDepth(this, &matrix, depth);
return;
}
bool pushedLight = mLightListCallback && mLightListCallback->pushLightState(this, cv);
for (PassVector::const_iterator it = mPasses.begin(); it != mPasses.end(); ++it)