Jump to content
  • Advertisement
Sign in to follow this  
devdept

OpenGL [D3D] Showing wireframe over shaded geometry

This topic is 4196 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

Hi All, To get good results, in OpenGL exists a function to offset the wireframe 'just a little bit' closer than the filled polygons. Can this be done with Direct3D? Thanks so much guys. Alberto

Share this post


Link to post
Share on other sites
Advertisement
When you say a just a little bit closer, you mean that it makes the wireframe draw above the filled polygons so that you see both the solid mesh and it's edges?
If so, then the problem is that since they both are at the same distance from the camera, Direct3D will not know who should be drawn (its called z-fighting or flimmering). There are many ways of solving this. One is to disable the Z-Buffer or disabling the Z-Writing temporarily and then Direct3D won't confuse between the depths. Another technique is to use the Z-Bias but I have suspicions about that one, it didn't seem to work last time I tried. You can also use stenciling to solve this but it's a bit more complicated; search for how to use 'decals' if you want to use this method.
Hope this helped,
Uri

Share this post


Link to post
Share on other sites
Decals?!?

I knew about the stencil approach but not about Z-bias.

I will try to fid something with google...

Thanks,

Alberto

Share this post


Link to post
Share on other sites
I think the "function to offset the wireframe 'just a little bit' closer than the filled polygons" is just Z-bias :)

You can do it in Direct3D by doing this :

float zBias = 0.01f; // your 'offset' value. Play with it until you get good results
pD3DDevice->SetRenderState(D3DRS_DEPTHBIAS, *(DWORD *)&zBias);

Share this post


Link to post
Share on other sites
Thanks a lot paic,


So I:

1) Set the zBias = 0.0f;
2) Draw shaded triangles
3) Set the zBias = 0.01f;
4) Draw wireframe triangles

Ok?

Alberto

Share this post


Link to post
Share on other sites
Thanks a lot Jack,


Looks like zBias doesn't work for lines... What if I need to outline a mesh of 4x4 = 16x2 = 32 triangle with 4+4+4+4 lines?!?


Alberto

Share this post


Link to post
Share on other sites
Another technique is to modify your projection matrix to push the near plane out a little which essentially brings all generated depth values back a bit. This would only be worth doing if you can batch your stuff such that all solid stuff is drawn and then modify proj matrix then render all wire stuff. It seems to work relatively well in practise.

Share this post


Link to post
Share on other sites
Quote:
Original post by devdept
Thanks a lot Jack,


Looks like zBias doesn't work for lines... What if I need to outline a mesh of 4x4 = 16x2 = 32 triangle with 4+4+4+4 lines?!?


Alberto

Couldn't you apply the depth bias to the solid object and leave the lines at the original depth?

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!