Example #1
0
        public void Add(VoxelAttribute attr, VoxelizationStage stage, bool output, bool shadows)
        {
            if (stage == VoxelizationStage.Initial)
            {
                if (output)
                {
                    AttributesDirect.Add(attr);
                }
                else
                {
                    AttributesTemp.Add(attr);
                }
            }
            else if (stage == VoxelizationStage.Post)
            {
                AttributesIndirect.Add(attr);
            }

            requireShadows |= shadows;
        }
Example #2
0
        public void CollectVoxelizationPasses(VoxelizationPassList passList, IVoxelStorer storer, Matrix view, Vector3 resolution, VoxelAttribute attr, VoxelizationStage stage, bool output, bool shadows)
        {
            while (VoxelizationViews.Count <= currentViewIndex)
            {
                VoxelizationViews.Add(new RenderView());
                VoxelizationViewSizes[VoxelizationViews[VoxelizationViews.Count - 1]] = new Int2();
            }
            RenderView voxelizationView = VoxelizationViews[currentViewIndex];

            voxelizationView.View           = Matrix.Identity;
            voxelizationView.Projection     = view;
            voxelizationView.ViewProjection = view;

            float  maxRes      = Math.Max(resolution.X, Math.Max(resolution.Y, resolution.Z));
            Matrix aspectScale = Matrix.Scaling(resolution / maxRes);

            voxelizationView.Projection    *= aspectScale;
            voxelizationView.ViewProjection = voxelizationView.View * voxelizationView.Projection;

            voxelizationView.ViewSize = new Vector2(maxRes * 8, maxRes * 8);
            VoxelizationViewSizes[voxelizationView] = new Int2((int)maxRes, (int)maxRes);


            //The BoundingFrustum constructor doesn't end up calculating the correct Near Plane for the symmetric matrix, squish it so the Z is from 0 to 1
            Matrix SquishedMatrix = voxelizationView.ViewProjection * Matrix.Scaling(1f, 1f, 0.5f) * Matrix.Translation(new Vector3(0, 0, 0.5f));

            voxelizationView.Frustum = new BoundingFrustum(ref SquishedMatrix);

            voxelizationView.CullingMode   = CameraCullingMode.None;
            voxelizationView.NearClipPlane = 0.1f;
            voxelizationView.FarClipPlane  = 1000.0f;

            currentViewIndex++;

            passList.AddDirect(storer, this, voxelizationView, attr, stage, output, shadows);
        }
        public void AddDirect(IVoxelStorer storer, IVoxelizationMethod method, RenderView view, VoxelAttribute attr, VoxelizationStage stage, bool output, bool shadows)
        {
            bool toAdd = true;

            foreach (VoxelizationPass pass in passes)
            {
                if (pass.storer.Equals(storer) &&
                    pass.method.Equals(method) &&
                    pass.view.ViewProjection == view.ViewProjection)
                {
                    pass.Add(attr, stage, output, shadows);
                    toAdd = false;
                    break;
                }
            }
            if (toAdd)
            {
                VoxelizationPass pass = new VoxelizationPass
                {
                    storer = storer,
                    method = method,
                    view   = view
                };
                pass.Add(attr, stage, output, shadows);
                passes.Add(pass);
            }
        }
Example #4
0
        public void CollectVoxelizationPasses(VoxelizationPassList passList, IVoxelStorer storer, Matrix view, Vector3 resolution, VoxelAttribute attr, VoxelizationStage stage, bool output, bool shadows)
        {
            axisX.MultisampleCount = MultisampleCount;
            axisY.MultisampleCount = MultisampleCount;
            axisZ.MultisampleCount = MultisampleCount;

            axisX.CollectVoxelizationPasses(passList, storer, view, resolution, attr, stage, output, shadows);
            axisY.CollectVoxelizationPasses(passList, storer, view, resolution, attr, stage, output, shadows);
            axisZ.CollectVoxelizationPasses(passList, storer, view, resolution, attr, stage, output, shadows);
        }
Example #5
0
 public AttributeStream(VoxelAttribute attribute, VoxelizationStage stage, bool output)
 {
     Attribute = attribute;
     Stage     = stage;
     Output    = output;
 }