• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Direct3D11.InputLayout类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中SharpDX.Direct3D11.InputLayout的典型用法代码示例。如果您正苦于以下问题:C# InputLayout类的具体用法?C# InputLayout怎么用?C# InputLayout使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



InputLayout类属于SharpDX.Direct3D11命名空间,在下文中一共展示了InputLayout类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: PhysicsDebugDraw

        public PhysicsDebugDraw(DeviceManager manager)
        {
            device = manager.Direct3DDevice;
            inputAssembler = device.ImmediateContext.InputAssembler;
            lineArray = new PositionColored[0];

            using (var bc = HLSLCompiler.CompileFromFile(@"Shaders\PhysicsDebug.hlsl", "VSMain", "vs_5_0"))
            {
                vertexShader = new VertexShader(device, bc);

                InputElement[] elements = new InputElement[]
                {
                    new InputElement("SV_POSITION", 0, Format.R32G32B32_Float, 0, 0, InputClassification.PerVertexData, 0),
                    new InputElement("COLOR", 0, Format.R8G8B8A8_UNorm, 12, 0, InputClassification.PerVertexData, 0)
                };
                inputLayout = new InputLayout(device, bc, elements);
            }

            vertexBufferDesc = new BufferDescription()
            {
                Usage = ResourceUsage.Dynamic,
                BindFlags = BindFlags.VertexBuffer,
                CpuAccessFlags = CpuAccessFlags.Write
            };

            vertexBufferBinding = new VertexBufferBinding(null, PositionColored.Stride, 0);

            using (var bc = HLSLCompiler.CompileFromFile(@"Shaders\PhysicsDebug.hlsl", "PSMain", "ps_5_0"))
                pixelShader = new PixelShader(device, bc);
        }
开发者ID:QamarWaqar,项目名称:Direct3D-Rendering-Cookbook,代码行数:30,代码来源:PhysicsDebugDraw.cs


示例2: Initialize

        public void Initialize(Device Device)
        {
            _shaderSolution=ROD_core.ShaderBinding.GetCompatibleShader(this);
            layout = new InputLayout(Device, _shaderSolution.shaders_bytecode[Shaders.VertexShader], mesh._vertexStream.vertexDefinition.GetInputElements());

            mesh.Load(Device);
            material.LoadTextures(Device);
            sampler = new SamplerState(Device, new SamplerStateDescription()
            {
                Filter = Filter.MinMagMipLinear,
                AddressU = TextureAddressMode.Wrap,
                AddressV = TextureAddressMode.Wrap,
                AddressW = TextureAddressMode.Wrap,
                BorderColor = new SharpDX.Color4(0,0,0,1),
                ComparisonFunction = Comparison.Never,
                MaximumAnisotropy = 16,
                MipLodBias = 0,
                MinimumLod = -float.MaxValue,
                MaximumLod = float.MaxValue
            });

            List<Shaders> actual_shaders = (from sh in _shaderSolution.shaders_bytecode select sh.Key).ToList<Shaders>();
            foreach (Shaders sh in actual_shaders)
            {
                ShaderReflection _shaderReflection = new ShaderReflection(_shaderSolution.shaders_bytecode[sh]);
                int buffers_count = _shaderReflection.Description.ConstantBuffers;
                SharpDX.Direct3D11.Buffer[] _buffers = new SharpDX.Direct3D11.Buffer[buffers_count];
                for (int i = 0; i < buffers_count; i++)
                {
                    ConstantBuffer cb_buffer = _shaderReflection.GetConstantBuffer(i);
                    _buffers[i] = new SharpDX.Direct3D11.Buffer(Device, cb_buffer.Description.Size, ResourceUsage.Default, BindFlags.ConstantBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, 0);
                }
                _shaderSolution.shaders_buffers[sh] = _buffers;
            }
        }
开发者ID:sinushawa,项目名称:ROD,代码行数:35,代码来源:Model.cs


