2

I've been trying to render silhouettes on CAD models with webgl. The closest i got to the desired result was with fwidth and a dot between the normal and the eye vector. I found it difficult to control the width though.

I saw another web based viewer and it's capable of doing something like this:

sillhouettes

I started digging through the shaders, and the most i could figure out is that this is analytical - an actual line entity is drawn and that the width is achieved by rendering a quad instead of default webgl lines. There is a bunch of logic in the shader and my best guess is that the vertex positions are simply updated on every render. This is a procedural model, so i guess that for cones and cylinders, two lines can always be allocated, silhouette points computed, and the lines updated.

If that is the case, would it be a good idea to try and do something like this in the shader (maybe it's already happening and i didn't understand it). I can see a cylinder being written to attributes or uniforms and the points computed.

Is there an approach like this already documented somewhere?

edit 8/15/17

I have not found any papers or documented techniques about this. But it got a couple of votes.

Given that i do have information about cylinders and cones, my idea is to sample the normal of that parametric surface from the vertex, push the surface out by some factor that would cover some amount of pixels in screen space, stencil it, and draw a thick line thus clipping it with the actual shape of the surface.

pailhead
  • 5,162
  • 2
  • 25
  • 46

2 Answers2

1

The traditional shader-based method is Gooch shading. The original paper is here:

http://artis.imag.fr/~Cyril.Soler/DEA/NonPhotoRealisticRendering/Papers/p447-gooch.pdf

solidpixel
  • 10,688
  • 1
  • 20
  • 33
  • 1
    I came across this but couldn't find any code that looked like it did edges it mostly talks about the color? Either way, what is specifically going on in the image above is that there are lines computed where a line segment should be a silhouette. This goes against the screen shots in the paper, this cannot be applied to the helix spring? Further meaning if this viewer is using something like that for arbitrary shapes for promitives it is definitely augmenting it with lines. – pailhead May 05 '17 at 17:29
0

The old fashing OpenGL technique from Jeff Lander

icebeat
  • 111
  • 1
  • 3
  • I ender up doing this by detecting the edges, basically I put another couple of attributes holding the normal of the two triangles the edge belongs to and checked in the shader if one of them is facing away from the camera while the other is facing towards. – pailhead Apr 11 '20 at 23:52