3D polylines and stippling pattern.

Started by
2 comments, last by tweduk 16 years, 9 months ago
Hey, In my application I wish to render lines specified using 3D coordinates that have a stippling pattern (i want to render dashed and dash-dotted lines). I am used to OpenGL where I can specify the line stipple pattern and the lines will be rendered in the correct line style. In Direct3D I tried to use ID3DXLine, however it renders lines only in screen space (DrawTransform transforms them to screen-space and then renders them) and I don't get the effect of depth-buffering. Eventually I simulated line-stippling using textures (alpha textures + alpha test). But it means that every time the line moves or the camera moves I need to update the texture coordinates so that the stippling pattern will always have the same size, regardless of the real size of the line on the screen (the dashes must always be N pixels long, for example). Does anybody here have a more elegant solution to this problem? Maybe an idea using shaders? Alex.
Advertisement
I'm not aware of any particularly elegant solutions here - and it's one of the common complaints from those doing visualization/modelling tools.

Looking through the ToC of books like ShaderX and GPU Gems might reveal some useful tricks. Also check out the AMD and Nvidia SDK's to see if they have anything useful, but I doubt you'll find a ready-to-go out-of-the-box solution.

Later shader models (3 & 4) are very powerful for procedural rendering, so you could definitely impliment a high quality solution via this method. All depends how important this is and how much effort you're willing to put in.

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

It is very important for our application as it is what the users are used to.

We have an existing working system and we are rewriting its GUI using new technologies (so that adding new features will be easier and faster). The users of our final product should see and feel something similar to what they are used to so it is very important to implement this feature.

As a developer I would like to implement it in the most elegant and yet efficient way so that the developers that come after me will easily understand the code and will be able to maintain it.

I hope I find something useful in those books.

Alex.
I am writing a modelling tool, and I have the same problem. I want to draw stippled lines whose start and end points are in some 3D coordinate system. I seem to remember that in previous versions of DirectX, there were render states for stippling, but they were dropped at some point.

I came to the conclusion that only reasonable way to do it in DX9/DX10 is to write a shader that procedurally generates the colour for each pixel of the stippled line. This will require extra data to be passed along with the vertices.

This topic is closed to new replies.

Advertisement