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[] swapchain, IShaderInput sceneData) { ThrowIfDisposed(); //Bind the output of the renderer to the swapchain renderer.SetOutputCount(swapchain.Length); for (int i = 0; i < swapchain.Length; i++) { renderer.BindTargets(new [] { swapchain[i] }, outputIndex: i); } //Bind all the inputs renderer.BindGlobalInputs(new IShaderInput[] { sceneData, gbufferTechnique.CameraOutput, shadowTechnique.CameraOutput, gbufferTechnique.ColorOutput, gbufferTechnique.NormalOutput, gbufferTechnique.AttributeOutput, gbufferTechnique.DepthOutput, shadowTechnique.ShadowOutput, bloomTechnique.BloomOutput, aoTechnique.AOOutput }); //Tell the renderer to allocate its resources based on the data we've provided renderer.CreateResources(); }
public void SetFullScreenTransform(IShaderInput input, Matrix texture) { input.Transform = new Matrix(2, 0, 0, 0, 0, -2, 0, 0, 0, 0, 1, 0, -1, 1, 0, 1); input.TexTransform = texture; }
public void SetTrasform(IShaderInput input, Rectangle rec, Matrix textureTransform) { var rt = GraphicDeviceFactory.Device.GetRenderTarget(0); var transform = new Matrix(rec.Width, 0, 0, 0, 0, rec.Height, 0, 0, 0, 0, 1, 0, rec.X, rec.Y, 0, 1) * Matrix.Scale(1f / (float)rt.Width, 1f / (float)rt.Height, 1) * new Matrix(2, 0, 0, 0, 0, -2, 0, 0, 0, 0, 1, 0, -1, 1, 0, 1); input.Transform = transform; input.TexTransform = textureTransform; }
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(); }
public Render() : base(GraphicDeviceFactory.Device) { _sinput = Effect.Map <IShaderInput>(); _sprite = Service.Require <Sprite>(); }
public void SetFullScreenTransform(IShaderInput input) { SetFullScreenTransform(input, Matrix.Identity); }