I am developing an augmented reality app that uses unity to overlay 3D objects onto a photograph.
For certain 3D objects I would only like them to be seen within the area of a 2D mask that covers a certain region of the photograph. For example overlay a wall with a 2D Mask. This mask would be the same size as the pixel size of the photograph and the unity screen width and height. A bit like a stencil in front of the camera, but for only certain objects.
Is this kind of thing possible? I am unsure of the terms to use to search the forum to find any examples! thanks a lot.
With Unity pro, you could render the objects into a texture and then render the resulting image with a mask shader (where you stencil is the mask).
With Unity Indy, you would need a different approach. One possibility would be to render the foto, then your stencil in the alpha channel, followed by all your 3D objects that use destination alpha instead of source. This approach is cumbersome, however, since each object needs to be rendered with a custom shader (which can be some work if you use many different shaders).