How to draw stylized lines

Started by
5 comments, last by XTAL256 14 years, 10 months ago
Hi, I'm looking for a way to draw lines, boxes, weird shapes (in 2D) and so far I can't think of anything that would let me do that. I always thought that it was the shaders that drew all the small hard to draw elements (such as for example a crooked line with ink splatters around it), but I just ead that shaders only manipulate how geometry is displayed and don't actually draw anything by themselves. Which methods are used to create such effects. BTW, all the drawing has to programmable, so for example the line can't just be a predrawn texture, it has to respond to the game in realtime.

You didn't come into this world. You came out of it, like a wave from the ocean. You are not a stranger here. -Alan Watts

Advertisement
Do you have an example of what you're talking about? For example, use of the technique you're describing in another game?

I would have imagined that textures were the most logical way to draw stuff like ink splatters...
Quote:Original post by Codeka
Do you have an example of what you're talking about? For example, use of the technique you're describing in another game?

I would have imagined that textures were the most logical way to draw stuff like ink splatters...


Well prety much any modern game, for example how can you draw a line then make it split when it hits the obstacle, or draw a glowing line or a pulsating one, basically what is that line made out of? Is it usaully done with vertecies/polygons or drawn pixels? A more direct question, I want to simply draw rounded glowing lines, and build a game similar to snake (more like Tron Light Cycles fltron.com) But I want to be able to control the width the curvature, glow, I want it to shatter when it hits the edge or opponent and those effects should all obey some realtime laws, not just be prescrited texture. How can this be accomplished?

You didn't come into this world. You came out of it, like a wave from the ocean. You are not a stranger here. -Alan Watts

What you're thinking of, I believe, is usually implemented as a particle effect, and is typically textured quads (i.e. lots of small squares, with a specific kind of texture map applied).

A quick google search turns up things such as this video - these "lines" actually a collection of textured quads.
Right something like that, but is doing particle simulation the only way? I mean just drawing a 2D line would require a particle engine?

You didn't come into this world. You came out of it, like a wave from the ocean. You are not a stranger here. -Alan Watts

A glowing line can be achieved by drawing 2 (or more) vertices using a LINESTRIP/LINELIST. After that, apply a glow effect to the backbuffer.

Either you render in two passes (a color and glow-buffer) or you use MRT. Either way, apply a horizontal and vertical gaussian blur to the glow-buffer and then blend it over the color buffer.

*edit* Of course, to draw lines, you need to enable wireframe drawing.
I should add that the glowing effect that you see in that video is done by blending effects. I once played around with that type of thing when i made a Windows Media Player visualization using OpenGL. OGL has some blend types that add/multiply/subtract/etc the source and destination pixels (i.e. the pixels already on screen and the pixels in the image to be drawn).

EDIT: wow, two posts while i was posting this. Ninja'd * 2
[Window Detective] - Windows UI spy utility for programmers

This topic is closed to new replies.

Advertisement