Beispiel #1
0
        public static Material CreateRegularPassMaterial(ResourceFactory factory)
        {
            Shader            vs          = factory.CreateShader(ShaderStages.Vertex, ShaderHelper.LoadShaderCode("shadow-vertex", ShaderStages.Vertex, factory));
            Shader            fs          = factory.CreateShader(ShaderStages.Fragment, ShaderHelper.LoadShaderCode("shadow-frag", ShaderStages.Fragment, factory));
            VertexInputLayout inputLayout = factory.CreateInputLayout(
                new VertexInputDescription(
                    32,
                    new VertexInputElement("in_position", VertexSemanticType.Position, VertexElementFormat.Float3),
                    new VertexInputElement("in_normal", VertexSemanticType.Normal, VertexElementFormat.Float3),
                    new VertexInputElement("in_texCoord", VertexSemanticType.TextureCoordinate, VertexElementFormat.Float2)));
            ShaderSet shaderSet = factory.CreateShaderSet(inputLayout, vs, fs);
            ShaderResourceBindingSlots constantSlots = factory.CreateShaderResourceBindingSlots(
                shaderSet,
                new ShaderResourceDescription("ProjectionMatrixBuffer", ShaderConstantType.Matrix4x4),
                new ShaderResourceDescription("ViewMatrixBuffer", ShaderConstantType.Matrix4x4),
                new ShaderResourceDescription("LightProjectionMatrixBuffer", ShaderConstantType.Matrix4x4),
                new ShaderResourceDescription("LightViewMatrixBuffer", ShaderConstantType.Matrix4x4),
                new ShaderResourceDescription("LightInfoBuffer", ShaderConstantType.Float4),
                new ShaderResourceDescription("WorldMatrixBuffer", ShaderConstantType.Matrix4x4),
                new ShaderResourceDescription("InverseTransposeWorldMatrixBuffer", ShaderConstantType.Matrix4x4),
                new ShaderResourceDescription("SurfaceTexture", ShaderResourceType.Texture),
                new ShaderResourceDescription("SurfaceTexture", ShaderResourceType.Sampler),
                new ShaderResourceDescription("ShadowMap", ShaderResourceType.Texture),
                new ShaderResourceDescription("ShadowMap", ShaderResourceType.Sampler));

            return(new Material(shaderSet, constantSlots));
        }
        public static Material CreateShadowPassMaterial(ResourceFactory factory)
        {
            Shader            vs          = factory.CreateShader(ShaderStages.Vertex, ShaderHelper.LoadShaderCode("shadowmap-vertex", ShaderStages.Vertex, factory));
            Shader            fs          = factory.CreateShader(ShaderStages.Fragment, ShaderHelper.LoadShaderCode("shadowmap-frag", ShaderStages.Fragment, factory));
            VertexInputLayout inputLayout = factory.CreateInputLayout(
                new VertexInputDescription(
                    12,
                    new VertexInputElement("in_position", VertexSemanticType.Position, VertexElementFormat.Float3)));
            ShaderSet shaderSet = factory.CreateShaderSet(inputLayout, vs, fs);
            ShaderResourceBindingSlots constantSlots = factory.CreateShaderResourceBindingSlots(
                shaderSet,
                new ShaderResourceDescription("ProjectionMatrixBuffer", ShaderConstantType.Matrix4x4), // Light Projection
                new ShaderResourceDescription("ViewMatrixBuffer", ShaderConstantType.Matrix4x4),       // Light View
                new ShaderResourceDescription("WorldMatrixBuffer", ShaderConstantType.Matrix4x4));

            return(new Material(shaderSet, constantSlots));
        }