public override void FrameUpdate(PipelineCamera cam, ref PipelineCommandData data) { culler.FrameUpdate(); if (culler.cullingResult.isCreated && culler.cullingResult.Length > 0) { data.buffer.SetRenderTarget(color: cam.targets.renderTargetIdentifier, depth: cam.targets.depthBuffer); foreach (var i in culler.cullingResult) { ref LoadedIrradiance irr = ref IrradianceVolumeController.current.loadedIrradiance[i]; CoeffTexture coefTex = IrradianceVolumeController.current.coeffTextures[irr.renderTextureIndex]; DrawGI(data.buffer, ref coefTex, new Matrix4x4(float4(irr.localToWorld.c0, 0), float4(irr.localToWorld.c1, 0), float4(irr.localToWorld.c2, 0), float4(irr.position, 1))); } }
public bool LoadVolume(int index) { if (isLoading) { return(false); } if (index < 0 || index >= resources.allVolume.Count) { return(false); } isLoading = true; IrradianceResources.Volume data = resources.allVolume[index]; currentIrr = new LoadedIrradiance { resolution = data.resolution, position = data.position, localToWorld = data.localToWorld, renderTextureIndex = loadedIrradiance.Length }; targetPath = data.path; currentTexture = new CoeffTexture(data.resolution); len = (int)(data.resolution.x * data.resolution.y * data.resolution.z * 9); if (coeff != null && coeff.count < len) { coeff.Dispose(); coeff = new ComputeBuffer(len, 12); } if (coeff == null) { coeff = new ComputeBuffer(len, 12); } LoadingThread.AddCommand((obj) => { var controller = (IrradianceVolumeController)obj; controller.LoadVolumeAsync(); }, this); return(true); }