public void CollectVoxelizationPasses(ProcessedVoxelVolume data, VoxelStorageContext storageContext)
        {
            Matrix BaseVoxelMatrix = storageContext.Matrix;

            BaseVoxelMatrix.Invert();
            BaseVoxelMatrix = BaseVoxelMatrix * Matrix.Scaling(2f, 2f, 2f);
            if (UpdatesPerFrame != UpdateMethods.AllClipmapsMultipleRenders)
            {
                /*
                 * Having trouble with shadow culling when this is enabled - currently performed in vertex shader instead
                 * if (UpdateMethod == UpdateMethods.OneClipPerFrame)
                 * {
                 *  BaseVoxelMatrix = Matrix.Scaling(PerMapOffsetScale[ClipMapCurrent].W) * Matrix.Translation(PerMapOffsetScale[ClipMapCurrent].XYZ());
                 *  BaseVoxelMatrix = BaseVoxelMatrix * Matrix.Translation(-0.5f,-0.5f,-0.5f);
                 *  BaseVoxelMatrix = BaseVoxelMatrix * Matrix.Scaling(2f, 2f, 2f);
                 * }
                 */
                VoxelStorerClipmap Storer = new VoxelStorerClipmap
                {
                    storageUints      = storageUints,
                    FragmentsBuffer   = FragmentsBuffer,
                    ClipMapCount      = ClipMapCount,
                    ClipMapCurrent    = ClipMapCurrent,
                    ClipMapResolution = ClipMapResolution,
                    PerMapOffsetScale = PerMapOffsetScale,
                    UpdatesPerFrame   = UpdatesPerFrame
                };
                foreach (var attr in data.Attributes)
                {
                    attr.Attribute.CollectVoxelizationPasses(data.passList, Storer, BaseVoxelMatrix, ClipMapResolution, attr.Stage, attr.Output);
                }
            }
            if (UpdatesPerFrame == UpdateMethods.AllClipmapsMultipleRenders)
            {
                for (int i = 0; i < ClipMapCount; i++)
                {
                    VoxelStorerClipmap Storer = new VoxelStorerClipmap
                    {
                        storageUints      = storageUints,
                        FragmentsBuffer   = FragmentsBuffer,
                        ClipMapCount      = ClipMapCount,
                        ClipMapCurrent    = i,
                        ClipMapResolution = ClipMapResolution,
                        PerMapOffsetScale = PerMapOffsetScale,
                        UpdatesPerFrame   = UpdateMethods.SingleClipmap
                    };
                    foreach (var attr in data.Attributes)
                    {
                        attr.Attribute.CollectVoxelizationPasses(data.passList, Storer, BaseVoxelMatrix, ClipMapResolution, attr.Stage, attr.Output);
                    }
                }
            }
        }
Exemple #2
0
        public bool CanShareRenderStage(IVoxelStorer storer)
        {
            VoxelStorerClipmap storerClipmap = storer as VoxelStorerClipmap;

            if (storerClipmap == null)
            {
                return(false);
            }

            bool singleClipA = UpdatesOneClipPerFrame();
            bool singleClipB = storerClipmap.UpdatesOneClipPerFrame();

            return(singleClipA == singleClipB);
        }
Exemple #3
0
        public override bool Equals(object obj)
        {
            VoxelStorerClipmap storerClipmap = obj as VoxelStorerClipmap;

            if (storerClipmap == null)
            {
                return(false);
            }

            bool singleClipA = UpdatesOneClipPerFrame();
            bool singleClipB = storerClipmap.UpdatesOneClipPerFrame();
            bool sameClipSet = (storerClipmap.UpdatesPerFrame == VoxelStorageClipmaps.UpdateMethods.SingleClipmap && storerClipmap.ClipMapCurrent == ClipMapCurrent);

            return(singleClipA == singleClipB && (!singleClipA || sameClipSet));
        }