6 using SiliconStudio.Paradox.Effects.Modules;
7 using SiliconStudio.Paradox.Games;
8 using SiliconStudio.Paradox.Graphics;
9 using SiliconStudio.Core.IO;
10 using SiliconStudio.Core.Mathematics;
12 namespace SiliconStudio.
Paradox.Effects
37 Parameters.SetDefault(GBufferBaseKeys.GBufferTexture);
38 ClearColor = Color.Transparent;
41 Tags.Set(RenderTargetKeys.RequireDepthStencilShaderResource,
true);
56 get {
return Parameters.Get(GBufferBaseKeys.GBufferTexture); }
72 var graphicsDevice = graphicsDeviceService.GraphicsDevice;
75 Parameters.AddSources(MainPlugin.ViewParameters);
77 if (OfflineCompilation)
81 var texture2D = Texture2D.New(
GraphicsDevice, 1024, 1024, 1, PixelFormat.A8_UNorm);
82 texture2D.Name =
"Renorm";
85 var texDataStream = VirtualFileSystem.OpenStream(
"/assets/effects/gbuffer/renorm.bin", VirtualFileMode.Open, VirtualFileAccess.Read);
86 var texFileLength = texDataStream.Length;
87 var texData =
new byte[texFileLength];
88 texDataStream.Read(texData, 0, (int)texFileLength);
89 texture2D.SetData(graphicsDevice, texData);
90 texDataStream.Dispose();
93 var mainDepthStencilState = MainTargetPlugin.Parameters.TryGet(EffectPlugin.DepthStencilStateKey) ?? graphicsDevice.DepthStencilStates.Default;
94 MainTargetPlugin.Parameters.Set(
EffectPlugin.DepthStencilStateKey, mainDepthStencilState);
97 var defaultDescription = mainDepthStencilState.Description;
98 ClearDepth = MainTargetPlugin.ClearDepth;
101 var depthStencilStateZStandard = DepthStencilState.New(GraphicsDevice, defaultDescription);
102 depthStencilStateZStandard.Name =
"ZStandard";
104 Parameters.Set(EffectPlugin.DepthStencilStateKey, depthStencilStateZStandard);
106 Parameters.Set(GBufferKeys.NormalPack, texture2D);
107 Parameters.Set(TexturingKeys.PointSampler, graphicsDevice.SamplerStates.PointWrap);
112 MainTargetPlugin.UseDepthStencilReadOnly =
true;
113 MainTargetPlugin.Parameters.Set(RenderTargetKeys.DepthStencilSource, DepthStencil.Texture);
114 MainTargetPlugin.DepthStencilReadOnly = DepthStencil.Texture.ToDepthStencilBuffer(
true);
118 RenderPass.EndPass += (context) =>
126 defaultDescription = mainDepthStencilState.Description;
127 defaultDescription.DepthBufferWriteEnable =
false;
128 DepthStencilStateZReadOnly = DepthStencilState.New(GraphicsDevice,defaultDescription);
129 DepthStencilStateZReadOnly.Name =
"ZReadOnly";
132 var gbufferTexture = Texture2D.New(GraphicsDevice, graphicsDevice.BackBuffer.Width, graphicsDevice.BackBuffer.Height, PixelFormat.R8G8B8A8_UNorm, TextureFlags.ShaderResource | TextureFlags.RenderTarget);
133 gbufferTexture.Name =
"GBufferTexture";
134 Parameters.Set(GBufferBaseKeys.GBufferTexture, gbufferTexture);
138 MainTargetPlugin.Parameters.Set(GBufferBaseKeys.GBufferTexture, gbufferTexture);
Service providing method to access GraphicsDevice life-cycle.
override void Initialize()
A renderable texture view.
Contains depth-stencil state for the device.
Plugin used to render to a GBuffer from a MainPlugin.
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.
GBufferPlugin()
Initializes a new instance of the GBufferPlugin class.
Plugin used for the main rendering view.
A Texture 2D frontend to SharpDX.Direct3D11.Texture2D.
Level10 render pass using a depth buffer and a render target.
override void ProcessModelView(RenderModelView2 effectModelView)
GBufferPlugin(string name)
Initializes a new instance of the GBufferPlugin class.