Пример #1
0
        internal void Draw(Matrix4x4 matrix)
        {
            if (Game.Lights.Count == 0)
            {
                return;
            }

            Game.GraphicsDevice.SetRenderTarget(RenderTarget);
            Game.GraphicsDevice.Clear(Color.Transparent);
            RenderTarget.TextureSlot(0);
            RenderTarget.BindTexture();

            Matrix4x4 mat = matrix * Graphics.ViewProjectionMatrix;

            int i = 0;

            foreach (Light l in Game.Lights)
            {
                LightData ldata = new LightData();
                ldata.Position  = l.Position.Transform(matrix);
                ldata.Intensity = (float)l.Intensity;
                ldata.Radius    = (float)(l.Radius * Game.Instance.Camera.ZoomFactor);
                ldata.Color[0]  = l.Color.RedComponent / 255f;
                ldata.Color[1]  = l.Color.GreenComponent / 255f;
                ldata.Color[2]  = l.Color.BlueComponent / 255f;
                lightData[i++]  = ldata;
            }

            databuffer.UpdateBuffer(0, lightData);

            var device = Game.GraphicsDevice;

            Graphics.SimpleFloodLightShader.Use();

            Vao.Bind();
            gl.Enable(Silk.NET.OpenGL.GLEnum.Blend);
            gl.BlendFunc(Silk.NET.OpenGL.GLEnum.SrcAlpha, Silk.NET.OpenGL.GLEnum.One);
            gl.DrawArraysInstanced(Silk.NET.OpenGL.GLEnum.Triangles, 0, 6, (uint)Game.Lights.Count);
        }