コード例 #1
0
 public abstract void SetBuffers(RenderableLightPrimitive primitive, Light light);
コード例 #2
0
        public override void SetBuffers(RenderableLightPrimitive primitive, Light light)
        {
            DeviceContext Context = Renderer.Context;
            PointLight pLight = light as PointLight;

            Context.InputAssembler.InputLayout = primitive.Shader.InputLayout;
            Context.InputAssembler.PrimitiveTopology = primitive.Shader.Topology;
            Context.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(primitive.VertexBuffer, 3 * sizeof(float), 0));
            Context.InputAssembler.SetIndexBuffer(primitive.IndexBuffer, Format.R16_UInt, 0);

            primitive.Shader.ConstantBuffers[0].FillBuffer(Context, Matrix.Scaling(pLight.Radius, pLight.Radius, pLight.Radius) * Matrix.Translation(pLight.Position));
            //primitive.Shader.ConstantBuffers[1].FillBuffer(Context, Matrix.Identity, pLight.Position, new Vector4(pLight.Color, pLight.Intensity));

            foreach (ConstantBufferWrapper cbuff in primitive.Shader.ConstantBuffers)
            {
                if (cbuff.ShaderType == ShaderType.VertexShader)
                    Context.VertexShader.SetConstantBuffer(cbuff.CBuffer, cbuff.ResourceSlot);
                if (cbuff.ShaderType == ShaderType.PixelShader)
                    Context.PixelShader.SetConstantBuffer(cbuff.CBuffer, cbuff.ResourceSlot);
            }

            //DeferredLighting LightingSystem = Renderer.LightingSystem as DeferredLighting;

            //Context.PixelShader.SetShaderResource(LightingSystem.PositionSRV, 0);
            //Context.PixelShader.SetShaderResource(LightingSystem.NormalSRV, 1);
            //Context.PixelShader.SetShaderResource(LightingSystem.LinearDepthSRV, 2);
        }