Hello Peterakos,

Have you checked if the tangent space gives you correct results if applied to lighting? Also I don't understand what you need the tangent space for. Usually the "fragment's normal" is what you already have in the normal-buffer, if you doing some sort of deferred shading. In this case you would write screenspace or viewspace normals to your normal-buffer and simply use them in the SSAO pass. Another issue that comes to mind is that there is no such thing as "the" tangent space of a single fragment, so maybe explain to us, what the tangent space is needed for in your opinion.

cheers
Sebastian
Hello.

I try to implement an ssao algorithm, but i cant figure out why the
grey artifacts appear (image 1).

Samples
-------
Here i create the sample points that will be checked:

//assume hemisphere
float radius = 1.0f;
for (int i=0; i<16; ++i) {
        osg::Vec3f sample = osg::Vec3f(
                getRandomFloat(-radius, radius),
                getRandomFloat(-radius, radius),
                getRandomFloat(0, radius)
        );
        sample.normalize();
        uni->setElement(i,sample);
}


Fragment Shader
------------
Here i create the tangent space based on fragment's normal (image 2):

vec3 normal = normalize( getFragNormal() * 2.0 - 1.0 );
vec3 temp_vec = vec3(normal.x, -normal.y, normal.z);
vec3 tangent = normalize(cross(temp_vec, normal));
vec3 bitangent = normalize(cross(normal, tangent));
mat3 tbn = mat3(tangent, bitangent, normal); //Do i have to transpose this ?


And here is the usage of tbn and sample:
vec4 sample_in_view_space = origin + vec4( tbn * sample_kernel[i] , 0);
where origin is the fragments world coordinates.
After that i project the sample back to window coordinates and i test
the depth value.

The first thing that comes to my mind is that i get grey pixels
because there are occluders for those pixels.
That shouldnt be happening, because the hemisphere is normal oriented
according to fragments normal.

Do i miss anything as fas as TBN matrix is concerned  ?
        
Thank you for your time and sorry for the long post.


_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to