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; } }
public ROD_Main() : base("FrameDX", 1280, 800, true, false, true) { #region HLSL definition //Shader for diffuse texture, normal texture and bump with tesselation ROD_core.ByteCodeBind[] ShadersByteCodeDNT = new ROD_core.ByteCodeBind[]{ new ROD_core.ByteCodeBind(ROD_core.Shaders.VertexShader, ShaderBytecode.CompileFromFile(@"shaders\DiffuseNormalTesselation.vs", "VS", "vs_5_0",ShaderFlags.Debug)), new ROD_core.ByteCodeBind(ROD_core.Shaders.HullShader, ShaderBytecode.CompileFromFile(@"shaders\DiffuseNormalTesselation.hs", "HS", "hs_5_0",ShaderFlags.Debug)), new ROD_core.ByteCodeBind(ROD_core.Shaders.DomainShader, ShaderBytecode.CompileFromFile(@"shaders\DiffuseNormalTesselation.ds", "DS", "ds_5_0",ShaderFlags.Debug)), new ROD_core.ByteCodeBind(ROD_core.Shaders.PixelShader, ShaderBytecode.CompileFromFile(@"shaders\DiffuseNormalTesselation_ward.ps", "PS", "ps_5_0",ShaderFlags.Debug)) }; ROD_core.ShaderSolution ShSolutionDNT = new ROD_core.ShaderSolution("DNS_Tes", Device, ShadersByteCodeDNT); ROD_core.Technique DNT = ROD_core.Technique.Diffuse_mapping|ROD_core.Technique.Normal_mapping|ROD_core.Technique.Specular_mapping|ROD_core.Technique.Tesslation; ROD_core.ShaderBinding.ShaderPool.Add(DNT, ShSolutionDNT); //Shader for simple diffuse texture ROD_core.ByteCodeBind[] ShadersByteCodeD = new ROD_core.ByteCodeBind[]{ new ROD_core.ByteCodeBind(ROD_core.Shaders.VertexShader, ShaderBytecode.CompileFromFile(@"shaders\Diffuse.vs", "VS", "vs_5_0")), new ROD_core.ByteCodeBind(ROD_core.Shaders.PixelShader, ShaderBytecode.CompileFromFile(@"shaders\Diffuse.ps", "PS", "ps_5_0", ShaderFlags.SkipOptimization)) }; ROD_core.ShaderSolution ShSolutionD = new ROD_core.ShaderSolution("D", Device, ShadersByteCodeD); ROD_core.Technique D = ROD_core.Technique.Diffuse_mapping; ROD_core.ShaderBinding.ShaderPool.Add(D, ShSolutionD); //Shader for screen quad diffuse texture ROD_core.ByteCodeBind[] ShadersByteCodeSQ = new ROD_core.ByteCodeBind[]{ new ROD_core.ByteCodeBind(ROD_core.Shaders.VertexShader, ShaderBytecode.CompileFromFile(@"shaders\Diffuse2D.vs", "VS", "vs_5_0")), new ROD_core.ByteCodeBind(ROD_core.Shaders.PixelShader, ShaderBytecode.CompileFromFile(@"shaders\Diffuse2D.ps", "PS", "ps_5_0")) }; ROD_core.ShaderSolution ShSolutionSQ = new ROD_core.ShaderSolution("SQ", Device, ShadersByteCodeSQ); ROD_core.Technique SQ = ROD_core.Technique.Quad_rendering; ROD_core.ShaderBinding.ShaderPool.Add(SQ, ShSolutionSQ); InitializeScene(); scene.Prep(Device); SetEnvironnement(); #endregion }
public new 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); 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 }); }