示例3: InitializeAll

 public static void InitializeAll(Device device) {
     EffectPassDescription? passDesc;
     var e1 = EffectManager11.Instance.GetEffect<BasicEffect11>();
     passDesc = e1?.Light1Tech?.GetPassByIndex(0)?.Description;
     try {
         if (passDesc?.Signature != null) {
             _posNorm = new InputLayout(device, passDesc.Value.Signature, InputLayoutDescriptions.PosNorm);
         }
     } catch (SharpDXException ex) {
         Debug.Print(ex.Message);
     }
     try {
         if (passDesc?.Signature != null) {
             _posNormTex = new InputLayout(device, passDesc.Value.Signature, InputLayoutDescriptions.PosNormTex);
         }
     } catch (SharpDXException ex) {
         Debug.Print(ex.Message);
     }
     var e2 = EffectManager11.Instance.GetEffect<SkyboxEffect11>();
     passDesc = e2?.SkyTech?.GetPassByIndex(0)?.Description;
     if (passDesc?.Signature != null) {
         _pos = new InputLayout(device, passDesc.Value.Signature, InputLayoutDescriptions.Pos);
     }
     var e3 = EffectManager11.Instance.GetEffect<NormalMapEffect11>();
     passDesc = e3?.Light1Tech?.GetPassByIndex(0)?.Description;
     if (passDesc?.Signature != null) {
         _posNormTexTan = new InputLayout(device, passDesc.Value.Signature, InputLayoutDescriptions.PosNormTexTan);
     }
     var e4 = EffectManager11.Instance.GetEffect<FireParticleEffect11>();
     passDesc = e4?.StreamOutTech?.GetPassByIndex(0)?.Description;
     if (passDesc?.Signature != null) {
         _particle = new InputLayout(device, passDesc.Value.Signature, InputLayoutDescriptions.Particle);
     }
 }
开发者ID:Hozuki,项目名称:Noire,代码行数:34,代码来源:InputLayouts.cs


示例4: MeshFactory

        public MeshFactory(SharpDX11Graphics graphics)
        {
            this.device = graphics.Device;
            this.inputAssembler = device.ImmediateContext.InputAssembler;
            this.demo = graphics.Demo;

            instanceDataDesc = new BufferDescription()
            {
                Usage = ResourceUsage.Dynamic,
                BindFlags = BindFlags.VertexBuffer,
                CpuAccessFlags = CpuAccessFlags.Write,
                OptionFlags = ResourceOptionFlags.None,
            };

            InputElement[] elements = new InputElement[]
            {
                new InputElement("POSITION", 0, Format.R32G32B32_Float, 0, 0, InputClassification.PerVertexData, 0),
                new InputElement("NORMAL", 0, Format.R32G32B32_Float, 12, 0, InputClassification.PerVertexData, 0),
                new InputElement("WORLD", 0, Format.R32G32B32A32_Float, 0, 1, InputClassification.PerInstanceData, 1),
                new InputElement("WORLD", 1, Format.R32G32B32A32_Float, 16, 1, InputClassification.PerInstanceData, 1),
                new InputElement("WORLD", 2, Format.R32G32B32A32_Float, 32, 1, InputClassification.PerInstanceData, 1),
                new InputElement("WORLD", 3, Format.R32G32B32A32_Float, 48, 1, InputClassification.PerInstanceData, 1),
                new InputElement("COLOR", 0, Format.R8G8B8A8_UNorm, 64, 1, InputClassification.PerInstanceData, 1)
            };
            inputLayout = new InputLayout(device, graphics.GetEffectPass().Description.Signature, elements);

            groundColor = ColorToUint(Color.Green);
            activeColor = ColorToUint(Color.Orange);
            passiveColor = ColorToUint(Color.OrangeRed);
            softBodyColor = ColorToUint(Color.LightBlue);
        }
开发者ID:RainsSoft,项目名称:BulletSharpPInvoke,代码行数:31,代码来源:MeshFactory.cs


