Render pick is ignoring alpha

Running into a render pick problem. I’m using instancing for a broken up 3D model. I’m drawing 93 different shapes, and since instancing won’t do geometry, I have an alpha shape bitmap for each one.

when I draw them all instanced it works as intended, but when render picking, it’s returning instance ID from the square that is holding the texture, not the actual pixels.

I’ve tried all the discard pixels by alpha and stuff like that but no joy. The textures are in a texture array and are indexed by the W if that matters.

I guess my next workaround will be to try doing 93 geos instead of instancing just for the picking, but it feels like a bug to not ignore fully transparent pixels when picking.

Bruce

Hi @bwheaton,

render picking taking into consideration the transparency of a texture is currently not possible.

If you just need the Instance ID of the rendered object, would it be possible to encode the id into a color channel, render it with a second buffer and extract it with a TOP to CHOP or .sample() method?

cheers
Markus

I’ll look at those. I’m actually down this rabbit hole because the render pick doesn’t seem to report primitive number. I moved to instances to help solve that and help with dynamic positioning.

Can I add an attribute per primitive and get that from the render picker?

I guess I can use instances still if I encode the instance id into a color channel or separate buffer? Can I render pick from a different buffer?

Yes, you can manually add a primitive ID attribute and get that out of the render picking. It won’t fix the issue with alpha though. The problem is the main rendering shader is not used doing a render-pick. So the full-final output color of the render is not computed, so the alpha-test can’t be applied properly. I’ll see if this can be improved though

Hi @bwheaton,

just as an illustration of what I wrote above - the attached example is making use of a custom instance attribute which contains the texture index (alternatively you could also use TDInstanceID() directly in the shader but I thought this gives a bit more possibilities in case instance id and object id don’t match.)
This is passed from the vertex shader to the pixelshader and written into an extra color buffer.
To retrieve it, I make use of a TOP To CHOP. You could combine this with a Renderpick which onEvent checks if the result from the TOP To CHOP contains a valid number…

If you are using a orthographic camera, you could also distribute each instance in depth and encode it’s id via that, making a shader unnecessary and reading the id from a Depth TOP directly via the same method of the TOP To CHOP.

Hope this helps
cheers
Markus
customAttribute.toe (7.2 KB)