/* attempt to deal with prototype, bootstrap, jquery conflicts */ /* for dropdown menus */

Jump to content

Image of the Day

Today's #ScreenshotSaturday features Face Your Fears from Turtle Roc ... #virtualrealityshop #mobilevr #vrshop https://t.co/3qhSNAVNOZ
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net's newsletters to receive the latest updates and exclusive content.

Sign up now

How to draw some objects "always on top"?

4: Adsense

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
7 replies to this topic

#1 korvax   Members   


Posted 14 December 2012 - 07:33 AM

HI, I need some help. I have a simple 3d system where Im displaying the axes of an object. The problem is if the axes is inside the object I cant see them. So I would like to be able to draw them so they are always visible regardless where they are in the 3d space. Just as when you select an object in blender or 3ds, you will see the objects axes regarles where they are located in the object. anyone?

Just like this picture (taken from Blenders homepage, http://www.blender.org), you can see axes on the bears arm even if they are "inside" the arm
Posted Image

Im rendering in dx11.

#2 Ashaman73   Members   


Posted 14 December 2012 - 07:39 AM


Try to use the stencil buffer. Render the models which should be visible all the time first (write to a stencil bit to mark this pixels). Then render your scene but don't overwrite pixel where the stencil flag has been set.



Gnoblins: Website - Facebook - Twitter - Youtube - Steam Greenlit - IndieDB - Gamedev Log

#3 Burnt_Fyr   Members   


Posted 14 December 2012 - 12:01 PM

A simpler method IMO would be to draw all overlays last, disabling depth testing before hand.

#4 simpler   Members   


Posted 14 December 2012 - 12:46 PM

Using a D3D11_DEPTH_STENCIL_DESC with depth writes disabled does the trick. Something like this:

[source lang="cpp"] ID3D11DepthStencilState* EnableAllDSS; D3D11_DEPTH_STENCIL_DESC depthdesc; memset(&depthdesc, 0, sizeof(depthdesc)); depthdesc.DepthEnable = (BOOL) false; depthdesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ZERO; depthdesc.DepthFunc = D3D11_COMPARISON_NEVER; depthdesc.StencilEnable = (BOOL) false; HR(device->CreateDepthStencilState(&depthdesc, &EnableAllDSS));[/source]

Then just set EnableAllDDS as the depth stencil state when rendering the axis arrows and reset it when done rendering them.

#5 mhagain   Members   


Posted 14 December 2012 - 06:38 PM

You could also output depth 0 from the pixel shader used for drawing the axes (assuming less-equal depth testing and that this is not considered a performance-critical code-path).

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.

#6 Tom KQT   Members   


Posted 15 December 2012 - 03:09 AM

But without depth testing, it won't draw the coordinate system properly if it is a 3D object (which it is on the Blender example) - it won't do depth testing even between individual pixels of the axes and if let's say the blue arrow is partially hidden behind the green arrow, it can be rendered in a wrong way.

Isn't Ashaman73's solution the only proper one in this thread?

#7 eppo   Members   


Posted 15 December 2012 - 06:25 AM

If the arrows need to depth-test with themselves, but not the rest of the scene, you should render them using their own depth buffer (or clear the buffer before rendering the arrows).

Edited by eppo, 15 December 2012 - 06:28 AM.

#8 GeniusPooh   Members   


Posted 18 December 2012 - 12:45 AM

easiest way is just render Axis with no depth testing Posted Image

(d3d render state ztest off Posted Image just at drawins Axis and then turn it on Posted Image )

It's so easy I see some wrong answer above Posted Image

but you need self depth test? Am I right?

then you need mask like stencil and so many other way..

How about this?

draw Axis to other texture and compositing it Posted Image It's very easy and simple Posted Image

but you must draw 3 times but you can debug Axis and object so easily ..I never use stencil. and I think It's not necessary at all at over DX 9 Posted Image

any other help plz let me know Posted Image

Ah sorry you just need turn on off Z test that's all :) I confuse with others message

sorry I'm new here and I'm Korean

Edited by GeniusPooh, 18 December 2012 - 12:47 AM.

Beauty is only skin deep , ugly goes to bones


World's only 3D engine tunner and 3D engine guru.


and real genius inventor :) but very kind warm heart .. and having serious depression for suffering in Korea


www.polygonart.co.kr ( currently out dated and only Korean will change to English and new stuff when I get better condition :) sorry for that)

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.