Inheritance: UnityEngine.MonoBehaviour
Example #1
0
        static void BeginRender()
        {
            if (s_command_buffer == null)
            {
                s_command_buffer      = new CommandBuffer();
                s_command_buffer.name = "Hair";
                s_command_buffer.IssuePluginEvent(hwi.hwGetRenderEventFunc(), 0);
            }

            var cam = Camera.current;

            if (cam != null)
            {
                Matrix4x4 V   = cam.worldToCameraMatrix;
                Matrix4x4 P   = GL.GetGPUProjectionMatrix(cam.projectionMatrix, DoesRenderToTexture(cam));
                float     fov = cam.fieldOfView;
                hwi.hwSetViewProjection(ref V, ref P, fov);
                HairLight.AssignLightData();

                if (!s_cameras.Contains(cam))
                {
                    cam.AddCommandBuffer(s_timing, s_command_buffer);
                    s_cameras.Add(cam);
                }
            }

            hwi.hwBeginScene();
        }
Example #2
0
        static void BeginRender()
        {
            if (s_command_buffer == null)
            {
                s_command_buffer      = new CommandBuffer();
                s_command_buffer.name = "Hair";
                s_command_buffer.IssuePluginEvent(hwi.hwGetRenderEventFunc(), 0);
            }

            Camera cam = Camera.current;

            if (cam != null)
            {
                Matrix4x4 V = cam.worldToCameraMatrix;
                //DoesRenderToTexture does not account for image effects or msaa. Force true for now. False only useful in forward without image effects or msaa, unlikely use case.
                Matrix4x4 P   = GL.GetGPUProjectionMatrix(cam.projectionMatrix, /*DoesRenderToTexture(cam)*/ true);
                float     fov = cam.fieldOfView;
                hwi.hwSetViewProjection(ref V, ref P, fov);
                HairLight.AssignLightData();

                if (!s_cameras.Contains(cam))
                {
                    cam.AddCommandBuffer(s_timing, s_command_buffer);
                    s_cameras.Add(cam);
                }
            }

            hwi.hwBeginScene();
        }
Example #3
0
        //
        private void BeginRender(bool vrMode)
        {
            if (!m_hairSystemStarted)
            {
                return;
            }

            if (s_command_buffer == null)
            {
                s_command_buffer      = new CommandBuffer();
                s_command_buffer.name = "Hair";
                s_command_buffer.IssuePluginEvent(hwi.hwGetRenderEventFunc(), 0);
            }

            if (s_command_bufferVR == null)
            {
                s_command_bufferVR      = new CommandBuffer();
                s_command_bufferVR.name = "HairVR";
                s_command_bufferVR.IssuePluginEvent(hwi.hwGetRenderEventFunc(), 1);
            }

            if (s_command_bufferVR_singlePass == null)
            {
                s_command_bufferVR_singlePass      = new CommandBuffer();
                s_command_bufferVR_singlePass.name = "HairVRSinglePass";
                s_command_bufferVR_singlePass.IssuePluginEvent(hwi.hwGetRenderEventFunc(), 2);
            }

            Camera cam = Camera.current;

            if (cam != null)
            {
                // set camera and projection matrix for hairworks
                SetCameraProjectionMatrix(cam);

                // set light data
                HairLight.AssignLightData(vrMode);

                if (!s_cameras.Contains(cam))
                {
                    AddCameraCommandBuffer(cam);
                    s_cameras.Add(cam);
                }
                else
                {
                    UpdateCameraCommandBuffer(cam);
                }
            }

            hwi.hwBeginScene(vrMode);
        }