mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-01 01:45:34 +00:00
Merge branch 'osgshadow-test-vdsm' into osgshadow-test-vdsm-sky-method-two
This commit is contained in:
commit
26fe47b9a2
6 changed files with 12 additions and 16 deletions
|
@ -210,7 +210,7 @@ namespace MWRender
|
|||
settings->setReceivesShadowTraversalMask(~0u);
|
||||
|
||||
//settings->setShadowMapProjectionHint(osgShadow::ShadowSettings::PERSPECTIVE_SHADOW_MAP);
|
||||
settings->setBaseShadowTextureUnit(1);
|
||||
settings->setBaseShadowTextureUnit(7);
|
||||
//settings->setMinimumShadowMapNearFarRatio(0);
|
||||
//settings->setNumShadowMapsPerLight(1);
|
||||
//settings->setShadowMapProjectionHint(osgShadow::ShadowSettings::ORTHOGRAPHIC_SHADOW_MAP);
|
||||
|
|
|
@ -51,7 +51,7 @@ namespace MWRender
|
|||
"} \n";
|
||||
|
||||
|
||||
MWShadow::MWShadow() : debugCamera(new osg::Camera), debugProgram(new osg::Program), testTex(new osg::Texture2D)
|
||||
MWShadow::MWShadow() : debugCamera(new osg::Camera), debugProgram(new osg::Program), debugTextureUnit(0)
|
||||
{
|
||||
debugCamera->setViewport(0, 0, 200, 200);
|
||||
debugCamera->setRenderOrder(osg::Camera::POST_RENDER);
|
||||
|
@ -67,13 +67,9 @@ namespace MWRender
|
|||
debugCamera->addChild(debugGeometry);
|
||||
osg::ref_ptr<osg::StateSet> stateSet = debugGeometry->getOrCreateStateSet();
|
||||
stateSet->setAttributeAndModes(debugProgram, osg::StateAttribute::ON);
|
||||
osg::ref_ptr<osg::Uniform> textureUniform = new osg::Uniform("texture", 0);
|
||||
osg::ref_ptr<osg::Uniform> textureUniform = new osg::Uniform("texture", debugTextureUnit);
|
||||
//textureUniform->setType(osg::Uniform::SAMPLER_2D);
|
||||
stateSet->addUniform(textureUniform.get());
|
||||
|
||||
testTex->setDataVariance(osg::Object::DYNAMIC);
|
||||
osg::ref_ptr<osg::Image> testImage = osgDB::readRefImageFile("resources/mygui/openmw.png");
|
||||
testTex->setImage(testImage);
|
||||
}
|
||||
|
||||
class VDSMCameraCullCallback : public osg::NodeCallback
|
||||
|
@ -560,10 +556,7 @@ namespace MWRender
|
|||
{
|
||||
osg::ref_ptr<osg::Texture2D> texture = sd->_texture;
|
||||
osg::ref_ptr<osg::StateSet> stateSet = debugGeometry->getOrCreateStateSet();
|
||||
if (true)
|
||||
stateSet->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON);
|
||||
else
|
||||
stateSet->setTextureAttributeAndModes(0, testTex, osg::StateAttribute::ON);
|
||||
stateSet->setTextureAttributeAndModes(debugTextureUnit, texture, osg::StateAttribute::ON);
|
||||
|
||||
unsigned int traversalMask = cv.getTraversalMask();
|
||||
cv.setTraversalMask(debugGeometry->getNodeMask());
|
||||
|
|
|
@ -12,13 +12,13 @@ namespace MWRender
|
|||
|
||||
virtual void cull(osgUtil::CullVisitor& cv);
|
||||
protected:
|
||||
const int debugTextureUnit;
|
||||
|
||||
osg::ref_ptr<osg::Camera> debugCamera;
|
||||
|
||||
osg::ref_ptr<osg::Program> debugProgram;
|
||||
|
||||
osg::ref_ptr<osg::Node> debugGeometry;
|
||||
|
||||
osg::ref_ptr<osg::Texture2D> testTex;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@ varying vec4 passColor;
|
|||
varying vec3 passViewPos;
|
||||
varying vec3 passNormal;
|
||||
|
||||
uniform int shadowTextureUnit0;
|
||||
varying vec4 shadowSpaceCoords;
|
||||
|
||||
#include "lighting.glsl"
|
||||
|
@ -104,6 +105,6 @@ void main(void)
|
|||
passNormal = gl_Normal.xyz;
|
||||
|
||||
// This matrix has the opposite handedness to the others used here, so multiplication must have the vector to the left. Alternatively it could be transposed after construction, but that's extra work for the GPU just to make the code look a tiny bit cleaner.
|
||||
mat4 eyePlaneMat = mat4(gl_EyePlaneS[1], gl_EyePlaneT[1], gl_EyePlaneR[1], gl_EyePlaneQ[1]);
|
||||
mat4 eyePlaneMat = mat4(gl_EyePlaneS[shadowTextureUnit0], gl_EyePlaneT[shadowTextureUnit0], gl_EyePlaneR[shadowTextureUnit0], gl_EyePlaneQ[shadowTextureUnit0]);
|
||||
shadowSpaceCoords = viewPos * eyePlaneMat;
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ varying vec4 passColor;
|
|||
varying vec3 passViewPos;
|
||||
varying vec3 passNormal;
|
||||
|
||||
uniform int shadowTextureUnit0;
|
||||
varying vec4 shadowSpaceCoords;
|
||||
|
||||
#include "lighting.glsl"
|
||||
|
@ -38,6 +39,6 @@ void main(void)
|
|||
uv = gl_MultiTexCoord0.xy;
|
||||
|
||||
// This matrix has the opposite handedness to the others used here, so multiplication must have the vector to the left. Alternatively it could be transposed after construction, but that's extra work for the GPU just to make the code look a tiny bit cleaner.
|
||||
mat4 eyePlaneMat = mat4(gl_EyePlaneS[1], gl_EyePlaneT[1], gl_EyePlaneR[1], gl_EyePlaneQ[1]);
|
||||
mat4 eyePlaneMat = mat4(gl_EyePlaneS[shadowTextureUnit0], gl_EyePlaneT[shadowTextureUnit0], gl_EyePlaneR[shadowTextureUnit0], gl_EyePlaneQ[shadowTextureUnit0]);
|
||||
shadowSpaceCoords = viewPos * eyePlaneMat;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ varying vec3 screenCoordsPassthrough;
|
|||
varying vec4 position;
|
||||
varying float depthPassthrough;
|
||||
|
||||
uniform int shadowTextureUnit0;
|
||||
varying vec4 shadowSpaceCoords;
|
||||
|
||||
void main(void)
|
||||
|
@ -23,6 +24,6 @@ void main(void)
|
|||
depthPassthrough = gl_Position.z;
|
||||
|
||||
// This matrix has the opposite handedness to the others used here, so multiplication must have the vector to the left. Alternatively it could be transposed after construction, but that's extra work for the GPU just to make the code look a tiny bit cleaner.
|
||||
mat4 eyePlaneMat = mat4(gl_EyePlaneS[1], gl_EyePlaneT[1], gl_EyePlaneR[1], gl_EyePlaneQ[1]);
|
||||
mat4 eyePlaneMat = mat4(gl_EyePlaneS[shadowTextureUnit0], gl_EyePlaneT[shadowTextureUnit0], gl_EyePlaneR[shadowTextureUnit0], gl_EyePlaneQ[shadowTextureUnit0]);
|
||||
shadowSpaceCoords = (gl_ModelViewMatrix * gl_Vertex) * eyePlaneMat;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue