windows runtime - Drawing over terrain with depth test? -


i'm trying render geometrical shapes on uneven terrain (loaded heightmap / shapes geometry generated based on averaged heights across heightmap not fit exactly). have following problem - somethimes terrain shows through shape showed on picture.

open image

i need draw both terrain , shapes depth testing enabled not obstruct other objects in scene.. suggest solution make sure shapes rendered on top ? lifting them not feasible... need replace colors of actual pixel on terrain , doing in pixel shader seems expensive..

thanks in advance

i had similar problem , how solved it:

  • you first render terrain , keep depth buffer. not render objects
  • render solid bounding box of shape want put on terrain.
  • you need make sure bounding box covers height range shape covers
  • an over-conservative estimation use global minimum , maximum elevation of entire terrain
  • in pixel shader, read depth buffer , reconstructs world space position
  • you check if position inside shape
  • in case can check if xy (xz) projection within given distance center of given circle
  • transform position shape's local coordinate system , compute desired color
  • alpha-blend on render target

this method results in shapes aligned terrain surface. not produce artifacts , works terrain. possible drawback requires using deferred-style shading , not know if can this. still, hope might helpful you.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -