Esempio n. 1
0
        public override void Initialize()
        {
            AdapterConfig = new()
            {
                SwapChain = true,
            };


            Camera.SetPosition(0, -0.55f, -8.0f);
            Camera.Update();

            Adapter   = new(AdapterConfig);
            Device    = new(Adapter);
            SwapChain = new(Device, new()
            {
                Source = GetSwapchainSource(Adapter),
                ColorSrgb = false,
                Height = Window.Height,
                Width = Window.Width,
                VSync = false,
                DepthFormat = Adapter.DepthFormat is VkFormat.Undefined ? null : Adapter.DepthFormat
            });

            Context     = new(Device);
            Framebuffer = new(SwapChain);

            uniform = new(Camera.Projection, Model, Camera.View);

            light = new()
            {
                Ambient   = new Vector4(0.5f, 0.5f, 0.5f, 1.0f),
                Diffuse   = new Vector4(0.8f, 0.8f, 0.8f, 1.0f),
                Direction = new Vector3(1, 1, -1.05f),
            };



            ConstBuffer = new(Device, new()
            {
                BufferFlags = BufferFlags.ConstantBuffer,
                Usage = ResourceUsage.CPU_To_GPU,
                SizeInBytes = Interop.SizeOf <TransformUniform>(),
            });


            ConstBuffer2 = new(Device, new()
            {
                BufferFlags = BufferFlags.ConstantBuffer,
                Usage = ResourceUsage.CPU_To_GPU,
                SizeInBytes = Interop.SizeOf <Light>(),
            });


            GLTFModel = new(Device, Constants.ModelsFile + "chinesedragon.gltf");

            CreatePipelineState();
        }
Esempio n. 2
0
        public override void Initialize()
        {
            AdapterConfig = new()
            {
                SwapChain  = true,
                Debug      = false,
                Fullscreen = false,
            };


            Camera.SetPosition(0, -8, -40.0f);
            Camera.Update();

            Adapter   = new(AdapterConfig);
            Device    = new(Adapter);
            SwapChain = new(Device, new()
            {
                Source = GetSwapchainSource(Adapter),
                ColorSrgb = false,
                Height = Window.Height,
                Width = Window.Width,
                VSync = false,
                DepthFormat = Adapter.DepthFormat is VkFormat.Undefined ? null : Adapter.DepthFormat
            });

            Context     = new(Device);
            Framebuffer = new(SwapChain);

            uniform = new(Camera.Projection, Model, Camera.View);
            light   = new(new Vector4(1.0f, 1.0f, 1.0f, 1.0f), new Vector3(0.0f, 0.0f, 0.0f));


            BufferDescription bufferDescription = new()
            {
                BufferFlags = BufferFlags.ConstantBuffer,
                Usage       = ResourceUsage.CPU_To_GPU,
                SizeInBytes = Interop.SizeOf <TransformUniform>(),
            };

            ConstBuffer  = new(Device, bufferDescription);
            ConstBuffer2 = new(Device, bufferDescription);
            ConstBuffer3 = new(Device, bufferDescription);

            ConstBuffer4 = new(Device, new()
            {
                BufferFlags = BufferFlags.ConstantBuffer,
                Usage = ResourceUsage.CPU_To_GPU,
                SizeInBytes = Interop.SizeOf <Light>(),
            });



            CreatePipelineState();

            GLTFModel = new(Device, Constants.ModelsFile + "mesh_mat.gltf");
        }
Esempio n. 3
0
        public void CreateBuffers()
        {
            VertexPositionColor[] vertices = new[]
            {
                new VertexPositionColor(new Vector3(0.0f, -0.65f, -0.5f), new Vector3(1.6f, 0.0f, 0.0f)),
                new VertexPositionColor(new Vector3(0.65f, 0.65f, -0.5f), new Vector3(0.0f, 1.6f, 0.0f)),
                new VertexPositionColor(new Vector3(-0.65f, 0.65f, -0.5f), new Vector3(0.0f, 0.0f, 1.6f)),
            };


            int[] indices = new[]
            {
                0, 1, 2
            };


            VertexBuffer = new(Device, new()
            {
                BufferFlags = BufferFlags.VertexBuffer,
                Usage = ResourceUsage.CPU_To_GPU,
                SizeInBytes = Interop.SizeOf <VertexPositionColor>(vertices),
            });
            VertexBuffer.SetData(vertices);


            IndexBuffer = new(Device, new()
            {
                BufferFlags = BufferFlags.IndexBuffer,
                Usage = ResourceUsage.CPU_To_GPU,
                SizeInBytes = Interop.SizeOf <int>(indices),
            });
            IndexBuffer.SetData(indices);


            ConstBuffer = new(Device, new()
            {
                BufferFlags = BufferFlags.ConstantBuffer,
                Usage = ResourceUsage.CPU_To_GPU,
                SizeInBytes = Interop.SizeOf <TransformUniform>(),
            });
        }
Esempio n. 4
0
        public override void Initialize()
        {
            AdapterConfig = new()
            {
                SwapChain = true,
            };


            Camera.SetPosition(0, 0, -8.0f);
            Camera.Update();

            Adapter   = new(AdapterConfig);
            Device    = new(Adapter);
            SwapChain = new(Device, new()
            {
                Source = GetSwapchainSource(Adapter),
                ColorSrgb = false,
                Height = Window.Height,
                Width = Window.Width,
                VSync = false,
                DepthFormat = Adapter.DepthFormat is VkFormat.Undefined ? null : Adapter.DepthFormat
            });

            Context     = new(Device);
            Framebuffer = new(SwapChain);

            uniform = new(Camera.Projection, Camera.View);

            light = new()
            {
                Ambient       = new Vector4(0.5f, 0.5f, 0.5f, 1.0f),
                Diffuse       = new Vector4(0.8f, 0.8f, 0.8f, 1.0f),
                Direction     = new Vector3(1, 1, -1.05f),
                Specular      = new(1, 1, 1),
                SpecularPower = 30,
            };



            ConstBuffer = new(Device, new()
            {
                BufferFlags = BufferFlags.ConstantBuffer,
                Usage = ResourceUsage.CPU_To_GPU,
                SizeInBytes = Interop.SizeOf <TransformUniform>(),
            });


            ConstBuffer2 = new(Device, new()
            {
                BufferFlags = BufferFlags.ConstantBuffer,
                Usage = ResourceUsage.CPU_To_GPU,
                SizeInBytes = Interop.SizeOf <Light>(),
            });

            Sphere          = new(Device, Vultaik.Toolkit.GeometricPrimitives.PrimitiveType.Sphere);
            Sphere.Position = new(-2.5f, 1.5f, 0.0f);

            Torus          = new(Device, Vultaik.Toolkit.GeometricPrimitives.PrimitiveType.Torus);
            Torus.Position = new(2.5f, 1.5f, 0.0f);

            Pyramid          = new(Device, Vultaik.Toolkit.GeometricPrimitives.PrimitiveType.Pyramid);
            Pyramid.Position = new(-2.5f, -1.5f, 0.0f);

            Cube          = new(Device, Vultaik.Toolkit.GeometricPrimitives.PrimitiveType.Cube);
            Cube.Position = new(2.5f, -1.5f, 0.0f);

            Capsule          = new(Device, Vultaik.Toolkit.GeometricPrimitives.PrimitiveType.Capsule);
            Capsule.Position = new(0, 0, 0.0f);
            Capsule.Size     = new(0.4f, 0.4f, 0.4f);

            CreatePipelineState();
        }