示例5: InitEffects

        protected override void InitEffects()
        {
            var custom = renderTechniquesManager.RenderTechniques["RenderCustom"];
            var lines = renderTechniquesManager.RenderTechniques[DefaultRenderTechniqueNames.Lines];
            var points = renderTechniquesManager.RenderTechniques[DefaultRenderTechniqueNames.Points];
            var text = renderTechniquesManager.RenderTechniques[DefaultRenderTechniqueNames.BillboardText];
            var blinn = renderTechniquesManager.RenderTechniques[DefaultRenderTechniqueNames.Blinn];

            RegisterEffect(Properties.Resources._custom, new[] { custom, lines, points, text, blinn});

            var customInputLayout = new InputLayout(device, GetEffect(custom).GetTechniqueByName("RenderCustom").GetPassByIndex(0).Description.Signature, new[]
            {
                new InputElement("POSITION", 0, Format.R32G32B32A32_Float, InputElement.AppendAligned, 0),
                new InputElement("COLOR",    0, Format.R32G32B32A32_Float, InputElement.AppendAligned, 0),
                new InputElement("TEXCOORD", 0, Format.R32G32_Float,       InputElement.AppendAligned, 0),
                new InputElement("NORMAL",   0, Format.R32G32B32_Float,    InputElement.AppendAligned, 0),
                new InputElement("TANGENT",  0, Format.R32G32B32_Float,    InputElement.AppendAligned, 0),
                new InputElement("BINORMAL", 0, Format.R32G32B32_Float,    InputElement.AppendAligned, 0),
                new InputElement("COLOR",    1, Format.R32G32B32A32_Float, InputElement.AppendAligned, 0),

                //INSTANCING: die 4 texcoords sind die matrix, die mit jedem buffer reinwandern
                new InputElement("TEXCOORD", 1, Format.R32G32B32A32_Float, InputElement.AppendAligned, 1, InputClassification.PerInstanceData, 1),
                new InputElement("TEXCOORD", 2, Format.R32G32B32A32_Float, InputElement.AppendAligned, 1, InputClassification.PerInstanceData, 1),
                new InputElement("TEXCOORD", 3, Format.R32G32B32A32_Float, InputElement.AppendAligned, 1, InputClassification.PerInstanceData, 1),
                new InputElement("TEXCOORD", 4, Format.R32G32B32A32_Float, InputElement.AppendAligned, 1, InputClassification.PerInstanceData, 1),
            });

            RegisterLayout(new[] { custom, lines, points, text, blinn}, customInputLayout);

            var linesInputLayout = new InputLayout(device, GetEffect(lines).GetTechniqueByName(DefaultRenderTechniqueNames.Lines).GetPassByIndex(0).Description.Signature, new[]
            {
                new InputElement("POSITION", 0, Format.R32G32B32A32_Float, InputElement.AppendAligned, 0),
                new InputElement("COLOR",    0, Format.R32G32B32A32_Float, InputElement.AppendAligned, 0),
                new InputElement("COLOR",    1, Format.R32G32B32A32_Float,    InputElement.AppendAligned, 0),

                //INSTANCING: die 4 texcoords sind die matrix, die mit jedem buffer reinwandern
                new InputElement("TEXCOORD", 1, Format.R32G32B32A32_Float, InputElement.AppendAligned, 1, InputClassification.PerInstanceData, 1),
                new InputElement("TEXCOORD", 2, Format.R32G32B32A32_Float, InputElement.AppendAligned, 1, InputClassification.PerInstanceData, 1),
                new InputElement("TEXCOORD", 3, Format.R32G32B32A32_Float, InputElement.AppendAligned, 1, InputClassification.PerInstanceData, 1),
                new InputElement("TEXCOORD", 4, Format.R32G32B32A32_Float, InputElement.AppendAligned, 1, InputClassification.PerInstanceData, 1),
            });
            RegisterLayout(new[]{lines},linesInputLayout);

            var pointsInputLayout = new InputLayout(device, GetEffect(points).GetTechniqueByName(DefaultRenderTechniqueNames.Points).GetPassByIndex(0).Description.Signature, new[]
            {
                new InputElement("POSITION", 0, Format.R32G32B32A32_Float, InputElement.AppendAligned, 0),
                new InputElement("COLOR",    0, Format.R32G32B32A32_Float, InputElement.AppendAligned, 0),
                new InputElement("COLOR",    1, Format.R32G32B32A32_Float,    InputElement.AppendAligned, 0),
            });
            RegisterLayout(new[] { points }, pointsInputLayout);

            var textInputLayout = new InputLayout(device, GetEffect(text).GetTechniqueByName(DefaultRenderTechniqueNames.BillboardText).GetPassByIndex(0).Description.Signature, new[]
            {
                new InputElement("POSITION", 0, Format.R32G32B32A32_Float,  InputElement.AppendAligned, 0),
                new InputElement("COLOR",    0, Format.R32G32B32A32_Float,  InputElement.AppendAligned, 0),
                new InputElement("TEXCOORD", 0, Format.R32G32B32A32_Float,  InputElement.AppendAligned, 0),
            });
            RegisterLayout(new[] { text }, textInputLayout);
        }
