Ejemplo n.º 1
0
        internal void CreateResources(DeviceTexture blurTarget)
        {
            ThrowIfDisposed();

            //Dispose of the resources
            outputTarget?.Dispose();
            inputSampler?.Dispose();
            outputSampler?.Dispose();

            //Create a output target (same format and size as the blur-target)
            outputTarget = DeviceTexture.CreateColorTarget(blurTarget.Size, blurTarget.Format, scene);

            //Create samplers
            inputSampler  = new DeviceSampler(scene.LogicalDevice, blurTarget, disposeTexture: false);
            outputSampler = new DeviceSampler(scene.LogicalDevice, outputTarget, disposeTexture: false);

            //Bind the input
            renderer.BindGlobalInputs(new IShaderInput[] { inputSampler });

            //Bind the target
            renderer.BindTargets(new [] { outputTarget });

            //Tell the renderer to allocate its resources based on the data we've provided
            renderer.CreateResources();
        }
Ejemplo n.º 2
0
        internal void CreateResources(Int2 swapchainSize, IShaderInput sceneData)
        {
            ThrowIfDisposed();

            //Dispose of the old target
            depthTarget?.Dispose();

            //Dispose of the old sampler
            depthSampler?.Dispose();

            //Create the new render target
            depthTarget = DeviceTexture.CreateDepthTarget((targetSize, targetSize), depthFormat, scene);
            //Create sampler
            depthSampler = new DeviceSampler(scene.LogicalDevice, depthTarget, disposeTexture: false);

            //Bind inputs to the renderer
            renderer.BindGlobalInputs(new IShaderInput[] { sceneData, cameraBuffer });

            //Bind the targets to the renderer
            renderer.BindTargets(new [] { depthTarget });

            //Tell the renderer to allocate its resources based on the data we've provided
            renderer.CreateResources();

            //Store the aspect of the swapchain, we need it later to calculate the shadow frustum
            swapchainAspect = (float)swapchainSize.X / swapchainSize.Y;
        }
        internal void CreateResources(DeviceTexture blurTarget)
        {
            ThrowIfDisposed();

            //Dispose of the resources
            targetB?.Dispose();
            samplerHor?.Dispose();
            samplerVer?.Dispose();

            //Create a temp target (same format and size as the blur-target) so we can ping-point
            //between the original target and this temp target for each blur step
            targetB = DeviceTexture.CreateColorTarget(blurTarget.Size, blurTarget.Format, scene);

            //Create samplers
            samplerHor = new DeviceSampler(scene.LogicalDevice, blurTarget, disposeTexture: false);
            samplerVer = new DeviceSampler(scene.LogicalDevice, targetB, disposeTexture: false);

            //Bind the inputs
            rendererHor.BindGlobalInputs(new IShaderInput[] { samplerHor });
            rendererVer.BindGlobalInputs(new IShaderInput[] { samplerVer });

            //Bind the targets
            rendererHor.BindTargets(new [] { targetB });
            rendererVer.BindTargets(new [] { blurTarget });

            //Tell the renderers to allocate their resources based on the data we've provided
            rendererHor.CreateResources();
            rendererVer.CreateResources();
        }
Ejemplo n.º 4
0
        internal void CreateResources(Int2 swapchainSize)
        {
            ThrowIfDisposed();

            //Dispose of the old target
            bloomTarget?.Dispose();

            //Dispose of the old sampler
            bloomSampler?.Dispose();

            //Create the new render target
            bloomTarget = DeviceTexture.CreateColorTarget(
                size: (swapchainSize * targetSizeMultiplier).RoundToInt(), bloomFormat, scene);

            //Create sampler
            bloomSampler = new DeviceSampler(scene.LogicalDevice, bloomTarget, disposeTexture: false);

            //Bind inputs to the renderer
            renderer.BindGlobalInputs(new IShaderInput[] { gbufferTechnique.ColorOutput });

            //Bind the targets to the renderer
            renderer.BindTargets(new [] { bloomTarget });

            //Tell the renderer to allocate its resources based on the data we've provided
            renderer.CreateResources();

            //Initialize the blurTechnique, point it to the bloom-target
            blurTechnique.CreateResources(bloomTarget);
        }
Ejemplo n.º 5
0
        public void Dispose()
        {
            ThrowIfDisposed();

            blurTechnique.Dispose();
            renderer.Dispose();
            renderObject.Dispose();
            rotationNoiseSampler.Dispose();
            aoTarget?.Dispose();
            sampleKernelBuffer.Dispose();

            disposed = true;
        }
        internal void CreateResources(Int2 swapchainSize, IShaderInput sceneData)
        {
            ThrowIfDisposed();

            //Dispose of the old targets
            colorTarget?.Dispose();
            normalTarget?.Dispose();
            attributeTarget?.Dispose();
            depthTarget?.Dispose();

            //Dispose of the old samplers
            colorSampler?.Dispose();
            normalSampler?.Dispose();
            attributeSampler?.Dispose();
            depthSampler?.Dispose();

            //Create the new render targets
            colorTarget     = DeviceTexture.CreateColorTarget(swapchainSize, colorFormat, scene);
            normalTarget    = DeviceTexture.CreateColorTarget(swapchainSize, normalFormat, scene);
            attributeTarget = DeviceTexture.CreateColorTarget(swapchainSize, attributeFormat, scene);
            depthTarget     = DeviceTexture.CreateDepthTarget(swapchainSize, depthFormat, scene);

            //Create samplers for the targets
            colorSampler     = new DeviceSampler(scene.LogicalDevice, colorTarget, disposeTexture: false);
            normalSampler    = new DeviceSampler(scene.LogicalDevice, normalTarget, disposeTexture: false);
            attributeSampler = new DeviceSampler(scene.LogicalDevice, attributeTarget, disposeTexture: false);
            depthSampler     = new DeviceSampler(scene.LogicalDevice, depthTarget, disposeTexture: false);

            //Bind inputs to the renderer
            renderer.BindGlobalInputs(new IShaderInput[] { sceneData, cameraBuffer });

            //Bind the targets to the renderer
            renderer.BindTargets(new [] { colorTarget, normalTarget, attributeTarget, depthTarget });

            //Tell the renderer to allocate its resources based on the data we've provided
            renderer.CreateResources();
        }