Jump to content

[SOLVED] Selection pass


photo

Recommended Posts

I'm trying to write a program that allows a user to select objects in the scene. Typically a ray-intersection would do, except my scene contains many deferred decals that I'd also like to be able to select (so a ray cast won't work since they don't have geometry).

 

In past projects (not using Unigine) I've rendered a "selection pass" where each object is rendered with a unique ambient material color (e.g. object 1 = (0,0,1), object 2 = (0,0,2), ... object 255 = (0,0,255), object 256 = (0,1,0), etc.), then reading off the object index by looking at the color value under the cursor. Does anyone have any recommendations on doing something like this with Unigine? Can the auxilliary pass be used for this?

 

Thanks,

Kevin

Link to comment

Auxiliary pass seems to be the right approach. We used such an approach for Infrared view simulation. All materials have been extended to support auxiliary color definition.    

 

post-82-0-71807600-1438858556_thumb.jpg

 

The only problem I see at the moment is the CPU-readback of the auxiliary texture for evaluation of the color values at a specific location. I don't think there is any available script/c++ function for auxiliary texture access yet. This might therefore require engine source code modifications.

 

       

Link to comment
×
×
  • Create New...