I'm new to Unity and I'm developing an augmented reality app.

My situation is as follows: I have two objects in the scene, a neighborhood model and a cube. The mockup will be the object I am going to enlarge and the cube will be like the acrylic box where the mockup is. The cube represents the viewing area and will be transparent. The model has an animation in which it moves and scales and the cube remains fixed.

I need something to assign to the cube so that when expanding the model, the parts that stick out of the cube will have 50% colorless transparency (all gray) and the part of the model that is inside the cube (in intersection) remains solid and with the colors and textures.

The idea is to present the mockup on an initial scale that is inside the cube (acrylic box) then the model's animation will zoom in on the mockup at certain points, the whole mockup will be much larger than the cube. the outside of the cube is transparent and colorless, and the inside remains coloured to make it more prominent.

Can someone help me?

  • \$\begingroup\$ You can use a strategy similar to the one discussed in this Q&A. The difference is that rather than using the clip function to abort pixels outside the cube, you'd instead just reduce the alpha value of the colour returned by your shader. \$\endgroup\$
    – DMGregory
    Nov 29, 2019 at 1:38
  • \$\begingroup\$ Given your comment/answer on the question linked by DMGregory, you might want to edit this question and add more details regarding what you have tried so far. Did you try the solution provided by DMGregory? If so, what was missing from it to complete the feature you're working on? Solutions and code snippets taken from the internet rarely work and apply to other situations, they have to be adapted :) \$\endgroup\$
    – Vaillancourt
    Dec 3, 2019 at 17:28


You must log in to answer this question.