Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Line width and style in Direct3D10/11


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 leonard2012   Members   -  Reputation: 167

Like
0Likes
Like

Posted 06 May 2012 - 08:54 PM

My problem is how to render lines with different width and styles, or what's the D3D equivalent to glLineWidth and glLineStipple. I've searched the web and found D3DXLine class serves my need well. However, D3DX is no longer available in Windows 8 SDK (http://msdn.microsoft.com/en-us/library/windows/desktop/ee663275.aspx) and so it makes no sense to use it in my application. Could some please suggest a method to do this? Thanks.

Sponsor:

#2 MJP   Moderators   -  Reputation: 11736

Like
1Likes
Like

Posted 06 May 2012 - 09:04 PM

There is no way to adjust line width, the API only provides rendering of 1-pixel-wide lines. If you want something else you'll have to roll your own solution. One possible approach might be to use a sprite renderer to draw your lines.

#3 leonard2012   Members   -  Reputation: 167

Like
0Likes
Like

Posted 06 May 2012 - 10:13 PM

There is no way to adjust line width, the API only provides rendering of 1-pixel-wide lines. If you want something else you'll have to roll your own solution. One possible approach might be to use a sprite renderer to draw your lines.

Thank you for your quick response MJP. It's hard to believe there is no line width/style support in the latest D3D, whereas the same feature was available in OpenGL 1.0. I take a look at DirectXTK and find no direct reference on line rendering. I'll read the DirectXTK documentation later. Anyway, is there any other approach to line width/style rendering. Someone suggest to use geometry shader but does not offer the code sample.

#4 MJP   Moderators   -  Reputation: 11736

Like
1Likes
Like

Posted 06 May 2012 - 11:51 PM

In general D3D11 doesn't expose features that aren't supported by the hardware, which is surely why there is no option for line width. I'm no OpenGL expert, but a quick search seems to indicate that line widths > 1.0 aren't supported in the core profile since version 3.2.

One way to generalize lines on GPU's is by rendering quads with width and height determined based on the thickness and length of the line you want to render. A sprite renderer will essentially render and batch quads, which is why I suggested using one and linked you to DirectXTK. A sprite renderer will also let you apply a texture, which can let you approximate antialiasing as well as different line styles. Another possible quad-based approach is to render a quad that covers the the screen-space area covered by a line, and then use a pixel shader to analytically determine coverage and rasterize the line. This article explains how to do this.

A geometry shader is generally used for expansion from one primitive to multiple primitives. An example would be taking a single point/vertex as input, and emitting a quad as an output. This is done frequently for particle systems, and could also be used in a sprite or line renderer to expand points to quads. You could also take a line primitive and emit a quad as a means implementing line thickness.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS