Hello !
After years of using the D3D Rendersystem, I just tried the GL3+ Rendersystem to see how it performs.
I'm porting my custom shaders and everything is ok so far.
But I'm trying to add the support of hardware pcf, like in D3D11, as it is now possible with GLSL 330+.
So as specified in the various documentation I've found, I've implemented the functions related to texture comparison in the render system:
Code: Select all
void GL3PlusRenderSystem::_setTextureUnitCompareFunction(size_t unit, CompareFunction function)
{
if (!activateGLTextureUnit(unit))
return;
OGRE_CHECK_GL_ERROR(glSamplerParameteri(mTextureTypes[unit], GL_TEXTURE_COMPARE_FUNC, convertCompareFunction(function)));
activateGLTextureUnit(0);
}
void GL3PlusRenderSystem::_setTextureUnitCompareEnabled(size_t unit, bool compare)
{
if (!activateGLTextureUnit(unit))
return;
mTextureCompareEnabled = compare;
OGRE_CHECK_GL_ERROR(glSamplerParameteri(mTextureTypes[unit], GL_TEXTURE_COMPARE_MODE, compare ? GL_COMPARE_REF_TO_TEXTURE:GL_NONE));
activateGLTextureUnit(0);
}
And changed my pixel shader shadow sampling code from this :
Code: Select all
float shadow = (shadowMapPos.z <= texture(shadowMap, shadowMapPos.xy ).r) ? 1.0 : 0.0;
to this:
Code: Select all
float shadow = texture( shadowSampler, vec3(shadowMapPos.xy, shadowMapPos.z));
Which should do thejob, shadowSampler being a "sampler2DShadow", as requested.
However, the result is always 0, so something must be wrong, but I have no clue, except that this may not work with a texture type different from GL_DEPTH, but it's not clear, and I don't know if it's possible to use PF_DEPTH as a format for shadow textures in Ogre.
