3 using SiliconStudio.Core;
4 using SiliconStudio.Core.IO;
5 using SiliconStudio.Core.Mathematics;
6 using SiliconStudio.Core.Serialization.Assets;
7 using SiliconStudio.Paradox.Graphics;
9 namespace SiliconStudio.
Paradox.Effects.Modules
18 private bool useNormalPack;
21 : base(services, recursivePipeline)
23 this.depthStencilBuffer = depthStencilBuffer;
24 useNormalPack = normalPack;
29 get {
return gbufferTexture; }
35 GraphicsDevice.Clear(gbufferTextureRenderTarget, Color.Transparent);
36 GraphicsDevice.Clear(depthStencilBuffer, DepthStencilClearOptions.DepthBuffer | DepthStencilClearOptions.Stencil);
37 GraphicsDevice.SetRenderTarget(depthStencilBuffer, gbufferTextureRenderTarget);
39 base.OnRendering(context);
42 public override void Load()
47 gbufferTexture = Texture2D.New(
GraphicsDevice, GraphicsDevice.BackBuffer.Width,
48 GraphicsDevice.BackBuffer.Height, PixelFormat.R32G32B32A32_Float,
49 TextureFlags.RenderTarget | TextureFlags.ShaderResource);
51 gbufferTextureRenderTarget = gbufferTexture.ToRenderTarget();
58 using (var texDataStream = assetManager.OpenAsStream(
"renorm.bin", StreamFlags.None))
60 var texFileLength = texDataStream.Length;
61 var texData =
new byte[texFileLength];
62 texDataStream.Read(texData, 0, (int)texFileLength);
64 gbufferRenormTexture = Texture2D.New(GraphicsDevice, 1024, 1024, PixelFormat.A8_UNorm, texData);
65 gbufferRenormTexture.Name =
"Renorm";
68 RecursivePipeline.Parameters.Set(GBufferKeys.NormalPack, gbufferRenormTexture);
72 RecursivePipeline.Parameters.AddSources(Pass.Parameters);
74 Pass.Parameters.Set(GBufferBaseKeys.GBufferTexture, gbufferTexture);
82 RecursivePipeline.Parameters.Remove(GBufferKeys.NormalPack);
83 Pass.Parameters.Remove(GBufferBaseKeys.GBufferTexture);
86 Utilities.Dispose(ref gbufferTextureRenderTarget);
87 Utilities.Dispose(ref gbufferTexture);
88 Utilities.Dispose(ref gbufferRenormTexture);
override void Unload()
Unloads this instance. This method is called when a RenderPass is de-attached (directly or indirectly...
A renderable texture view.
GBufferRenderProcessor(IServiceRegistry services, RenderPipeline recursivePipeline, DepthStencilBuffer depthStencilBuffer, bool normalPack)
Interface of the asset manager.
A service registry is a IServiceProvider that provides methods to register and unregister services...
Performs primitive-based rendering, creates resources, handles system-level variables, adjusts gamma ramp levels, and creates shaders. See The+GraphicsDevice+class to learn more about the class.
override void OnRendering(RenderContext context)
This Renderer recursively render another RenderPass.
override void Load()
Loads this instance. This method is called when a RenderPass is attached (directly or indirectly) to ...
Thread-local storage context used during rendering.
A Texture 2D frontend to SharpDX.Direct3D11.Texture2D.
Defines an entry point for mesh instantiation and recursive rendering.