Exemple #1
0
        public void PreRenderFrame(Camera camera, Camera lastNormalCamera, CommandBuffer commandBuffer)
        {
            if (TemporalReprojectionMaterial == null)
            {
                return;
            }
            WeatherMakerCameraType cameraType = WeatherMakerScript.GetCameraType(camera);

            if (cameraType == WeatherMakerCameraType.Other)
            {
                return;
            }

            lastNormalCamera = (cameraType == WeatherMakerCameraType.Normal ? camera : (lastNormalCamera ?? camera));

            // assign current matrixes, only normal stereo cameras use the stereo methods
            // reflection cameras are rendered one eye at a time without stereo
            if (camera.stereoEnabled)
            {
                view[0]                  = camera.GetStereoViewMatrix(Camera.StereoscopicEye.Left);
                view[1]                  = camera.GetStereoViewMatrix(Camera.StereoscopicEye.Right);
                projection[0]            = lastNormalCamera.GetStereoProjectionMatrix(Camera.StereoscopicEye.Left);
                projection[1]            = lastNormalCamera.GetStereoProjectionMatrix(Camera.StereoscopicEye.Right);
                inverseView[0]           = view[0].inverse;
                inverseView[1]           = view[1].inverse;
                inverseProjection[0]     = projection[0].inverse;
                inverseProjection[1]     = projection[1].inverse;
                inverseProjectionView[0] = inverseProjection[0] * inverseView[0];
                inverseProjectionView[1] = inverseProjection[1] * inverseView[1];
                prevViewProjection[0]    = (projection[0] * prevView[0]);
                prevViewProjection[1]    = (projection[1] * prevView[1]);
                ipivpvp[0]               = projection[0] * prevView[0] * inverseView[0] * inverseProjection[0];
                ipivpvp[1]               = projection[1] * prevView[1] * inverseView[1] * inverseProjection[1];
            }
            else
            {
                view[0]                  = view[1] = camera.worldToCameraMatrix;
                inverseView[0]           = inverseView[1] = camera.cameraToWorldMatrix;
                projection[0]            = projection[1] = lastNormalCamera.projectionMatrix;
                inverseProjection[0]     = inverseProjection[1] = lastNormalCamera.projectionMatrix.inverse;
                inverseProjectionView[0] = inverseProjectionView[1] = inverseView[0] * inverseProjection[0];
                prevViewProjection[0]    = prevViewProjection[1] = (projection[0] * prevView[0]);
                ipivpvp[0]               = ipivpvp[1] = projection[0] * prevView[0] * inverseView[0] * inverseProjection[0];
            }

            commandBuffer.SetGlobalTexture(WMS._TemporalReprojection_SubFrame, SubFrameTexture);
            commandBuffer.SetGlobalTexture(WMS._TemporalReprojection_PrevFrame, PrevFrameTexture);
            commandBuffer.SetGlobalFloat(WMS._TemporalReprojection_BlendMode, (float)BlendMode);
            commandBuffer.SetGlobalFloat(WMS._TemporalReprojection_SubPixelSize, ReprojectionSize);
            commandBuffer.SetGlobalFloat(WMS._TemporalReprojection_SubFrameNumber, SubFrameNumber);
            commandBuffer.SetGlobalFloat(WMS._TemporalReprojection_SimilarityMax, TemporalReprojectionMaterial.GetFloat(WMS._TemporalReprojection_SimilarityMax));
            commandBuffer.SetGlobalMatrixArray(WMS._TemporalReprojection_PreviousView, prevView);
            commandBuffer.SetGlobalMatrixArray(WMS._TemporalReprojection_View, view);
            commandBuffer.SetGlobalMatrixArray(WMS._TemporalReprojection_InverseView, inverseView);
            commandBuffer.SetGlobalMatrixArray(WMS._TemporalReprojection_Projection, projection);
            commandBuffer.SetGlobalMatrixArray(WMS._TemporalReprojection_InverseProjection, inverseProjection);
            commandBuffer.SetGlobalMatrixArray(WMS._TemporalReprojection_InverseProjectionView, inverseProjectionView);
            commandBuffer.SetGlobalMatrixArray(WMS._TemporalReprojection_PreviousViewProjection, prevViewProjection);
            commandBuffer.SetGlobalMatrixArray(WMS._TemporalReprojection_ipivpvp, ipivpvp);
        }
Exemple #2
0
 public WeatherMakerTemporalReprojectionState(Camera camera, Material reprojMaterial, bool integratedTemporalReprojection)
 {
     Camera = camera;
     TemporalReprojectionMaterial   = (reprojMaterial == null ? null : (Application.isPlaying ? new Material(reprojMaterial) : reprojMaterial));
     IntegratedTemporalReprojection = integratedTemporalReprojection;
     if (TemporalReprojectionMaterial != null && Application.isPlaying)
     {
         TemporalReprojectionMaterial.name += " (Clone)";
         BlendMode = (TemporalReprojectionBlendMode)TemporalReprojectionMaterial.GetInt(WMS._TemporalReprojection_BlendMode);
     }
 }