Login  Register

Re: How do I use stencil textures for outlining shapes?

Posted by imakerobots on Jun 26, 2023; 8:44pm
URL: https://forum.jogamp.org/How-do-I-use-stencil-textures-for-outlining-shapes-tp4042652p4042713.html

com/marginallyclever/robotoverlord/renderpanel/OpenGLTestStencil.java in the new-outline branch is my latest.  The goal is to trace the edge of a given mesh with a line of a given thickness.  My understanding is that I should write the shape I want to the stencil buffer, then run a jump-flood algorithm as described in

https://bgolus.medium.com/the-quest-for-very-wide-outlines-ba82ed442cd9

and for which there are JFA samples available at

https://www.shadertoy.com/view/4syGWK
https://www.shadertoy.com/view/WlGyR3

my latest is simply trying to render the stencil buffer to the view so that I can confirm the contents of the stencil buffer match the shape on screen.  to that end I render the quad at 90% size so i can confirm the position of the shape behind the quad.

if you run the test and pres 0-6 you will see different styles of triangles (some drawn with VBOs, some VAOs, etc).  keys 7-9 will use one of three different stencil-to-quad shaders that are trying to bring the stencil texture to the output.  So the most sophisticated test is 6-9.  The results are very odd.  I'd love to know what I'm doing wrong OR the "right" way.  I've already tried offset-along-normal, looks like crud with sophisticated shapes.  If there's another buffer I should use... cool, please point me to the tutorial.  

as an aside, I'd love to have a general way to display various buffers as in https://www.youtube.com/watch?v=PiQ_JLJKi0M