Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

880103 Posts in 33021 Topics- by 24386 Members - Latest Member: tu3sday

May 25, 2013, 06:55:16 PM
TIGSource ForumsDeveloperTechnical (Moderators: Glaiel-Gamer, ThemsAllTook)best way to draw outlines?
Pages: [1]
Print
Author Topic: best way to draw outlines?  (Read 632 times)
stevesan
Level 3
***


Experienced coder, n00b designer.


View Profile WWW
« 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:

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) Huh?
Logged

Evan Balster
Level 10
*****


dreaming close to metal


View Profile WWW Email
« Reply #1 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.
Logged

Infinite Blank, SoundSelf, Cave Story+, Wreath
voice, accordion, mandolin, (oboe, soon)
Game audio programming consultant.
<plaid/audio>: opensource audio framework
stevesan
Level 3
***


Experienced coder, n00b designer.


View Profile WWW
« Reply #2 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.
Logged

stevesan
Level 3
***


Experienced coder, n00b designer.


View Profile WWW
« Reply #3 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.
Logged

kamac
Level 10
*****


Notorious posts editor


View Profile WWW Email
« Reply #4 on: August 11, 2012, 11:34:41 AM »

I don't understand. Why not fragment shader?  WTF
Logged

Polly
Level 2
**


View Profile
« Reply #5 on: August 11, 2012, 02:10:50 PM »

Why do you want / need to texture the outlines to begin with?
Logged
stevesan
Level 3
***


Experienced coder, n00b designer.


View Profile WWW
« Reply #6 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.
Logged

Polly
Level 2
**


View Profile
« Reply #7 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?

Logged
stevesan
Level 3
***


Experienced coder, n00b designer.


View Profile WWW
« Reply #8 on: August 22, 2012, 09:01:35 PM »

So for my game, I ended up just creating outline geometry and texturing it: Notice the subtle pseudo-shadow-gradient. I like the look.
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic