[osg-users] 32bit DEPTH for RTT

Trajce Nikolov NICK trajce.nikolov.nick at gmail.com
Thu Oct 20 08:39:01 PDT 2016


Glenn,

this worked ... :-) ... Thanks for the hint ...

On Thu, Oct 20, 2016 at 5:02 PM, Trajce Nikolov NICK <
trajce.nikolov.nick at gmail.com> wrote:

> wops ..
>
> mx.makeLookAt(lightPosInViewSpace,lightPosInViewSpace+lightDirInViewSpace
> ,up)
>
> On Thu, Oct 20, 2016 at 5:00 PM, Trajce Nikolov NICK <
> trajce.nikolov.nick at gmail.com> wrote:
>
>> Thanks Glenn,
>>
>> actually I was expecting this. I have the math to get the light direction
>> in view space, just the construction of the light matrix in view space
>> hurts my head a bit ( I missed that part of the class :-) )
>>
>> vec3 lightDirInViewSpace;
>> vec3 lightPosInViewSpace;
>> mx.makeLookAt(lightPosInViewSpace,lightPosInViewSpace+lightP
>> osInViewSpace,up)
>>
>> Something like this?
>>
>> On Thu, Oct 20, 2016 at 4:04 PM, Glenn Waldron <gwaldron at gmail.com>
>> wrote:
>>
>>> There's your precision loss, you can't do that with ECEF coordinates or
>>> they will be truncated.
>>>
>>> Better idea: build your light matrix in view space on the CPU (instead
>>> of world space), and then use it on the view-space vertex in the shader.
>>> (You'll have to update it every time the camera moves, of course.)
>>>
>>>
>>> Glenn Waldron
>>>
>>> On Thu, Oct 20, 2016 at 10:00 AM, Trajce Nikolov NICK <
>>> trajce.nikolov.nick at gmail.com> wrote:
>>>
>>>> Hi Glenn,
>>>>
>>>> vec3 vVertex = vec3(gl_ModelViewMatrix * VertexMODEL);
>>>> worldSpaceVertex = osg_ViewMatrixInverse * vec4( vVertex, 1.0 );
>>>>
>>>> Part of VP
>>>>
>>>> On Thu, Oct 20, 2016 at 3:52 PM, Glenn Waldron <gwaldron at gmail.com>
>>>> wrote:
>>>>
>>>>> Nick, how did you calculate "worldSpaceVertex"?
>>>>>
>>>>> Glenn Waldron
>>>>>
>>>>> On Thu, Oct 20, 2016 at 9:13 AM, Trajce Nikolov NICK <
>>>>> trajce.nikolov.nick at gmail.com> wrote:
>>>>>
>>>>>> hehe .. ok :-) .. Maybe you give me a hint.
>>>>>>
>>>>>> I have F+ lighting (written by a friend of mine) and I have extended
>>>>>> it so local lights cast shadows (a bit of complex code - relatively
>>>>>> actually, but for me it is ;-) ). Works well for flat terrains with
>>>>>> reasonable sizes. I am trying to make it work with ECEF terrain (for
>>>>>> testing I use osgearth). The debug code works just fine, I am seeing the
>>>>>> renderings from the local lights are correct, so the light view matrix
>>>>>> passed to the shader is correct, but getting z-fights with
>>>>>> setInternalFormat(GL_DEPTH_COMPONENT); only. Here is my setup for
>>>>>> the RTT (it is texturearray):
>>>>>>
>>>>>> http://pastebin.com/Nnc2iA1F
>>>>>>
>>>>>> With DEPTH32bit (really naive approach, I "was" thinking fast the
>>>>>> increase of the DEPTH precision will solve this issue, just recently
>>>>>> started with reading papers and I must admit I am not a "shadowing expert").
>>>>>>
>>>>>> Further, I am calculating the Light View Matrix and passing it to the
>>>>>> shader - this one is correct as well, since I am seeing the light in the
>>>>>> scene with the z artifacts as I mentioned .... and this is my GLSL snippet:
>>>>>>
>>>>>> http://pastebin.com/r2W0gh0L
>>>>>>
>>>>>> I am trying to get it done as simple as is ... meanwhile found this:
>>>>>>
>>>>>> http://developer.download.nvidia.com/SDK/10/direct3d/Source/
>>>>>> VarianceShadowMapping/Doc/VarianceShadowMapping.pdf
>>>>>>
>>>>>> that looks promising and apparently should help with the Z issues.
>>>>>>
>>>>>> This is my story for now, any hints are highly appreciated !!!!!
>>>>>>
>>>>>> And thanks a bunch for so far!
>>>>>>
>>>>>> Cheers,
>>>>>>
>>>>>> On Thu, Oct 20, 2016 at 2:56 PM, Voerman, L. <l.voerman at rug.nl>
>>>>>> wrote:
>>>>>>
>>>>>>> yes?
>>>>>>> we use a variation on OpenSceneGraph\src\osgShadow\P
>>>>>>> arallelSplitShadowMap.cpp
>>>>>>> regards, Laurens.
>>>>>>>
>>>>>>> On Thu, Oct 20, 2016 at 2:35 PM, Trajce Nikolov NICK <
>>>>>>> trajce.nikolov.nick at gmail.com> wrote:
>>>>>>>
>>>>>>>> Hi Laurens,
>>>>>>>>
>>>>>>>> do you have experience with DEPTH32bit and shadowcomparation set to
>>>>>>>> true - for shadow mapping?
>>>>>>>>
>>>>>>>> On Thu, Oct 20, 2016 at 12:08 PM, Trajce Nikolov NICK <
>>>>>>>> trajce.nikolov.nick at gmail.com> wrote:
>>>>>>>>
>>>>>>>>> Hi Voerman,
>>>>>>>>>
>>>>>>>>> Yes, GL_DEPTH_COMPONENT32 was what I was missing ... Thanks a lot!
>>>>>>>>>
>>>>>>>>> Trajce
>>>>>>>>>
>>>>>>>>> On Thu, Oct 20, 2016 at 9:25 AM, Voerman, L. <l.voerman at rug.nl>
>>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>>> Hi Trajce,
>>>>>>>>>> maybe this sniplet helps?
>>>>>>>>>> _textureDepthBuffer = new osg::Texture2D;
>>>>>>>>>> _textureDepthBuffer->setTextureSize(_width+2.0f*_width*_guardBandPercentage,
>>>>>>>>>> _height+2.0f*_height*_guardBandPercentage);
>>>>>>>>>> _textureDepthBuffer->setSourceFormat(GL_DEPTH_COMPONENT);
>>>>>>>>>> _textureDepthBuffer->setInternalFormat(GL_DEPTH_COMPONENT32);
>>>>>>>>>> _textureDepthBuffer->setFilter(osg::Texture2D::MIN_FILTER,os
>>>>>>>>>> g::Texture2D::NEAREST);
>>>>>>>>>> _textureDepthBuffer->setFilter(osg::Texture2D::MAG_FILTER,os
>>>>>>>>>> g::Texture2D::NEAREST);
>>>>>>>>>> _textureDepthBuffer->setShadowComparison(false);
>>>>>>>>>> _textureDepthBuffer->setWrap(osg::Texture::WRAP_R,osg::Textu
>>>>>>>>>> re::CLAMP_TO_EDGE);
>>>>>>>>>> _textureDepthBuffer->setWrap(osg::Texture::WRAP_S,osg::Textu
>>>>>>>>>> re::CLAMP_TO_EDGE);
>>>>>>>>>>
>>>>>>>>>> // camera
>>>>>>>>>> _colorDepthCamera = new osg::Camera;
>>>>>>>>>> _colorDepthCamera->setStats(new osg::Stats("Camera"));
>>>>>>>>>> _colorDepthCamera->setName("colorDepth");
>>>>>>>>>> _colorDepthCamera->setClearMask(GL_COLOR_BUFFER_BIT |
>>>>>>>>>> GL_DEPTH_BUFFER_BIT);
>>>>>>>>>> _colorDepthCamera->setReferenceFrame(osg::Transform::RELATIV
>>>>>>>>>> E_RF);
>>>>>>>>>> // set viewport
>>>>>>>>>> _colorDepthCamera->setViewport(0,0,_width+2.0f*_width*_guard
>>>>>>>>>> BandPercentage,_height+2.0f*_height*_guardBandPercentage);
>>>>>>>>>> _colorDepthCamera->setRenderOrder(osg::Camera::PRE_RENDER,0);
>>>>>>>>>> _colorDepthCamera->setRenderTargetImplementation(osg::Camera
>>>>>>>>>> ::FRAME_BUFFER_OBJECT);
>>>>>>>>>> _colorDepthCamera->attach(osg::Camera::DEPTH_BUFFER,
>>>>>>>>>> _textureDepthBuffer.get(),0,0,false,0,0); // depth
>>>>>>>>>> _colorDepthCamera->attach(osg::Camera::COLOR_BUFFER,
>>>>>>>>>> _textureColorBuffer.get(),0,0,false,_msaa,_msaa); // color
>>>>>>>>>> regards, Laurens.
>>>>>>>>>>
>>>>>>>>>> On Wed, Oct 19, 2016 at 11:15 PM, Trajce Nikolov NICK <
>>>>>>>>>> trajce.nikolov.nick at gmail.com> wrote:
>>>>>>>>>>
>>>>>>>>>>> Hi Community,
>>>>>>>>>>>
>>>>>>>>>>> anyone with clue how to set RTT osg::Texture with 32bit DEPTH?
>>>>>>>>>>>
>>>>>>>>>>> Thanks a bunch as always!
>>>>>>>>>>> Cheers,
>>>>>>>>>>> Nick
>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>>>> trajce nikolov nick
>>>>>>>>>>>
>>>>>>>>>>> _______________________________________________
>>>>>>>>>>> osg-users mailing list
>>>>>>>>>>> osg-users at lists.openscenegraph.org
>>>>>>>>>>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-opens
>>>>>>>>>>> cenegraph.org
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> _______________________________________________
>>>>>>>>>> osg-users mailing list
>>>>>>>>>> osg-users at lists.openscenegraph.org
>>>>>>>>>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-opens
>>>>>>>>>> cenegraph.org
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> trajce nikolov nick
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> trajce nikolov nick
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> osg-users mailing list
>>>>>>>> osg-users at lists.openscenegraph.org
>>>>>>>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-opens
>>>>>>>> cenegraph.org
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> osg-users mailing list
>>>>>>> osg-users at lists.openscenegraph.org
>>>>>>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-opens
>>>>>>> cenegraph.org
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> trajce nikolov nick
>>>>>>
>>>>>> _______________________________________________
>>>>>> osg-users mailing list
>>>>>> osg-users at lists.openscenegraph.org
>>>>>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-opens
>>>>>> cenegraph.org
>>>>>>
>>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> osg-users mailing list
>>>>> osg-users at lists.openscenegraph.org
>>>>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-opens
>>>>> cenegraph.org
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> trajce nikolov nick
>>>>
>>>> _______________________________________________
>>>> osg-users mailing list
>>>> osg-users at lists.openscenegraph.org
>>>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-opens
>>>> cenegraph.org
>>>>
>>>>
>>>
>>> _______________________________________________
>>> osg-users mailing list
>>> osg-users at lists.openscenegraph.org
>>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-opens
>>> cenegraph.org
>>>
>>>
>>
>>
>> --
>> trajce nikolov nick
>>
>
>
>
> --
> trajce nikolov nick
>



-- 
trajce nikolov nick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20161020/9deb0a89/attachment-0003.htm>


More information about the osg-users mailing list