Player can open a area (use sphere) , and the terrain of material in area will change.
First , I used trigger , when the sphere touch terrain , it will change the material.
But all the material of terrain changed , I just want to change the area’s material .
Then, I tried to use this : Unity 4.2 - Stencils for portal rendering
I make two identical terrains , and one of it will be seen when the area (sphere with StencilsMask ) open.
But a problem happened:
when I move the camera , all the object will be seen through this sphere.
You’ve got some nice improvements by yourself, but the solution for it probably will have to be made by another approach. I don’t understand what a Stencil Mask is, but maybe you could figure something out by insisting on it, since the result got close to desired.
As for changing the material. You can’t change the material of just a part of the object. It’ll change the material for the object entirely. To change of just a part, you’ll have to cut it, than assigning separately. So if you have a car and the wheels are part of it’s mesh, they will all have the same material. But if the wheels are a separate GameObject, than it’s Ok.
And when you change a material, you change all of it’s instances. So if two cars have the same material, changing the material itself will change the look of both cars. But you can Always give each car a diffrente material.
So, to change that area on your game, you’ll have two solutions:
1- Create two terrains, one of the affected area and other for the non-affected. Than change the material of the affected area.
2-Create a decal for the affected area and place it on the top. If your floor was plane, you’d just have to instantiate a 2D Sprite right on top of the floor. Most shooters use it to making decals on walls.
The problem is that the terrain isn’t plain, so you’d have to make the decal deform to match it. There is an asset on the Store that does it, but it’s paid.