As I know, we can set the line color before draw lines. Is it possible to write a fragment shader that can make the model edge a different color so that we do not need to draw edge in different color specially?
Asked
Active
Viewed 378 times
1
-
http://stackoverflow.com/questions/18035719/drawing-a-border-on-a-2d-polygon-with-a-fragment-shader – solidpixel Jul 28 '15 at 17:03
-
Thnaks! But in the solution you mentioned, it needs geometry shader which OpenGL ES 2.0 does not have. Is there any other way to solve this problem? @Isogen74 – Blaise Wang Jul 29 '15 at 15:54
-
The section "Without Geometry Shaders (OpenGL ES friendly)" in the above link might be a good start ... – solidpixel Jul 29 '15 at 19:07
-
Thank you any way, but that's not the result I want to make, so I have to draw lines to make that happen. Thank you. @Isogen74 – Blaise Wang Jul 30 '15 at 12:29
-
A dumber but simpler approach may be to 1) render the outlined object as normal and enable stencil operations such that the stencil buffer gets set at pixels where the model is rendered. Then, 2) prepare a second draw call where pixels get rejected if the stencil is marked, scale up the model slightly (the scale depends on how thick the outline would need to be but this may also need to be dependent on the view distance if you want to keep the outline thickness constant) and render the model again using a shader that simply outputs a uniform color for the outline. Sorry, no code :) – user8709 Aug 01 '15 at 06:36
-
Thank you. That's what I did to make it happen. @user8709 – Blaise Wang Aug 02 '15 at 08:22
1 Answers
0
FI know its old thread, but better than scaling up model. is a 2 pass shader, scale up on each vertex, by pushing vertex position out a bit more along the direction of the normal for that vertex. Works much better than scaling the model Scaling model only works for convex shapes (cubes, balls). For concave and complex shapes (humanoid) the normal-push version works.

Jon Hilliard
- 31
- 4