Пример #1
0
        private static void InitMesh(GxContext context)
        {
            // all tiles will supply their own vertex buffer
            ChunkMesh.VertexBuffer.Dispose();

            ChunkMesh.AddElement("POSITION", 0, 3);
            ChunkMesh.AddElement("NORMAL", 0, 3);
            ChunkMesh.AddElement("TEXCOORD", 0, 2);
            ChunkMesh.AddElement("TEXCOORD", 1, 2);
            ChunkMesh.AddElement("COLOR", 0, 4, DataType.Byte, true);
            ChunkMesh.AddElement("COLOR", 1, 4, DataType.Byte, true);

            ChunkMesh.IndexCount = 768;
            ChunkMesh.Stride     = IO.SizeCache <IO.Files.Terrain.AdtVertex> .Size;
            ChunkMesh.BlendState.BlendEnabled     = false;
            ChunkMesh.DepthState.DepthEnabled     = true;
            ChunkMesh.RasterizerState.CullEnabled = true;

            BlendNew = new ShaderProgram(context);
            BlendNew.SetVertexShader(Resources.Shaders.TerrainVertex);
            BlendNew.SetPixelShader(Resources.Shaders.TerrainPixelNew);

            ChunkMesh.Program = BlendNew;
            ChunkMesh.InitLayout(BlendNew);

            BlendOld = new ShaderProgram(context);
            BlendOld.SetVertexShader(Resources.Shaders.TerrainVertex);
            BlendOld.SetPixelShader(Resources.Shaders.TerrainPixel);

            ColorSampler = new Sampler(context)
            {
                AddressU          = SharpDX.Direct3D11.TextureAddressMode.Wrap,
                AddressV          = SharpDX.Direct3D11.TextureAddressMode.Wrap,
                AddressW          = SharpDX.Direct3D11.TextureAddressMode.Clamp,
                Filter            = SharpDX.Direct3D11.Filter.Anisotropic,
                MaximumAnisotropy = 16,
            };
            AlphaSampler = new Sampler(context)
            {
                AddressU          = SharpDX.Direct3D11.TextureAddressMode.Clamp,
                AddressV          = SharpDX.Direct3D11.TextureAddressMode.Clamp,
                AddressW          = SharpDX.Direct3D11.TextureAddressMode.Clamp,
                Filter            = SharpDX.Direct3D11.Filter.Anisotropic,
                MaximumAnisotropy = 16,
            };
        }