2

I'm doing an isometric game and I would like to use height/normal data generated by a 3D program. Here's an example of an "object" data I have :

enter image description here

first one is the actual object, second one defines how high in world coordinate each pixel is, and the 3rd one describe what the normal for each pixel is.

Now, if I randomly place boxes on a screen, I am able to tell with the heightmap, for a given screen pixel (x,y), which box pixel should actually be rendered on top, this is what I call "pixel-perfect occlusion".

What would be the most efficient way to compute the final result of a scene (with the actual "box_color" images being drawn in the correct order) using this method? I can easily compute the resulting height map that would appear on screen using a shader , but how could this heightmap be used for correctly ordering the colored boxes?

genpfault
  • 51,148
  • 11
  • 85
  • 139
lezebulon
  • 7,607
  • 11
  • 42
  • 73
  • Can't see how it is possible in any efficient way. At each fragment you need to know positions(actual 3D position) of all objects and ability to calculate their dimensions to determine which one should be rendered. Instead you can just z-sort them and use alpha. – JAre May 27 '14 at 21:40
  • Can you just write to `gl_FragDepth` (with depth testing/writing enabled)? – GuyRT May 28 '14 at 13:31
  • You experts may perhaps know the answer to ... http://stackoverflow.com/questions/34952184/pixel-perfect-shader-in-unity – Fattie Jan 22 '16 at 17:04

0 Answers0