picking ground and deferred rendering.


I’m doing my own ‘how to pick object with the mouse’ thread :wink:

Since I’ve used deferred lighting ( similar to the fireflies demo), I thought that I could create a easier ( and faster ?) solution to pick element than creating collision box for every object and casting a collisionRay.

I don’t need to know which object I picked, only its location.

So since I’ve got a depth Texture created for my rendering, I suppose than I can just look the value of my mouse position ( switched from (-1)-1 to the 0-1 range) inside the depth texture. from that, a little math give me the position.

first problem: how can I access a particular pixel inside my texture ? I’ve try a texture.pick() but it don’t give me anything.

Is this solution stupid, or far too slow ?


In order for Texture.peek() to work, you will need to copy the texture to RAM, rather than the default behavior of leaving it on the graphics memory. You can do this by setting the appropriate parameters when you bind the texture to the offscreen buffer. However, this will be really slow.



with GraphicsOutput.RTMCopyRam I can do a peek.

the performance lost are noticeable but I can cope with that for now.

I can access my diffuse texture now.
But If I do the same with my depth texture, I have a seg fault.

I suppose it’s because my depth texture is not a color ( Texture.FDepthStencil), and TexturePeeker can only access color ?

So far for this idea then, I though it was good.

Hmm, that’s possible. I will investigate.


if you investigate, here another precision: In fact with RTMCopyRAM, my depth texture doesn’t ‘works’, it’s fully blank,
I suppose the problem is linked to this post:
panda3d.org/forums/viewtopic … 5b3375cb4a

(except I’m on linux right now ( ubuntu 10.4, panda3d 1.7.0, 8600gt))