Ejemplo n.º 1
0
 private void DrawGI(CommandBuffer buffer, ref CoeffTexture currentTexture, Matrix4x4 localToWorld)
 {
     buffer.SetGlobalTexture(IrradianceVolumeController.current._CoeffIDs[0], currentTexture.coeff0);
     buffer.SetGlobalTexture(IrradianceVolumeController.current._CoeffIDs[1], currentTexture.coeff1);
     buffer.SetGlobalTexture(IrradianceVolumeController.current._CoeffIDs[2], currentTexture.coeff2);
     buffer.SetGlobalTexture(IrradianceVolumeController.current._CoeffIDs[3], currentTexture.coeff3);
     buffer.SetGlobalTexture(IrradianceVolumeController.current._CoeffIDs[4], currentTexture.coeff4);
     buffer.SetGlobalTexture(IrradianceVolumeController.current._CoeffIDs[5], currentTexture.coeff5);
     buffer.SetGlobalTexture(IrradianceVolumeController.current._CoeffIDs[6], currentTexture.coeff6);
     buffer.SetGlobalMatrix(ShaderIDs._WorldToLocalMatrix, localToWorld.inverse);
     buffer.DrawMesh(GraphicsUtility.cubeMesh, localToWorld, irradianceVolumeMat, 0, 0);
 }
 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)));
         }
     }
Ejemplo n.º 3
0
 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);
 }