开发者ID:ORRNY66,项目名称:helix-toolkit,代码行数:59,代码来源:CustomEffectsManager.cs


示例6: RenderTechnique

 public RenderTechnique(string name, Effect effect, InputLayout layout)
 {
     this.Name = name;
     this.Device = effect.Device;
     this.Effect = effect;
     this.EffectTechnique = effect.GetTechniqueByName(this.Name);
     this.InputLayout = layout;
 }
开发者ID:ORRNY66,项目名称:helix-toolkit,代码行数:8,代码来源:RenderTechnique.cs


示例7: ProjectiveTexturingShader

        public ProjectiveTexturingShader(Device device)
        {
            var shaderByteCode = new ShaderBytecode(File.ReadAllBytes("Content/DepthAndProjectiveTextureVS.cso"));
            vertexShader = new VertexShader(device, shaderByteCode);
            geometryShader = new GeometryShader(device, new ShaderBytecode(File.ReadAllBytes("Content/DepthAndColorGS.cso")));
            pixelShader = new PixelShader(device, new ShaderBytecode(File.ReadAllBytes("Content/DepthAndColorPS.cso")));

            // depth stencil state
            var depthStencilStateDesc = new DepthStencilStateDescription()
            {
                IsDepthEnabled = true,
                DepthWriteMask = DepthWriteMask.All,
                DepthComparison = Comparison.LessEqual,
                IsStencilEnabled = false,
            };
            depthStencilState = new DepthStencilState(device, depthStencilStateDesc);

            // rasterizer states
            var rasterizerStateDesc = new RasterizerStateDescription()
            {
                CullMode = CullMode.None,
                FillMode = FillMode.Solid,
                IsDepthClipEnabled = true,
                IsFrontCounterClockwise = true,
                IsMultisampleEnabled = true,
            };
            rasterizerState = new RasterizerState(device, rasterizerStateDesc);

            // constant buffer
            var constantBufferDesc = new BufferDescription()
            {
                Usage = ResourceUsage.Dynamic,
                BindFlags = BindFlags.ConstantBuffer,
                SizeInBytes = Constants.size,
                CpuAccessFlags = CpuAccessFlags.Write,
                StructureByteStride = 0,
                OptionFlags = 0,
            };
            constantBuffer = new SharpDX.Direct3D11.Buffer(device, constantBufferDesc);

            // user view sampler state
            var colorSamplerStateDesc = new SamplerStateDescription()
            {
                Filter = Filter.MinMagMipLinear,
                AddressU = TextureAddressMode.Border,
                AddressV = TextureAddressMode.Border,
                AddressW = TextureAddressMode.Border,
                //BorderColor = new SharpDX.Color4(0.5f, 0.5f, 0.5f, 1.0f),
                BorderColor = new SharpDX.Color4(0, 0, 0, 1.0f),
            };
            colorSamplerState = new SamplerState(device, colorSamplerStateDesc);

            vertexInputLayout = new InputLayout(device, shaderByteCode.Data, new[]
            {
                new InputElement("SV_POSITION", 0, Format.R32G32B32A32_Float, 0, 0),
            });

        }
开发者ID:Dallemanden,项目名称:RoomAliveToolkit,代码行数:58,代码来源:ProjectiveTexturingShader.cs


示例8: SetInputLayout

        internal void SetInputLayout(InputLayout il)
        {
            if (il == m_inputLayout)
                return;

            m_inputLayout = il;
            m_deviceContext.InputAssembler.InputLayout = il;
            m_statistics.SetInputLayout++;
        }
开发者ID:rem02,项目名称:SpaceEngineers,代码行数:9,代码来源:MyRenderContextState.cs


