public override void FrameUpdate(PipelineCamera cam, ref PipelineCommandData data) { CommandBuffer buffer = data.buffer; LastVPData lastData = IPerCameraData.GetProperty <LastVPData>(cam, getLastVP); //Calculate Last VP for motion vector and Temporal AA Matrix4x4 nonJitterVP = GL.GetGPUProjectionMatrix(cam.cam.nonJitteredProjectionMatrix, false) * cam.cam.worldToCameraMatrix; ref Matrix4x4 lastVp = ref lastData.lastVP;
public override void PreRenderFrame(PipelineCamera cam, ref PipelineCommandData data) { if (!cam.cam.TryGetCullingParameters(out cullParams)) { return; } data.buffer.SetInvertCulling(cam.inverseRender); cullParams.reflectionProbeSortingCriteria = ReflectionProbeSortingCriteria.ImportanceThenSize; cullParams.cullingOptions = CullingOptions.NeedsLighting | CullingOptions.NeedsReflectionProbes; if (cam.cam.useOcclusionCulling) { cullParams.cullingOptions |= CullingOptions.OcclusionCull; } cullResults = data.context.Cull(ref cullParams); for (int i = 0; i < frustumPlanes.Length; ++i) { Plane p = cullParams.GetCullingPlane(i); //GPU Driven RP's frustum plane is inverse from SRP's frustum plane frustumPlanes[i] = new Vector4(-p.normal.x, -p.normal.y, -p.normal.z, -p.distance); } PipelineFunctions.InitRenderTarget(ref cam.targets, cam.cam, data.buffer); lastData = IPerCameraData.GetProperty(cam, getLastVP); calculateJob = new CalculateMatrixJob { isD3D = GraphicsUtility.platformIsD3D, nonJitterP = cam.cam.nonJitteredProjectionMatrix, worldToView = cam.cam.worldToCameraMatrix, lastVP = lastData.lastVP, rand = (Random *)UnsafeUtility.AddressOf(ref rand), p = cam.cam.projectionMatrix, VP = (float4x4 *)UnsafeUtility.AddressOf(ref VP), inverseVP = (float4x4 *)UnsafeUtility.AddressOf(ref inverseVP) }; handle = calculateJob.ScheduleRefBurst(); }
public override void PreRenderFrame(PipelineCamera cam, ref PipelineCommandData data) { if (!cam.cam.TryGetCullingParameters(out cullParams)) { return; } data.buffer.SetInvertCulling(cam.inverseRender); cullParams.reflectionProbeSortingCriteria = ReflectionProbeSortingCriteria.ImportanceThenSize; cullParams.cullingOptions = CullingOptions.NeedsLighting | CullingOptions.NeedsReflectionProbes; if (cam.cam.useOcclusionCulling) { cullParams.cullingOptions |= CullingOptions.OcclusionCull; } cullResults = data.context.Cull(ref cullParams); for (int i = 0; i < frustumPlanes.Length; ++i) { Plane p = cullParams.GetCullingPlane(i); //GPU Driven RP's frustum plane is inverse from SRP's frustum plane frustumPlanes[i] = new Vector4(-p.normal.x, -p.normal.y, -p.normal.z, -p.distance); } PipelineFunctions.InitRenderTarget(ref cam.targets, cam.cam, data.buffer); lastData = IPerCameraData.GetProperty(cam, getLastVP); calculateJob.isD3D = GraphicsUtility.platformIsD3D; calculateJob.nonJitterP = cam.cam.nonJitteredProjectionMatrix; calculateJob.worldToView = cam.cam.worldToCameraMatrix; calculateJob.lastVP = lastData.lastVP; calculateJob.rand = (Random *)UnsafeUtility.AddressOf(ref rand); calculateJob.p = cam.cam.projectionMatrix; calculateJob.VP = (float4x4 *)UnsafeUtility.AddressOf(ref VP); calculateJob.inverseVP = (float4x4 *)UnsafeUtility.AddressOf(ref inverseVP); Transform camTrans = cam.cam.transform; perspCam.forward = camTrans.forward; perspCam.up = camTrans.up; perspCam.right = camTrans.right; perspCam.position = camTrans.position; perspCam.nearClipPlane = cam.cam.nearClipPlane; perspCam.farClipPlane = cam.cam.farClipPlane; perspCam.aspect = cam.cam.aspect; perspCam.fov = cam.cam.fieldOfView; float3 *corners = stackalloc float3[8]; PipelineFunctions.GetFrustumCorner(ref perspCam, corners); frustumMinPoint = corners[0]; frustumMaxPoint = corners[0]; for (int i = 1; i < 8; ++i) { frustumMinPoint = min(frustumMinPoint, corners[i]); frustumMaxPoint = max(frustumMaxPoint, corners[i]); } handle = calculateJob.ScheduleRefBurst(); }
public override void PreRenderFrame(PipelineCamera cam, ref PipelineCommandData data) { if (!cam.cam.TryGetCullingParameters(out cullParams)) { return; } data.buffer.SetInvertCulling(cam.inverseRender); cullParams.reflectionProbeSortingCriteria = ReflectionProbeSortingCriteria.ImportanceThenSize; cullParams.cullingOptions = CullingOptions.NeedsLighting | CullingOptions.NeedsReflectionProbes; if (cam.cam.useOcclusionCulling) { cullParams.cullingOptions |= CullingOptions.OcclusionCull; } cullResults = data.context.Cull(ref cullParams); for (int i = 0; i < frustumPlanes.Length; ++i) { frustumPlanes[i] = cam.frustumArray[i]; } PipelineFunctions.InitRenderTarget(ref cam.targets, cam.cam, data.buffer); var getter = new LastVPData.GetLastVPData { c = cam.cam }; lastData = IPerCameraData.GetProperty <LastVPData, LastVPData.GetLastVPData>(cam, getter); calculateJob.isD3D = GraphicsUtility.platformIsD3D; calculateJob.nonJitterP = cam.cam.nonJitteredProjectionMatrix; calculateJob.worldToView = cam.cam.worldToCameraMatrix; //TODO //Set Camera calculateJob.lastCameraLocalToWorld = lastData.camlocalToWorld; calculateJob.lastP = lastData.lastP; calculateJob.sceneOffset = RenderPipeline.sceneOffset; calculateJob.rand = (Random *)UnsafeUtility.AddressOf(ref rand); calculateJob.p = cam.cam.projectionMatrix; calculateJob.VP = (float4x4 *)UnsafeUtility.AddressOf(ref VP); calculateJob.inverseVP = (float4x4 *)UnsafeUtility.AddressOf(ref inverseVP); handle = calculateJob.ScheduleRefBurst(); }