Exemplo n.º 1
0
        public Sky(Device device, string filename, float skySphereRadius)
        {
            CubeMapSRV = ShaderResourceView.FromFile(device, filename);
            using (var r = CubeMapSRV.Resource) {
                r.DebugName = "sky cubemap";
            }

            var sphere   = GeometryGenerator.CreateSphere(skySphereRadius, 30, 30);
            var vertices = sphere.Vertices.Select(v => v.Position).ToArray();
            var vbd      = new BufferDescription(
                Marshal.SizeOf(typeof(Vector3)) * vertices.Length,
                ResourceUsage.Immutable,
                BindFlags.VertexBuffer,
                CpuAccessFlags.None,
                ResourceOptionFlags.None,
                0
                );

            _vb = new Buffer(device, new DataStream(vertices, false, false), vbd);

            _indexCount = sphere.Indices.Count;
            var ibd = new BufferDescription(
                _indexCount * sizeof(int),
                ResourceUsage.Immutable,
                BindFlags.IndexBuffer,
                CpuAccessFlags.None,
                ResourceOptionFlags.None,
                0
                );

            _ib = new Buffer(device, new DataStream(sphere.Indices.ToArray(), false, false), ibd);
        }
Exemplo n.º 2
0
        private void BuildScreenQuadGeometryBuffers()
        {
            var quad = GeometryGenerator.CreateFullScreenQuad();

            var verts = quad.Vertices.Select(v => new Basic32(v.Position, v.Normal, v.TexC)).ToList();
            var vbd   = new BufferDescription(Basic32.Stride * verts.Count, ResourceUsage.Immutable, BindFlags.VertexBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, 0);

            ScreenQuadVB = new Buffer(Device, new DataStream(verts.ToArray(), false, false), vbd);

            var ibd = new BufferDescription(sizeof(int) * quad.Indices.Count, ResourceUsage.Immutable, BindFlags.IndexBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, 0);

            ScreenQuadIB = new Buffer(Device, new DataStream(quad.Indices.ToArray(), false, false), ibd);
        }