示例9: VanillaInputLayout

 public VanillaInputLayout(ShaderAsset shader)
 {
     InputLayout  = new InputLayout(shader.Device, shader.Signature, new[]
     {
         new InputElement("POSITION", 0, Format.R32G32B32A32_Float, 0, 0),
         new InputElement("NORMAL", 0, Format.R32G32B32A32_Float, 16, 0),
         new InputElement("COLOR", 0, Format.R32G32B32A32_Float, 32, 0),
         new InputElement("TEXCOORD", 0, Format.R32G32B32A32_Float, 48, 0),
     });
 }
开发者ID:JoltSoftwareDevelopment,项目名称:Jolt.MashRoom,代码行数:10,代码来源:VanillaInputLayout.cs


示例10: Style

        public Style(String vertexShaderFilename, String pixelShaderFilename, InputElement[] layoutElements, int floatsPerVertex, DeviceManager deviceManager)
        {
            var path = Windows.ApplicationModel.Package.Current.InstalledLocation.Path;

            // Read pre-compiled shader byte code relative to current directory
            var vertexShaderByteCode = NativeFile.ReadAllBytes(path + "\\" + vertexShaderFilename);
            this.pixelShader = new PixelShader(deviceManager.DeviceDirect3D, NativeFile.ReadAllBytes(path + "\\" + pixelShaderFilename));
            this.vertexShader = new VertexShader(deviceManager.DeviceDirect3D, vertexShaderByteCode);

            // Specify the input layout for the new style
            this.layout = new InputLayout(deviceManager.DeviceDirect3D, vertexShaderByteCode, layoutElements);
            this.floatsPerVertex = floatsPerVertex;
        }
开发者ID:philyum,项目名称:TheAmazingFishy,代码行数:13,代码来源:Style.cs


示例11: RecordCommands

        internal unsafe void RecordCommands(MyRenderableProxy proxy, MyFoliageStream stream, int voxelMatId,
            VertexShader vertexShader, InputLayout inputLayout,
            int materialIndex, int indexCount, int startIndex, int baseVertex)
        {
            if (stream.m_stream == VertexBufferId.NULL) return;

            //var worldMatrix = proxy.WorldMatrix;
            //worldMatrix.Translation = Vector3D.Zero;
            //MyObjectData objectData = proxy.ObjectData;
            //objectData.LocalMatrix = Matrix.Identity;

            var worldMat = proxy.WorldMatrix;
            //worldMat.Translation -= MyRender11.Environment.CameraPosition;

            MyObjectDataCommon objectData = proxy.CommonObjectData;
            objectData.LocalMatrix = worldMat;

            MyMapping mapping = MyMapping.MapDiscard(RC, proxy.ObjectBuffer);
            mapping.WriteAndPosition(ref proxy.VoxelCommonObjectData);
            mapping.WriteAndPosition(ref objectData);
            mapping.Unmap();

            RC.AllShaderStages.SetConstantBuffer(MyCommon.OBJECT_SLOT, proxy.ObjectBuffer);

            BindProxyGeometry(proxy, RC);

            RC.VertexShader.Set(vertexShader);
            RC.SetInputLayout(inputLayout);

            int offset = -1;
            if (!stream.Append)
            {
                offset = 0;
                stream.Append = true;
            }

            RC.SetTarget(stream.m_stream.Buffer, offset);
            RC.AllShaderStages.SetConstantBuffer(MyCommon.FOLIAGE_SLOT, MyCommon.FoliageConstants);

            float densityFactor = MyVoxelMaterials1.Table[voxelMatId].FoliageDensity * MyRender11.Settings.GrassDensityFactor;

            float zero = 0;
            mapping = MyMapping.MapDiscard(RC, MyCommon.FoliageConstants);
            mapping.WriteAndPosition(ref densityFactor);
            mapping.WriteAndPosition(ref materialIndex);
            mapping.WriteAndPosition(ref voxelMatId);
            mapping.WriteAndPosition(ref zero);
            mapping.Unmap();

            RC.DrawIndexed(indexCount, startIndex, baseVertex);
        }
开发者ID:rem02,项目名称:SpaceEngineers,代码行数:51,代码来源:MyFoliageGeneratingPass.cs


