/// <summary> /// Creates a new dewarp mesh game object, and sets the nessecary dependncies for generation of the mesh. /// /// /// The dewarp mesh takes a post process material, Dewarp mesh verticies positions and a render texture. /// The Post process material can be the UniCave postprocess material which enables edge blending and debugging. /// The DewarpMeshPositions is positions of imported verticies from config. So it can generate a mesh based /// on your loaded mesh calibration. /// The render texture is for the camera displaying this dewarp mesh. /// /// </summary> /// <param name="name">the name of the gameobject</param> /// <param name="postProcessMaterial">post process material</param> /// <param name="vertices">positions of verticies from calibartion</param> /// <param name="cameraTexture">render texture for the camera</param> public Dewarp(string name, Material postProcessMaterial, DewarpMeshPosition verticesPositions, RenderTexture cameraTexture) { dewarpObject = new GameObject(objectName + name); this.PostProcessMaterial = postProcessMaterial; this.CalibratedVerticesPositions = verticesPositions; this.CameraTexture = cameraTexture; this.GenerateMesh(); this.GenerateAndAssignMaterials(name); }
public Dewarp(string name, Material postProcessMaterial, DewarpMeshPosition vertices, RenderTexture cameraTexture) { this.dewarpPositions = vertices; dewarpObject = new GameObject(objectName + name); dewarpObject.layer = 8; this.warpMeshFilter = dewarpObject.AddComponent <MeshFilter> (); this.warpMeshFilter.mesh = Generate(); dewarpObject.layer = 8; //post processing layer is 8 //create material for left warpMesh this.renderMaterial = new Material(postProcessMaterial); this.renderMaterial.name = $"Material for {name}"; //assign the render texture to the material and the material to the warpMesh renderMaterial.mainTexture = cameraTexture; dewarpObject.AddComponent <MeshRenderer> ().material = renderMaterial; }