How to draw lines like that ?
http://img269.imageshack.us/img269/2134/thrust.jpg
I really like the graphics of Thrust Deluxe and I wonder how best I could draw the same kind of lines ?
I can see they have these properties:
- anti aliased
- color gradient along the line
- the line junctions are brighter as if the line colors are added together
- there's a glow around the line which is added too
So,
1) Can I do it with GDI+ ?
as I want to write a C# 2D application
2) If not, how best could I do it in DirectX ? What kind of primitive (triangles or line) ? And which mode or type of shader to use ?
Thanks !
Based on the brightening at the junctions, my guess is that the glow isn't postprocessing, but rather based on additive blending of billboarded, pre-bloomed line textures multiplied by the line color. I'm not really familiar with the capabilities of GDI+, but Direct3D can do it easily. Your primitives would be rectangles, with per-vertex colors modulating the texture.
Quote:Original post by vlad2048
So,
1) Can I do it with GDI+ ?
as I want to write a C# 2D application
You could achieve this in GDI+ using GraphicsPath to make the shape of the glow, like a flattened capsule. The gradient effect can be achieved using LinearGradientBrush (I know these are the c++ links, but I'm not sure where the C# equivalent docs are).
However this would probably be a heck of a lot easier with DirectX.
Thanks a lot guys !
Sneftel:
I think you're right. But after trying there's a little subtelety. A 1D texture to draw the line is perfect, but I need to "cap" the line with half a disc on each side. So 3 billboards: 1 line + 2 caps. (And actually the caps don't "mesh" too well for successive lines, I think I'd be better off just drawing one single full disc for each line junctions)
_moagstar_:
I'm going to look into that right now. I'd rather use GDI+ if it's possible. I will report back
Sneftel:
I think you're right. But after trying there's a little subtelety. A 1D texture to draw the line is perfect, but I need to "cap" the line with half a disc on each side. So 3 billboards: 1 line + 2 caps. (And actually the caps don't "mesh" too well for successive lines, I think I'd be better off just drawing one single full disc for each line junctions)
_moagstar_:
I'm going to look into that right now. I'd rather use GDI+ if it's possible. I will report back
_moagstar_:
It seems the LinearGradientBrush only does Linear gradient.
But my line 1D pattern is not linear. It's very bright in the center (4/5 pixels) and then very dim to black outside. Nothing proportional there.
Do you still think it's possible with GDI+. And will the additive blending be possible with these lines ?
It seems the LinearGradientBrush only does Linear gradient.
But my line 1D pattern is not linear. It's very bright in the center (4/5 pixels) and then very dim to black outside. Nothing proportional there.
Do you still think it's possible with GDI+. And will the additive blending be possible with these lines ?
Sorry, my bad, you are probably better off with PathGradientBrush you can control the shape of the blend with that brush.
Hmmm, it doesn't look like additivie blending is an option - link. Thats going to be a problem, again, this will probably be much easier with directx.
Hmmm, it doesn't look like additivie blending is an option - link. Thats going to be a problem, again, this will probably be much easier with directx.
If you're not updating the image every frame and can be bothered to spend 10 minutes writing your own GDI drawing code (and consequently not worry about any API's), you can always write your own glow filter (draw lines using GDI+ or whatnot, or write your own antialiased line drawing code, or check online for source code on how to do that; for each line segment create a bounding box which extends N pixels away from the line in each direction, for each pixel in the bounding box calculate distance to line segment and modulate alpha by distance, do additive blend using max() as the term to decide whether to retain the source glow value or use the new one - meaning you won't get banding at the joints that Sneftel mentioned).
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement