void OnPreRender() { //Method called twice. Thus left eye == 0 and right eye == 1 currentEye = 1 - currentEye; //if right eye if (currentEye == 1) { HairInstance.BeginRenderVR(this.GetComponent <Camera> ()); foreach (var a in HairInstance.GetInstances()) { a.Render(); } HairInstance.EndRender(); } }
public static void Render(Camera CameraToAdd, HairInstance instance) { if (CmdBuffer_HairRender == null) { CmdBuffer_HairRender = new CommandBuffer(); CmdBuffer_HairRender.name = "Hair"; CmdBuffer_HairRender.IssuePluginEvent(hwi.hwGetRenderEventFunc(), 0); } if (!HairWorksEnabled) { return; } if (CameraToAdd != null) { CameraEvent s_timing; if (IsDeferred(CameraToAdd)) { s_timing = CameraEvent.BeforeImageEffects; } else { s_timing = CameraEvent.AfterImageEffectsOpaque; } Matrix4x4 V = CameraToAdd.worldToCameraMatrix; Matrix4x4 P = GL.GetGPUProjectionMatrix(CameraToAdd.projectionMatrix, DoesRenderToTexture(CameraToAdd)); float fov = CameraToAdd.fieldOfView; hwi.hwSetViewProjection(ref V, ref P, fov); HairLight.AssignLightData(); if (!s_cameras.Contains(CameraToAdd)) { CameraToAdd.AddCommandBuffer(s_timing, CmdBuffer_HairRender); s_cameras.Add(CameraToAdd); } } hwi.hwBeginScene(); instance.Render(); hwi.hwEndScene(); }