Exemple #1
0
        private void Render()
        {
            ClearRenderTargets();
            Camera.Freeze();

            // 모델 렌더링
            foreach (var triangle in Model.Triangles)
            {
                GBufferShader.DrawPrimitive(triangle);
            }

            // 화면 전체를 덮는 사각형으로 조명 처리
            Camera.World = Camera.View = Camera.Projection = Matrix.CreateIdentity();
            var full = new Triangle[] {
                new Triangle(
                    new Vertex(new Vector3(-1, 1, 0), new Vector3(1, 1, 1)),
                    new Vertex(new Vector3(-1, -1, 0), new Vector3(1, 1, 1)),
                    new Vertex(new Vector3(1, 1, 0), new Vector3(1, 1, 1))
                    ),
                new Triangle(
                    new Vertex(new Vector3(1, 1, 0), new Vector3(1, 1, 1)),
                    new Vertex(new Vector3(-1, -1, 0), new Vector3(1, 1, 1)),
                    new Vertex(new Vector3(1, -1, 0), new Vector3(1, 1, 1))
                    )
            };

            PointLightShader.Intensity     = 0.4f;
            PointLightShader.LightPosition = new Vector4(-100, 50, 100, 1) * Camera.Transform;

            foreach (var triangle in full)
            {
                AmbientLightShader.DrawPrimitive(triangle);
                PointLightShader.DrawPrimitive(triangle);
            }
        }
Exemple #2
0
        private void InitializeShaders()
        {
            GBufferShader      = new GBufferShader(this);
            AmbientLightShader = new AmbientLightShader(this);
            PointLightShader   = new PointLightShader(this);

            AmbientLightShader.Intensity = 0.1f;
        }