Esempio n. 1
0
 internal override void SetTextureResource(PixelShaderStage pixelShader)
 {
     if (Active != -1)
     {
         pixelShader.SetShaderResource(0, resourceView[Active]);
     }
 }
Esempio n. 2
0
        public void Update(SharpDevice device, Matrix View, Matrix Projection)
        {
            TransUpdate( );

            SendGPUData(device, View, Projection);

            MMDModelMorph.UpdateMorph(OrigVertice, Vertice);

            UpdateMesh( );

            Mesh.Begin( );
            for (int i = 0; i < Mesh.SubSets.Count; i++)
            {
                SharpSubSet      sharpSubSet  = Mesh.SubSets[i];
                PixelShaderStage pixelShader  = device.DeviceContext.PixelShader;
                MaterialGPUData  materialData = Materials[i].MaterialData;
                device.DeviceContext.PixelShader.SetShaderResource(0, sharpSubSet.DiffuseMap);
                device.DeviceContext.PixelShader.SetShaderResource(1, sharpSubSet.SphereMap);
                pixelShader.SetConstantBuffer(1, MaterialDataBuffer);
                device.UpdateData(MaterialDataBuffer, materialData);
                //set texture
                Mesh.Draw(i);
            }
            // https://gamedev.stackexchange.com/questions/49779/different-shaders-for-different-objects-directx-11
        }
Esempio n. 3
0
 internal override void SetTextureResource(PixelShaderStage pixelShader)
 {
     if (textureReady)
     {
         pixelShader.SetShaderResource(0, resourceView);
     }
 }
 internal void SetTextureResource(PixelShaderStage pixelShader, string id)
 {
     if (textures.ContainsKey(id))
     {
         if (textures.TryGetValue(id, out Tuple <ShaderResourceView, Texture2D> texture))
         {
             pixelShader.SetShaderResource(0, texture.Item1);
         }
     }
 }
Esempio n. 5
0
 internal DeviceContext(Device device)
     : base(device)
 {
     _device         = device;
     _inputAssembler = new InputAssemblerStage(device);
     _vertexShader   = new VertexShaderStage(device);
     _geometryShader = new GeometryShaderStage(device);
     _rasterizer     = new RasterizerStage(device);
     _pixelShader    = new PixelShaderStage(device);
     _outputMerger   = new OutputMergerStage(device);
 }
Esempio n. 6
0
 internal override void SetTextureResource(PixelShaderStage pixelShader)
 {
     if (textureReady)
     {
         if (Colored)
         {
             pixelShader.SetShaderResource(0, resourceView2);
         }
         else
         {
             pixelShader.SetShaderResource(0, resourceView1);
         }
     }
 }
Esempio n. 7
0
        protected void PrepareShader(SharpDevice device, string shaderPath)
        {
            //init shader
            Shader = new SharpShader(device, shaderPath,
                                     new SharpShaderDescription( )
            {
                VertexShaderFunction = "VS", PixelShaderFunction = "PS"
            },
                                     new InputElement[] {
                new InputElement("POSITION", 0, Format.R32G32B32_Float, 0, 0),
                new InputElement("NORMAL", 0, Format.R32G32B32_Float, 12, 0),
                new InputElement("TEXCOORD", 0, Format.R32G32_Float, 24, 0)
            });
            VertexShader = device.DeviceContext.VertexShader;
            PixelShader  = device.DeviceContext.PixelShader;

            GPUDataBuffer = Shader.CreateBuffer <GPUData>( );
        }
 internal override void SetTextureResource(PixelShaderStage pixelShader)
 {
     loader.SetTextureResource(pixelShader, TextureID);
 }
Esempio n. 9
0
 internal abstract void SetTextureResource(PixelShaderStage pixelShader);