示例12: Init

        public override Effect Init(EffectDescription description)
        {
            base.Init(description);

            var mode = _demo.SetupModel.Mode;

            _greetingsRenderTarget = _disposer.Add(new RenderTarget(
                device: _demo.Device,
                width: mode.Width,                    // TODO(mstrandh): Honor setupmodel?
                height: mode.Height,                   // TODO(mstrandh): Honor setupmodel?
                sampleCount: 1,                 // TODO(mstrandh): Honor setupmodel?
                sampleQuality: 0,               // TODO(mstrandh): Honor setupmodel?
                format: Format.R8G8B8A8_UNorm   // TODO(mstrandh): Honor setupmodel?
            ));

            CreateCylinderBuffers();
            var texture = _textures[0];
            _textureHeight = texture.Texture.Description.Height;

            _tubeVertexShader = _demo.ShaderManager["greetingsTube.vs.cso"];
            _tubePixelShader = _demo.ShaderManager["greetingsTube.ps.cso"];

            _tubeInputLayout = _disposer.Add(new InputLayout(_demo.Device, _tubeVertexShader.Signature, new[]
            {
                new InputElement("POSITION", 0, Format.R32G32B32_Float, 0, 0),
                new InputElement("TEXCOORD", 0, Format.R32G32_Float, 12, 0),
            }));

            _greetingsTexture = _resourceViews[0];
            _renderedCylinderTexture = _greetingsRenderTarget.ShaderResourceView;

            // Create the depth buffer
            var depthBuffer = _disposer.Add(new Texture2D(_demo.Device, new Texture2DDescription
            {
                Format = Format.D32_Float_S8X24_UInt,
                ArraySize = 1,
                MipLevels = 1,
                Width = mode.Width,
                Height = mode.Height,
                SampleDescription = new SampleDescription { Count = 1, Quality = 0 },
                Usage = ResourceUsage.Default,
                BindFlags = BindFlags.DepthStencil,
                CpuAccessFlags = CpuAccessFlags.None,
                OptionFlags = ResourceOptionFlags.None
            }));

            // Create the depth buffer view
            _greetingsDepthView = _disposer.Add(new DepthStencilView(_demo.Device, depthBuffer));

            return this;
        }
开发者ID:JoltSoftwareDevelopment,项目名称:Jolt.MashRoom,代码行数:51,代码来源:GreetingsEffect.cs


示例13: InitializeEffect

        private void InitializeEffect()
        {
            var vsBytecode = ShaderBytecode.CompileFromFile(string.Format(@"Content\{0}", FileName), "VS_Main", "vs_5_0");
            var psBytecode = ShaderBytecode.CompileFromFile(string.Format(@"Content\{0}", FileName), "PS_Main", "ps_5_0");

            _pixelShader = new PixelShader(_myGame.GraphicsDevice, psBytecode);
            _vertexShader = new VertexShader(_myGame.GraphicsDevice, vsBytecode);

            _layout = new InputLayout(_myGame.GraphicsDevice, ShaderSignature.GetInputSignature(vsBytecode), new[]
                    {
                        new InputElement("POSITION", 0, Format.R32G32_Float, 0, 0),
                        new InputElement("COLOR", 0, Format.R32G32B32A32_Float, 8, 0)
                    });
        }
开发者ID:Dani88,项目名称:SphereBed,代码行数:14,代码来源:Drawer.cs


示例14: CreateResources

        void CreateResources()
        {
            // If we have a shader signature, we can store the input layout directly
            if (EffectInputSignature != null)
            {
                InputLayout = GraphicsDevice.InputLayoutManager.GetInputLayout(EffectInputSignature, Layout);
            }

            nativeVertexBufferBindings = vertexBufferBindings.Select(x => new SharpDX.Direct3D11.VertexBufferBinding(x.Buffer.NativeBuffer, x.Stride, x.Offset)).ToArray();

            if (indexBufferBinding != null)
            {
                nativeIndexBuffer = indexBufferBinding.Buffer.NativeBuffer;
            }
        }
开发者ID:Powerino73,项目名称:paradox,代码行数:15,代码来源:VertexArrayObject.Direct3D.cs


