I am trying to create a shader/material that once contacted with a specific mesh, it will reveal the inside of it, similar to this: enter image description here
So far, I have done it's creating a shader that apply to the mesh itself, but I don't want that because I don't want to change the material of the mesh.
Any ideas on how can I make a material apply to a sphere/plane that cut one specific mesh?
I think I managed to solve it.
using UnityEngine;
using System.Collections.Generic;
public class MeshClipper : MonoBehaviour
{
public GameObject model3D;
public Transform planeTransform;
private Material cuttingMaterial;
private void Awake() {
MeshRenderer renderer = model3D.GetComponent<MeshRenderer>();
cuttingMaterial = renderer.material;
}
void Update()
{
Vector3 planePosition = planeTransform.position;
Vector3 planeNormal = planeTransform.up * -1;
cuttingMaterial.SetVector("_PlanePosition", planePosition);
cuttingMaterial.SetVector("_PlaneNormal", planeNormal);
}
}