Screenspace Co-ords - get and render to

  1. How can I determine the screen space co-ordinates of a rectangle (see pic)?

  2. Once determined, can I then use them to render a texture to that area?

TIA

Hi @CarlBateman,

I am thinking maybe do it the other way?

Render the texture using an offscreen camera, and then apply that texture to that object using a UI element.

1 Like

I still need the screen space co-ords to determine which part of the texture to use.
Can I use the screen space co-ords to crop a UI element?

Hi @CarlBateman,

You can use the following world to screen camera function for each world corner point, if that’s what you are trying to do:

https://developer.playcanvas.com/api/pc.CameraComponent.html#worldToScreen

Hah! I tried it previously but got nonsense results. Tried again and it’s working, must “finger trouble”! Thanks!

How about (2) rendering an irregular texture area?

1 Like

Mmm can you try posting an example of what you are trying to achieve? And how you are using those screen space coordinates?

This is a possible method of implementing portals.
I’d like to replace the magenta areas.

With the corresponding areas.

Resulting in this

1 Like