public void RenderEye(WVR_Eye eye, RenderTexture texture) { reset(); WaveVR_Utils.Trace.BeginSection((eye == WVR_Eye.WVR_Eye_Left) ? "Distortion_WVR_Eye_Left" : "Distortion_WVR_Eye_Right"); current = eye == WVR_Eye.WVR_Eye_Left ? Cleft : Cright; current.material.mainTexture = texture; cam.enabled = true; cam.rect = current.rect; cam.Render(); cam.enabled = false; WaveVR_Utils.Trace.EndSection(); }
public void RenderEye(WVR_Eye eye, RenderTexture texture) { reset(); bool isleft = eye == WVR_Eye.WVR_Eye_Left; WaveVR_Utils.Trace.BeginSection(isleft ? "Distortion_WVR_Eye_Left" : "Distortion_WVR_Eye_Right"); current = isleft ? Cleft : Cright; current.material.mainTexture = texture; cam.enabled = true; // When VR mode is enabled, the camera clean will not follow camera.rect. Not to clear when drawing right eyes. cam.clearFlags = isleft ? CameraClearFlags.SolidColor : CameraClearFlags.Nothing; cam.rect = current.rect; cam.Render(); cam.enabled = false; WaveVR_Utils.Trace.EndSection(); }
public void init() { wvr.distortion.Distortion obj = new wvr.distortion.Distortion(); Cleft = new wvr.distortion.Config(); Cleft.eye = true; Cleft.rect = new Rect(0, 0, 0.5f, 1); Cleft.expandRatio = 1; Cleft.center = GetCenter(WVR_Eye.WVR_Eye_Left); Cleft.mesh = obj.createMesh(Cleft); Cleft.mesh.name = "left_eye_distortion"; Cright = new wvr.distortion.Config(); Cright.eye = false; Cright.rect = new Rect(0.5f, 0, 0.5f, 1); Cright.expandRatio = 1; Cright.center = GetCenter(WVR_Eye.WVR_Eye_Right); Cright.mesh = obj.createMesh(Cright); Cright.mesh.name = "right_eye_distortion"; Shader shader = Resources.Load <Shader>("WaveVR_Distortion"); if (shader == null) { Debug.LogError("Can't find WaveVR/Distortion shader"); } var material = new Material(shader); Cleft.material = material; Cright.material = material; cam = GetComponent <Camera>(); cam.orthographic = true; cam.orthographicSize = 1; cam.cullingMask = 0; cam.backgroundColor = Color.black; cam.projectionMatrix = Matrix4x4.identity; cam.enabled = false; current = Cright; FlatMesh = new Mesh(); FlatMesh.vertices = new Vector3 [] { new Vector3(-1, 1), new Vector3(1, 1), new Vector3(1, -1), new Vector3(-1, -1) }; FlatMesh.uv = new Vector2[] { new Vector2(0, 1), new Vector2(1, 1), new Vector2(1, 0), new Vector2(0, 0) }; FlatMesh.SetIndices(new int[] { 0, 1, 2, 0, 2, 3 }, MeshTopology.Triangles, 0); }
public void init() { wvr.distortion.Distortion obj = new wvr.distortion.Distortion(); Cleft = new wvr.distortion.Config(); Cleft.eye = true; Cleft.rect = new Rect(0, 0, 0.5f, 1); Cleft.expandRatio = 1; Cleft.center = GetCenter(WVR_Eye.WVR_Eye_Left); Cleft.mesh = obj.createMesh(Cleft); Cleft.mesh.name = "left_eye_distortion"; Cright = new wvr.distortion.Config(); Cright.eye = false; Cright.rect = new Rect(0.5f, 0, 0.5f, 1); Cright.expandRatio = 1; Cright.center = GetCenter(WVR_Eye.WVR_Eye_Right); Cright.mesh = obj.createMesh(Cright); Cright.mesh.name = "right_eye_distortion"; Shader shader = Resources.Load <Shader>("WaveVR_Distortion"); if (shader == null) { Debug.LogError("Can't find WaveVR/Distortion shader"); } var material = new Material(shader); Cleft.material = material; Cright.material = material; cam = GetComponent <Camera>(); cam.orthographic = true; cam.orthographicSize = 1; cam.cullingMask = 0; cam.backgroundColor = Color.black; cam.clearFlags = CameraClearFlags.SolidColor; cam.projectionMatrix = Matrix4x4.identity; cam.enabled = false; current = Cright; }