Esempio 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();
        }
Esempio 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;
        }
Esempio n. 3
0
        internal void CreateResources(Int2 swapchainSize)
        {
            ThrowIfDisposed();

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

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

            //Bind inputs to the renderer
            renderer.BindGlobalInputs(new IShaderInput[] {
                gbufferTechnique.CameraOutput,
                gbufferTechnique.DepthOutput,
                gbufferTechnique.NormalOutput,
                sampleKernelBuffer,
                rotationNoiseSampler
            });

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

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

            //Initialize the blurTechnique, point it to the ao-target
            blurTechnique.CreateResources(aoTarget);
        }
        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();
        }
Esempio n. 5
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);
        }
Esempio n. 6
0
        public void Run()
        {
            PlainCoreSettings.GlfwSearchPath = Path.GetFullPath("../../../../../Native/");

            var window = new OpenGLWindow(800, 600, "Hello Core!", false, false);

            window.OnClosed += () => Console.WriteLine("Closed!");

            Setup();

            while (window.IsOpen)
            {
                defaultFramebuffer.Clear(Color4.CornflowerBlue);

                window.PollEvents();

                Draw();

                window.Display();
            }

            pipeline.Dispose();
            vao.Dispose();
            buffer.Dispose();
            indexBuffer.Dispose();
            texture.Dispose();
            defaultFramebuffer.Dispose();
            window.Dispose();
        }
Esempio n. 7
0
 public void ClearDeviceResources()
 {
     _deviceTexture?.Dispose();
     _textureBinding?.Dispose();
     if (_isTransparent)
     {
         _ib?.Dispose();
     }
 }
Esempio n. 8
0
 public void Dispose()
 {
     _vb?.Dispose();
     _ib?.Dispose();
     _material?.Dispose();
     _texture?.Dispose();
     _textureBinding?.Dispose();
     _wireframeState?.Dispose();
 }
Esempio n. 9
0
 public override void DestroyDeviceObjects()
 {
     _shaderSet.Dispose();
     _vb.Dispose();
     _ib.Dispose();
     _gridTexture.Dispose();
     _textureBinding.Dispose();
     _rasterizerState.Dispose();
 }
        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();
        }
Esempio n. 11
0
 public void Dispose()
 {
     deviceTexture.Dispose();
 }