opengl - 2D Rectangle stroke in GLSL -


i'm attempting draw rectangle modern opengl using shader fill , stroke. i'm sending fill color, stroke color , stroke width uniform block in fragment shader (along rectangle position , size). recommended way setting stroke fragments stroke color , fill fragments fill color?

at moment, have 2 ideas floating in head. first, if statement checks whether frag coordinate within bounds of rectangle or rectangle stroke , set frag color based on that. methods produce quite large complex if statement , when comes time rotate rectangle, may worse. (also, i've read branching in shader should avoided)

the second idea have use signed distance function determine color, unfamiliar using these , have idea don't sharp corners well.

am way off mark here? there perhaps better way this?

the fragment shader sounds stage late if want rasterise stroke. fragment shader executed after rasterisation process has been performed. if can make recommendation, i'd using geometry shader generate stroke's geometry on fly. though arguably incrementally adding data vbo best solution here (since majority of stroke not change on time). if resolution of drawing area not change, rendering stroke texture, , modifying that.


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -