CPU Picking (low-latency raycast) #5998
-
|
Hi Filament team, I was hoping you could clarify your previous advice on directly raycasting touches. I've been stuck a few days debugging my (CPU) screen touch -> world coordinate function. I'm using Filament's C++ API on iOS: Goal is:
I'm converting NDC -> View-Space -> World-Space, following @pixelflinger's previous advice here:
Here's my code (touches appear slightly off, misses more badly as I pan the camera left/right): I have a few specific questions:
Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
You should put You are forgetting to "divide-by-w" when you apply the The "inverse transpose" business is just how you transform vectors (like normals or other), for vectors, you can't apply the matrix just like you would for vertices. e.g. if you want to transform a vertex I think your biggest "mistake" is to not set Hope this helps! Let us know. |
Beta Was this translation helpful? Give feedback.

You should put
1.0in thewcomponent of your clip-space coordinate.You are forgetting to "divide-by-w" when you apply the
inverse(projection). You should be doing:The "inverse transpose" business is just how you transform vectors (like normals or other), for vectors, you can't apply the matrix just like you would for vertices. e.g. if you want to transform a vertex
vby the matrixM, you doM*v, but if you need to transform a vector (e.g. a normal) you need to doinverse(transpose(M))*v. At least that's what most people use, but it is actually incorrect in some case, the "real" correct way to do it is to use thecofactor(M). So I sug…