Jump to content
  • Advertisement
Sign in to follow this  
resle

(Webgl) Glsl silhouette

This topic is 2520 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,
I went on porting a simple 3d engine to webgl and noticed that GlPolygonMode and more importantly GlLineWidth have both been deprecated. Given that, could anyone point me to some tutorial on how to draw a toon outline using glsl? (perhaps - from what I "sniffed" on google - in image space?)

Thanks

Andrea

Share this post


Link to post
Share on other sites
Advertisement
Oww... no answers, looks badder than I thought. By the way I came back for a little update: image space is unluckily unusable in my rendering scenario, so I am now trying to search for object space ways of outlining a mesh.

It puzzles me the solutions of this problem was so straightforward with fixed function, and with little performance loss despite rendering every mesh twice, and it's an ungooglable riddle now with shaders..

Share this post


Link to post
Share on other sites
Two ways:
1 - As postprocessing: Render the normals/depth to a framebuffer, use a fragment shader to detect sillouette
2 - Use the old trick: Draw the mesh twice, first as normal, 2nd pass with black material, invert culling mode, and extrude/scale the vertices in the normals direction.

Share this post


Link to post
Share on other sites

Two ways:
1 - As postprocessing: Render the normals/depth to a framebuffer, use a fragment shader to detect sillouette
2 - Use the old trick: Draw the mesh twice, first as normal, 2nd pass with black material, invert culling mode, and extrude/scale the vertices in the normals direction.


Thanks Relfos, the 2nd technique sounds good for my case. I tried it by scaling the mesh in the 2nd pass by simple model matrix scaling. The result looks like this: scaling is probably a bit too simplistic for
some types of geometric shapes, also it doesn't take into account the object's own scale. (I can more or less guess what "extruding" means [moving a vertex on its normal?] but I am not sure I know how to do it, also I haven't per-vertex normals data)

nogood.png

Share this post


Link to post
Share on other sites
Any hint on the 2nd method - image space? I could try bending some parts of the engine to make it fit...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!