示例15: ColorShader

        public ColorShader(Device device)
        {
            var vertexShaderByteCode = ShaderBytecode.CompileFromFile(VertexShaderFileName, "ColorVertexShader", "vs_4_0", ShaderFlags.None, EffectFlags.None);
            var pixelShaderByteCode = ShaderBytecode.CompileFromFile(PixelShaderFileName, "ColorPixelShader", "ps_4_0", ShaderFlags.None, EffectFlags.None);

            VertexShader = new VertexShader(device, vertexShaderByteCode);
            PixelShader = new PixelShader(device, pixelShaderByteCode);

            var inputElements = new InputElement[]
            {
                new InputElement
                {
                    SemanticName = "POSITION",
                    SemanticIndex = 0,
                    Format = Format.R32G32B32_Float,
                    Slot = 0,
                    AlignedByteOffset = 0,
                    Classification = InputClassification.PerVertexData,
                    InstanceDataStepRate = 0
                },
                new InputElement
                {
                    SemanticName = "COLOR",
                    SemanticIndex = 0,
                    Format = Format.R32G32B32A32_Float,
                    Slot = 0,
                    AlignedByteOffset = ColorShader.Vertex.AppendAlignedElement,
                    Classification = InputClassification.PerVertexData,
                    InstanceDataStepRate = 0
                }
            };
            Layout = new InputLayout(device, ShaderSignature.GetInputSignature(vertexShaderByteCode), inputElements);

            vertexShaderByteCode.Dispose();
            pixelShaderByteCode.Dispose();

            // Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
            var matrixBufferDesc = new BufferDescription
            {
                Usage = ResourceUsage.Dynamic, // Updated each frame
                SizeInBytes = Utilities.SizeOf<MatrixBuffer>(), // Contains three matrices
                BindFlags = BindFlags.ConstantBuffer,
                CpuAccessFlags = CpuAccessFlags.Write,
                OptionFlags = ResourceOptionFlags.None,
                StructureByteStride = 0
            };
            ConstantMatrixBuffer = new Buffer(device, matrixBufferDesc);
        }
开发者ID:ndech,项目名称:PlaneSimulator,代码行数:48,代码来源:ColorShader.cs


示例16: GetLayout

        public static InputLayout GetLayout(GxContext context, InputElement[] elements, Mesh mesh, ShaderProgram program)
        {
            Dictionary<ShaderProgram, InputLayout> meshEntry;
            InputLayout layout;

            if (Layouts.TryGetValue(mesh, out meshEntry))
            {
                if (meshEntry.TryGetValue(program, out layout))
                    return layout;

                layout = new InputLayout(context.Device, program.VertexShaderCode.Data, elements);
                meshEntry.Add(program, layout);
                return layout;
            }

            bool hasInstance = false, hasVertex = false;

            for(var i = 0; i < elements.Length; ++i)
            {
                if (hasInstance && hasVertex)
                    break;

                if(elements[i].Classification == InputClassification.PerInstanceData && hasInstance == false)
                {
                    elements[i].AlignedByteOffset = 0;
                    hasInstance = true;
                    continue;
                }

                if(elements[i].Classification == InputClassification.PerVertexData && hasVertex == false)
                {
                    elements[i].AlignedByteOffset = 0;
                    hasVertex = true;
                }
            }

            layout = new InputLayout(context.Device, program.VertexShaderCode.Data, elements);
            meshEntry = new Dictionary<ShaderProgram, InputLayout>()
            {
                {program, layout}
            };

            Layouts.Add(mesh, meshEntry);
            return layout;
        }
开发者ID:Linrasis,项目名称:WoWEditor,代码行数:45,代码来源:InputLayoutCache.cs


示例17: Shader

        public Shader(Device device, string shaderFile, string vertexTarget, string pixelTraget, InputElement[] layouts)
        {
            var shaderString = ShaderBytecode.PreprocessFromFile(shaderFile);

            using (var bytecode = ShaderBytecode.Compile(shaderString, vertexTarget, "vs_4_0"))
            {
                layout = new InputLayout(device, ShaderSignature.GetInputSignature(bytecode), layouts);
                vertShader = new VertexShader(device, bytecode);
            }

            using (var bytecode = ShaderBytecode.Compile(shaderString, pixelTraget, "ps_4_0"))
            {
                pixShader = new PixelShader(device, bytecode);
            }

            OnCleanup += vertShader.Dispose;
            OnCleanup += pixShader.Dispose;
            OnCleanup += layout.Dispose;
        }
开发者ID:Earthmark,项目名称:Struct-of-Structs,代码行数:19,代码来源:Shader.cs


