Jump to content
  • Advertisement
Sign in to follow this  
AlexAlex

OpenGL 3D polylines and stippling pattern.

This topic is 4155 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!