private void OnDestroy()
        {
            DecalBase lastDec = MUnsafeUtility.GetObject <DecalBase>(decalDatas[decalDatas.Length - 1].comp);

            lastDec.index     = index;
            decalDatas[index] = decalDatas[decalDatas.Length - 1];
            decalDatas.RemoveLast();
            OnDispose();
        }
Exemplo n.º 2
0
        public void FrameUpdate(PipelineCamera cam, ref PipelineCommandData data)
        {
            CommandBuffer buffer = data.buffer;

            handle.Complete();
            buffer.GetTemporaryRT(ShaderIDs._BackupAlbedoMap, cam.cam.pixelWidth, cam.cam.pixelHeight, 0, FilterMode.Point, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear, 1, false);
            buffer.GetTemporaryRT(ShaderIDs._BackupNormalMap, cam.cam.pixelWidth, cam.cam.pixelHeight, 0, FilterMode.Point, RenderTextureFormat.ARGB2101010, RenderTextureReadWrite.Linear, 1, false);
            buffer.CopyTexture(cam.targets.gbufferIndex[2], 0, 0, ShaderIDs._BackupNormalMap, 0, 0);
            buffer.CopyTexture(cam.targets.gbufferIndex[0], 0, 0, ShaderIDs._BackupAlbedoMap, 0, 0);
            decalTargets[0] = cam.targets.gbufferIndex[0];
            decalTargets[1] = cam.targets.gbufferIndex[2];
            buffer.SetRenderTarget(colors: decalTargets, depth: ShaderIDs._DepthBufferTexture);
            DecalData *resulPtr = decalCullResults.Ptr();

            for (int i = 0; i < cullJob.count; ++i)
            {
                ref DecalData decal = ref resulPtr[i];
                DecalBase     dec   = MUnsafeUtility.GetObject <DecalBase>(decal.comp);
                dec.DrawDecal(buffer);
            }