Crop camera with a shape of a texture

Hello,

I want to crop the camera texture with the shape of the image input.
For example, If I have a png texture file of a daisy, I'd like to crop the camera texture with the daisy shape and get the cropped output texture.

I searched for crop features and segmentation for Lens Studio, but it seems like they provide ml-based segmentation only but not just regular cropping or segmentation.

If there's any source that I missed, please let me know.

Answers

  • Aleks Brzoska
    Aleks Brzoska Posts: 12 🔥

    Hi @GuuInTheHaus !

    Would this option solve your problem?

    1. Create a 9:16 aspect rectangle in photoshop or other editing app

    2. Put your daisy png on top and cut the shape out of the rectangle

    3. Once you have a rectangle with a daisy shape cut out, bring that rectangle into lens studio as a screen image.

  • hello @Aleks Brzoska ,

    Thanks for the reply.
    I am not sure if we are on the same page. I'd like to get 'cropped texture' for the next steps, not just to show camera output that looks cropped by covering with another image.
    Anyways, I appreciate your help!

  • While Lens Studio does offer ML-based segmentation, it also allows for regular cropping and segmentation.

    Here's how you can achieve your desired effect:

    1. Import your image:

    2. Use the "Image Transform" node:
      Add an "Image Transform" node to your scene graph.
      Connect the "Output Texture" of your camera to the "Input Texture" of the "Image Transform" node.
      Connect your daisy image texture to the "Mask Texture" input of the "Image Transform" node.

    3. Adjust the "Mask Offset" and "Mask Scale" properties:
      Use the "Mask Offset" property to position your daisy image over the camera texture.
      Use the "Mask Scale" property to resize your daisy image to match the desired portion of the camera texture you want to keep.

    4. Output the cropped texture:
      Connect the "Output Texture" of the "Image Transform" node to the desired output texture slot in your Lens.

    By following these steps, you can effectively crop your camera texture to the shape of your daisy image using just the built-in tools in Lens Studio. This method avoids the need for any complex ML-based segmentation and offers a straightforward approach to achieving your desired result.