<div dir="ltr">Ouch bad link: <div><br></div><div><a href="https://github.com/openscenegraph/OpenSceneGraph/blob/master/src/osgPlugins/gles/TangentSpaceVisitor.cpp#L46">https://github.com/openscenegraph/OpenSceneGraph/blob/master/src/osgPlugins/gles/TangentSpaceVisitor.cpp#L46</a><br></div><div><br></div><div>this one is the right one!</div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-11-08 9:19 GMT+01:00 Jordi Torres <span dir="ltr"><<a href="mailto:jtorresfabra@gmail.com" target="_blank">jtorresfabra@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Romulo, <div><br></div><div>You can use TangentSpaceGenerator to get the values of the T B and N. Here you have a code example: <a href="https://github.com/sketchfab/osg/blob/5d35b2a2d55e92b4c736ea5edcd9eeedf9ea6786/src/osgPlugins/gles/TangentSpaceVisitor.cpp#L46" target="_blank">https://github.com/<wbr>sketchfab/osg/blob/<wbr>5d35b2a2d55e92b4c736ea5edcd9ee<wbr>edf9ea6786/src/osgPlugins/<wbr>gles/TangentSpaceVisitor.cpp#<wbr>L46</a></div><div><br></div><div>Cheers. </div></div><div class="gmail_extra"><div><div class="h5"><br><div class="gmail_quote">2017-11-07 21:48 GMT+01:00 Rômulo Cerqueira <span dir="ltr"><<a href="mailto:romulogcerqueira@gmail.com" target="_blank">romulogcerqueira@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I have used normal mapping using GLSL and OSG for my application (an imaging sonar simulation) and I got problems by calculating the TBN matrix on shaders. The normal vectors contain lower resolution on border in comparison with the center of image.<br>
<br>
Follows my vertex code:<br>
<br>
Code:<br>
<br>
#version 130<br>
<br>
out vec3 pos;<br>
out vec3 normal;<br>
out mat3 TBN;<br>
<br>
void main() {<br>
    pos = (gl_ModelViewMatrix * gl_Vertex).xyz;<br>
    normal = gl_NormalMatrix * gl_Normal.xyz;<br>
<br>
    vec3 n = normalize(normal);<br>
    vec3 t = normalize(cross(normal, vec3(-1,0,0)));<br>
    vec3 b = cross(t, n) + cross(n, t);<br>
    TBN = transpose(mat3(t,b,n));<br>
<br>
    gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;<br>
    gl_TexCoord[0] = gl_MultiTexCoord0;<br>
}<br>
<br>
<br>
<br>
<br>
Part of my fragment code:<br>
<br>
Code:<br>
<br>
#version 130<br>
<br>
in vec3 pos;<br>
in vec3 normal;<br>
in mat3 TBN;<br>
uniform sampler2D normalTexture;<br>
<br>
void main() {<br>
    vec3 newNormal = (texture2D(normalTexture, gl_TexCoord[0].st).rgb * 2.0 - 1) * TBN;<br>
    newNormal = normalize(newNormal);<br>
...<br>
}<br>
<br>
<br>
<br>
<br>
The resulting figure is attached.<br>
<br>
How can I calculate the TBN matrix to compute the normal mapping properly?<br>
<br>
Thanks in advance,<br>
<br>
<br>
...<br>
<br>
Thank you!<br>
<br>
Cheers,<br>
Rômulo[/img]<br>
<br>
------------------<br>
Read this topic online here:<br>
<a href="http://forum.openscenegraph.org/viewtopic.php?p=72324#72324" rel="noreferrer" target="_blank">http://forum.openscenegraph.or<wbr>g/viewtopic.php?p=72324#72324</a><br>
<br>
<br>
<br>
<br>
Attachments:<br>
<a href="http://forum.openscenegraph.org//files/screenshot_from_2017_11_06_23_00_48_832.png" rel="noreferrer" target="_blank">http://forum.openscenegraph.or<wbr>g//files/screenshot_from_2017_<wbr>11_06_23_00_48_832.png</a><br>
<br>
<br>
______________________________<wbr>_________________<br>
osg-users mailing list<br>
<a href="mailto:osg-users@lists.openscenegraph.org" target="_blank">osg-users@lists.openscenegraph<wbr>.org</a><br>
<a href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" rel="noreferrer" target="_blank">http://lists.openscenegraph.or<wbr>g/listinfo.cgi/osg-users-opens<wbr>cenegraph.org</a><br>
</blockquote></div><br><br clear="all"><div><br></div></div></div><span class="HOEnZb"><font color="#888888">-- <br><div class="m_1124814308546280955gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Jordi Torres<br><br><br></div></div>
</font></span></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Jordi Torres<br><br><br></div></div>
</div>