[osg-users] Displaying the normals of your models

Sebastian Messerschmidt sebastian.messerschmidt at gmx.de
Fri Dec 1 01:22:11 PST 2017


Hi,

alternatively you can setup a geometry shader to run a second pass [1]:

layout(triangles) in;
layout(line_strip, max_vertices=6) out;

// (projection * view * model) matrix
uniform mat4 proj_view_model;

// length of the normal (object space)
uniform float normal_length;

in vec3 normal;

out NDData {
     vec3 normal;
} nd_out;

void main() {
    for (int i = 0; i < 3; i++) {
        gl_Position = gl_in[i].gl_Position;
        nd_out.normal = normal;
        EmitVertex();
        gl_Position = gl_in[i].gl_Position +
            proj_view_model * vec4(normal * normal_length, 0.f);
        nd_out.normal = normal;
        EmitVertex();
        EndPrimitive();
    }
}

[1] from: https://wiki.delphigl.com/index.php/shader_normal_debug_330

Cheers
Sebastian

> Hi everyone,
> 
> I have to debug a normal issue with my model, so I made a code to display them (transform normals in a bunch of gl_lines and create a resulted geometry).
> 
> I share the gist in case it may help:
> https://gist.github.com/fulezi/95a9ac319fd1cbeca1b18a4cde3986dc
> 
> 
> 
> Have a nice day,
> Florian
> 
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=72504#72504
> 
> 
> 
> 
> 
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> 


More information about the osg-users mailing list