Only render parts of objects inside box and texture blending

Two things

  1. Is there a way i can only have part of an object visible. Something like attached. This is for a AR Project so i cant just move the object and move it back to the original position like you would when that is off screen.

2
i am trying to do something like this
https://developer.playcanvas.com/en/tutorials/custom-shaders/
but on a 3d model and when the top Diffuse texture channel dissolves a secondary diffuse texture is shown. then a 3rd, 4th … ect
i was thinking you would just need 2 so when 1 dissolves the 2 is shown and texture is replaced on 1 and 2 dissolves to 1 showing a new texture

i was thinking of doing it with an opacity map and changing the alpha test value but that means i would need 2x the geometry

This would need a masking shader, similar to how the UI elements do masking. Not sure if we have something out of the box for this.

Thing 1 - how is the invisible / visible area defined? If it is some kind of box / sphere volume, you could modify shader to discard pixels inside / outside that volume, based on some uniforms you pass in. It it is defined by some other objects rendered, you’d probably need to render them to texture / stencil buffer first and use it as a mask.

Thing 2 - doing multi object solution could work, but might not be very GPU efficient. Custom shader would be a better solution. Something similar to current implementation of detail texture, but with some masking. https://github.com/playcanvas/engine/issues/1962

1 Like

In case this is helpful, here is another way to occlude part of an object using invisible occluders.

Requires some custom properties to be set in a material in code (check the included script) and a new Layer.

https://playcanvas.com/project/706714/settings

1 Like

@Leonidas Awesome that would work exactly how i want. I will look at the code.

@mvaligursky is the detail map solution you are suggesting implemented into playcanvas yet?

1 Like

Yes, the detail map is part of the engine but can only be applied via code at moment. It’s not yet integrated into the Editor