示例18: Init

 public static void Init(SharpDX.Direct3D11.Device device)
 {
     vertexShaderByteCode = ShaderBytecode.CompileFromFile("Graphics/VertexShader.hlsl", "vertex", "vs_4_0", ShaderFlags.OptimizationLevel1, EffectFlags.None, null, null);
     vertexShader = new VertexShader(device, vertexShaderByteCode, null);
     vertices = SharpDX.Direct3D11.Buffer.Create<Vertex>(device, BindFlags.VertexBuffer, new Vertex[]
     {
         new Vertex(new Vector4(-1f, -1f, 0.5f, 1f), new Vector2(0f, 1f)),
         new Vertex(new Vector4(-1f, 1f, 0.5f, 1f), new Vector2(0f, 0f)),
         new Vertex(new Vector4(1f, -1f, 0.5f, 1f), new Vector2(1f, 1f)),
         new Vertex(new Vector4(-1f, 1f, 0.5f, 1f), new Vector2(0f, 0f)),
         new Vertex(new Vector4(1f, 1f, 0.5f, 1f), new Vector2(1f, 0f)),
         new Vertex(new Vector4(1f, -1f, 0.5f, 1f), new Vector2(1f, 1f))
     }, 144, ResourceUsage.Default, CpuAccessFlags.None, ResourceOptionFlags.None, 0);
     layout = new InputLayout(device, ShaderSignature.GetInputSignature(vertexShaderByteCode), Vertex.elements);
     binding = new VertexBufferBinding(vertices, 24, 0);
     buffer = new SharpDX.Direct3D11.Buffer(device, 64, ResourceUsage.Default, BindFlags.ConstantBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, 0);
     data.offset = 0f;
     data.scale = 1f;
 }
开发者ID:romanchom,项目名称:Luna,代码行数:19,代码来源:ScreenQuad.cs


示例19: Compile

        public void Compile()
        {
             // Compilo Vertex y Pixel Shaders
            CompilationResult vertexShaderBytecode = ShaderBytecode.CompileFromFile(_path, _vertexShaderEntryPoint, "vs_4_0",
                ShaderFlags.None, EffectFlags.None);
            CompilationResult pixelShaderBytecode = ShaderBytecode.CompileFromFile(_path, _pixelShaderEntryPoint, "ps_4_0",
                ShaderFlags.None, EffectFlags.None);

            _vertexShader = new VertexShader(GraphicManager.Device, vertexShaderBytecode);
            _pixelShader = new PixelShader(GraphicManager.Device, pixelShaderBytecode);

            Layout = new InputLayout(GraphicManager.Device, ShaderSignature.GetInputSignature(vertexShaderBytecode),
                VertexDescription.PosNormVertexInput);

            vertexShaderBytecode.Dispose();
            pixelShaderBytecode.Dispose();

            _compiled = true;
        }
开发者ID:bgarate,项目名称:SynergyEngine,代码行数:19,代码来源:Shader.cs


示例20: PhysicsDebugDraw

        public PhysicsDebugDraw(SharpDX11Graphics graphics)
        {
            _device = graphics.Device;
            _inputAssembler = _device.ImmediateContext.InputAssembler;

            InputElement[] elements = {
                new InputElement("POSITION", 0, Format.R32G32B32_Float, 0, 0, InputClassification.PerVertexData, 0),
                new InputElement("COLOR", 0, Format.R8G8B8A8_UNorm, 12, 0, InputClassification.PerVertexData, 0)
            };
            _inputLayout = new InputLayout(_device, graphics.GetDebugDrawPass().Description.Signature, elements);

            _vertexBufferDesc = new BufferDescription
            {
                Usage = ResourceUsage.Dynamic,
                BindFlags = BindFlags.VertexBuffer,
                CpuAccessFlags = CpuAccessFlags.Write
            };

            _vertexBufferBinding = new VertexBufferBinding(null, PositionColored.Stride, 0);
        }
开发者ID:sinkingsugar,项目名称:BulletSharpPInvoke,代码行数:20,代码来源:PhysicsDebugDraw.cs



注:本文中的SharpDX.Direct3D11.InputLayout类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Direct3D11.PixelShader类代码示例发布时间:2022-05-26
下一篇:
C# Direct3D11.InputElement类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap