コード例 #1
0
ファイル: AmbientLighting.cs プロジェクト: FaberSanZ/Vultaik
        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();
        }
コード例 #2
0
ファイル: DiffuseLighting.cs プロジェクト: FaberSanZ/Vultaik
        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");
        }