예제 #1
0
        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)));
        }
예제 #3
0
 public SimpleShaderResources(
     GraphicsDevice graphicsDevice,
     GlobalShaderResources globalShaderResources,
     MeshShaderResources meshShaderResources)
     : base(
         graphicsDevice,
         globalShaderResources,
         meshShaderResources,
         "Simple",
         CreateMaterialResourceBindings)
 {
 }
예제 #4
0
 public NormalMappedShaderResources(
     GraphicsDevice graphicsDevice,
     GlobalShaderResources globalShaderResources,
     MeshShaderResources meshShaderResources)
     : base(
         graphicsDevice,
         globalShaderResources,
         meshShaderResources,
         "NormalMapped",
         CreateMaterialResourceBindings)
 {
 }
예제 #5
0
        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);
        }
예제 #6
0
        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)));
        }