Hello everyone! I need your help with shaders. I’m creating a mixed reality game and I want to project a terrain onto a table. I want anything outside the table to be hidden and to be able to move the terrain or advance on it within the same table board. Like in the attached photos. (One of them is the new Civilization VII VR version). How could I simulate this? Thanks!
Well, depending on what you’re exactly doing, you could do this thought Shader/Shader Graphs or directly with VFX Graph.
In this example, I’m creating a simple hollow table where my particles are distributed in an evenly spaced 2D Grid. From there, the height of each particle is driven by a Noise value.

Now, to “Clip/mask” your terrain, you need to create a mask. This mask can be based on position or it can also come from a texture.
Let’s try with a simple “distance” mask to get a Spherical mask like in the last Civilization:
For this, we’re computing the distance between the particle’s position and the center of our “Sphere”.
We then divide, this distance by the “Radius”.
From there, we’re inverting the values, as we want the particles inside the mask to be 1.
In y case, I’m using the transform values (position, scale) of a cylinder in my scene.
This 0-1 mask is then used to drive the height of our particles.

Now we can also discard the particle with a mask value of 0 to optimize a bit.
For this, we can take the mask value to drive the value of the alive attribute
Now, another solution in VFX Graph, could be to sample a mask texture. The sampled values could be used to drive the visibility, Color attributes of your particles.
To this end, you’ll need to use your particles position as “UVs”.
But you could use the same kind of principle/ideas inside a custom Shader graph.
I hope this helps, and I wish you a wonderful day.
Thank you very much for your response. That effect is exactly what I need, but I am very amateur in Shaders and VFX, I have barely any knowledge in this area. I don’t know if you know of any tutorials, videos, or example projects to better study it. By the way, could these shaders be applied to Unity’s Terrains?
I would recommend that you first take a look at:
The VFX Learning Sample.
Which is a collection of VFX that were built to help you understand the different aspects of VFX Graph.
You can also take a look at the updated VFX Graph E-Book, which is a great resource to get started and explore VFX Graph.
When a little more familiar with VFX Graph, you can take a look at this GitHub repository, which is full of VFX Graph examples.
One of the example’s scene is a Hollow table like the one you’re trying to achieve:
You can find a recording of a GDC presentation that covers the hollow table VFX:
The Hollow table VFX breakdown starts around 30 min.
I hope this will help you to achieve what you’re looking for.
Great, it’s a big help. Thank you very much
!!








