public ShaderResourceManager( GraphicsDevice graphicsDevice, StandardGraphicsResources standardGraphicsResources) { using (GameTrace.TraceDurationEvent("ShaderResourceManager()")) { Global = AddDisposable(new GlobalShaderResources(graphicsDevice, standardGraphicsResources.SolidWhiteTexture)); Mesh = AddDisposable(new MeshShaderResources(graphicsDevice)); RadiusCursor = AddDisposable(new RadiusCursorDecalShaderResources(graphicsDevice, standardGraphicsResources.Aniso4xClampSampler)); FixedFunction = AddDisposable(new FixedFunctionShaderResources(graphicsDevice, Global, Mesh)); MeshDepth = AddDisposable(new MeshDepthShaderResources(graphicsDevice, Global, Mesh)); Particle = AddDisposable(new ParticleShaderResources(graphicsDevice, Global)); Road = AddDisposable(new RoadShaderResources(graphicsDevice, Global, RadiusCursor)); Sprite = AddDisposable(new SpriteShaderResources(graphicsDevice)); Terrain = AddDisposable(new TerrainShaderResources(graphicsDevice, Global, RadiusCursor)); Water = AddDisposable(new WaterShaderResources(graphicsDevice, Global)); _shaderMaterialResources = new Dictionary <string, ShaderMaterialShaderResources> { { "NormalMapped", AddDisposable(new NormalMappedShaderResources(graphicsDevice, Global, Mesh)) }, { "Simple", AddDisposable(new SimpleShaderResources(graphicsDevice, Global, Mesh)) } }; } }
public MeshDepthShaderResources( GraphicsDevice graphicsDevice, GlobalShaderResources globalShaderResources, MeshShaderResources meshShaderResources) : base( graphicsDevice, "MeshDepth", new GlobalResourceSetIndices(0u, LightingType.None, null, null, null, 2u), MeshShaderResources.MeshVertex.VertexDescriptors) { var depthRasterizerState = RasterizerStateDescriptionUtility.DefaultFrontIsCounterClockwise; depthRasterizerState.DepthClipEnabled = false; depthRasterizerState.ScissorTestEnabled = false; var resourceLayouts = new[] { globalShaderResources.GlobalConstantsResourceLayout, meshShaderResources.MeshConstantsResourceLayout, meshShaderResources.RenderItemConstantsResourceLayout, meshShaderResources.SkinningResourceLayout }; Pipeline = AddDisposable(graphicsDevice.ResourceFactory.CreateGraphicsPipeline( new GraphicsPipelineDescription( BlendStateDescription.SingleDisabled, DepthStencilStateDescription.DepthOnlyLessEqual, depthRasterizerState, PrimitiveTopology.TriangleList, ShaderSet.Description, resourceLayouts, ShadowData.DepthPassDescription))); }
public SimpleShaderResources( GraphicsDevice graphicsDevice, GlobalShaderResources globalShaderResources, MeshShaderResources meshShaderResources) : base( graphicsDevice, globalShaderResources, meshShaderResources, "Simple", CreateMaterialResourceBindings) { }
public NormalMappedShaderResources( GraphicsDevice graphicsDevice, GlobalShaderResources globalShaderResources, MeshShaderResources meshShaderResources) : base( graphicsDevice, globalShaderResources, meshShaderResources, "NormalMapped", CreateMaterialResourceBindings) { }
public FixedFunctionShaderResources( GraphicsDevice graphicsDevice, GlobalShaderResources globalShaderResources, MeshShaderResources meshShaderResources) : base( graphicsDevice, "FixedFunction", new GlobalResourceSetIndices(0u, LightingType.Object, 1u, 2u, 3u, 7u), MeshShaderResources.MeshVertex.VertexDescriptors) { _pipelines = new Dictionary <PipelineKey, Pipeline>(); _materialResourceLayout = AddDisposable(graphicsDevice.ResourceFactory.CreateResourceLayout( new ResourceLayoutDescription( new ResourceLayoutElementDescription("MaterialConstants", ResourceKind.UniformBuffer, ShaderStages.Fragment), new ResourceLayoutElementDescription("Texture0", ResourceKind.TextureReadOnly, ShaderStages.Fragment), new ResourceLayoutElementDescription("Texture1", ResourceKind.TextureReadOnly, ShaderStages.Fragment)))); _resourceLayouts = meshShaderResources.CreateResourceLayouts( globalShaderResources, _materialResourceLayout); }
protected ShaderMaterialShaderResources( GraphicsDevice graphicsDevice, GlobalShaderResources globalShaderResources, MeshShaderResources meshShaderResources, string shaderName, Func <IEnumerable <ResourceBinding> > createMaterialResourceBindings) : base( graphicsDevice, shaderName, new GlobalResourceSetIndices(0u, LightingType.Object, 1u, 2u, 3u, 7u), MeshShaderResources.MeshVertex.VertexDescriptors) { var materialResourceBindings = createMaterialResourceBindings().ToArray(); MaterialResourceBindings = materialResourceBindings.ToDictionary(x => x.Description.Name); var materialResourceLayoutElements = materialResourceBindings .Select(x => x.Description) .ToArray(); _materialResourceLayout = AddDisposable(graphicsDevice.ResourceFactory.CreateResourceLayout( new ResourceLayoutDescription(materialResourceLayoutElements))); var resourceLayouts = meshShaderResources.CreateResourceLayouts( globalShaderResources, _materialResourceLayout); Pipeline = AddDisposable(graphicsDevice.ResourceFactory.CreateGraphicsPipeline( new GraphicsPipelineDescription( BlendStateDescription.SingleDisabled, DepthStencilStateDescription.DepthOnlyLessEqual, RasterizerStateDescriptionUtility.DefaultFrontIsCounterClockwise, PrimitiveTopology.TriangleList, ShaderSet.Description, resourceLayouts, RenderPipeline.GameOutputDescription))); }