mannu598
mannu598

Reputation: 21

Circular show-through mask like Holomaps

I am using Unity 5.5 and trying to replicate mask/clipping like how it is done in Holomaps application for Hololens. Even if not circle, a square/rectangle mask. Youtube video of Holomaps application is at https://www.youtube.com/watch?v=8gpuYzWVP9w

There you can see, map is a regular rectangle mesh but is only seen through a circular portal.

Difference is, I have a base plane with map and a different mesh containing building and other landmarks.

I have tried DepthMasks (from Unity Wiki) and Stencil shaders but not able to achieve the results.

For DepthMask, I created 4 cubes to cover all sides of map and just leave a small hole in-between 4 cubes. But to cover the building heights, cubes need to be higher than buildings and that causes camera view to ignore mask, when camera goes inside the mask cube.

Stencil shaders, when applied to any 3D shape, will allow the mask to show through at all camera angles, which gives away the mask shape.

Any pointers to how we can do a mask/clipping like that?

Upvotes: 1

Views: 1465

Answers (2)

mannu598
mannu598

Reputation: 21

ok, I have been able to figure out the exact solution at https://github.com/kwnetzwelt/unity3d-dissolve-shader. This is a shader which does clipping of object from a world-point (center) at a certain distance in shape of a sphere.

Exactly what I was looking for!!

Thanks for your @Everts and @Nonameghost for the ideas :)

Upvotes: 1

Nonameghost
Nonameghost

Reputation: 843

https://en.wikibooks.org/wiki/Cg_Programming/Unity/Cutaways

Have you tried doing cutouts like this? I could imagine a shader with center and radius parameters, where any pixel farther than the radius getting discarded. That's generally how alpha-cutout shaders work and generally used with masks like this.

Upvotes: 0

Related Questions