|
Title: best way to draw outlines? Post by: stevesan on August 11, 2012, 07:35:32 AM Hey folks,
I'm working on a 2D game which has lots of arbitrary polygons, and I would like to draw out lines on them. Much like the hills in Tiny Wings: (http://www.maclife.com/files/u310631/2011/01/tiny_wings.jpg) Just like that nice, grey outline on the hill. So, what's the best way to do that? A few options I can think of: 1) Use OGL's line drawing prims, but this won't allow texturing 2) Create and draw thin quads. 3) ??? Title: Re: best way to draw outlines? Post by: Evan Balster on August 11, 2012, 08:29:05 AM Basically the two things you said there. I don't know how you form your arbitrary polygons (whether they can be concave) but my system is to supply their outlines and triangulate them with GLUtessellator for the fills. The outlines can be used directly as polylines, or passed through a fatten/thin algorithm such as that in AngusJ's libclipper in order to give them thickness. Aforesaid system supports all kinds of geometry, excepting self-intersecting contours which will render the latter step's output ill-defined.
Note that the only way to consistently texture tessellated polygons is to have the texture coordinates be a linear transform of the vertex coordinates, as their vertices can be arranged many different ways and will often be broken into multiple primitives. The line, on the other hand, could be a tri-strip. There are some other techniques for outline-drawing which involve shaders; I doubt they're useful to you, but look up an article on toon shading for more intel on that. Title: Re: best way to draw outlines? Post by: stevesan on August 11, 2012, 10:30:46 AM Cool. I'll go with drawing thin quads then.
I have arbitrary non-self-intersecting polygons, and I've got triangulation code working, so I can fill them. Just need to add the outlines now. Title: Re: best way to draw outlines? Post by: stevesan on August 11, 2012, 10:32:56 AM A bit off topic, but the Tiny Wings hills are textured in a pretty cool way. My guess is that he just has a stripe texture, tessellates the hill into thin vertical strips which fit the hill curve, and then offsets the UV coordinates vertically a little bit with each strip.
Title: Re: best way to draw outlines? Post by: kamac on August 11, 2012, 11:34:41 AM I don't understand. Why not fragment shader? :wtf:
Title: Re: best way to draw outlines? Post by: Polly on August 11, 2012, 02:10:50 PM Why do you want / need to texture the outlines to begin with?
Title: Re: best way to draw outlines? Post by: stevesan on August 11, 2012, 04:52:19 PM I'd like some outlines to be dotted lines for this game. And maybe some other random effects. Just for the sake of details and polish.
Title: Re: best way to draw outlines? Post by: Polly on August 11, 2012, 05:31:28 PM I'd like some outlines to be dotted lines for this game. You're using a OpenGL version that doesn't support line stipple? Or doesn't that give you the desired effect? (http://i.imgur.com/2DLu0.png) Title: Re: best way to draw outlines? Post by: stevesan on August 22, 2012, 09:01:35 PM So for my game, I ended up just creating outline geometry and texturing it: (http://i.imgur.com/uQBCN.png) Notice the subtle pseudo-shadow-gradient. I like the look.
|