Point on plane at certain fragment coordinates

Hello, Blender artists!
I’ve got a “plane”. It is not an object(KX_GameObject), but just a data set which contains:

  • position
  • rotation(euler angles)
  • scale(local, always 0 at z axis)

I need to find out how far a point on this plane is from camera. That’s pretty simple - just (camera.position - point).length. However, my problem is finding that point. I need to find out if there is the plane at exact pixel coordinates and if there is, than I need to find out how far from camera is it. It’d be best to do in 2D filter.
Thanks

No! That’s what I am already doing. But I noted that the plane is just a set of data. It’s not being rendered, nor even exists as BGE format object(KX_GameObject). I can’t test for it’s Z depth…

Then you’ll have to compute it using the plane equation, vector projection etc.

Maybe you can give some hints.
How to find out the current fragment coordinate inside 2D filter?
How to find out how far the point on plane is when projected straight out of the camera’s position through the current fragment?

So want to check whether any pixels of the camera image contain a object and then calculate the distance?
Or do you want to map all camera pixels to global coordinate on the planes surface?

Why cant the plane be a game object rendered plane? (it doesn’t have to visible for the user)
Is obstruction/ partly visibility a thing? how to you plan retrieve the distance from the shader?

Sorry can’t really make sense what you want to achieve but it seems you are shaving a yak

Hi! What I need is as follows:
I need this all in 2D filter.
I need depth texture without the plane. It must contain all the visible scene data(I hope that Blender includes alpha clipping in depth texture).
I need to find out if the specific pixel has the plane on it and I need to find out how far the plane is at the specific pixel.
Than I can compare the distance between the depth texture sample and the point on the plane.

That’s all I need.:wink:

So, the problem seems to make sure that the specific camera pixel in question resides on and belongs to that plane? And distance is only a matter of raycast or detph texture..

Anyway you would have a lower res camera do the rendering for that kind of detection.
Lets leave the plane as a normal visible plane in game.
I would render the scene twice on that lowres camera, once with and once without the plane.
Then take the difference of those two images with ImageMix.
After that I would have to retrieve the image into a python list which is slow. We want to avoid doing that multiple times.
List index check whether that pixel ( you seem to know which, but as its a list,it doesnt matter anymore) has color.

If it does raycast or use the depth texture for distance.

Checking for visibility per pixel is quite hard to do.
IF you don’t need obstruction detection, just math it. Check whether the camera direction vector to the camera pixel intersects with the plane.

What my main question was - when I am in 2D filter - how do I find out the current fragment coordinates?

A new question(needed only if I get answer to the first one) - can I get the projection matrix inside 2D filter? I need it to get correct ray direction from fragment coordinates once I have them.

Thanks, I think I’ll handle rest of it myself as I already found some plane releated equations;)