title: Directx11: remove alpha blending for specific sprite
body: <p>Background:
   - I've been spending the last 6 weeks trying to learn Directx 11 programming. </p>
  
  <p>I'm currently rendering dds images on-screen following this book
  <a href="http://www.amazon.co.uk/Beginning-Directx-11-Game-Programming/dp/1435458958/ref=sr_1_1?ie=UTF8&amp;qid=1346510304&amp;sr=8-1" rel="nofollow">http://www.amazon.co.uk/Beginning-Directx-11-Game-Programming/dp/1435458958/ref=sr_1_1?ie=UTF8&amp;qid=1346510304&amp;sr=8-1</a></p>
  
  <p>I am trying to draw 2D sprites upon a 2D background which in itself also is a 2D sprite. Problem is that these two lines </p>
  
  <p>d3dDevice_->CreateBlendState( &amp;blendDesc, &amp;alphaBlendState_ );</p>
  
  <p>d3dContext_->OMSetBlendState( alphaBlendState_, blendFactor, 0xFFFFFFFF );</p>
  
  <p>to enable the alpha transparency in the dds images. I like to have the option to blend sprites but right now every sprites is blended with my blue background thus resulting in blu logos, icons etc.</p>
  
  <p><strong>How do I make the Alpha Blending ignore a specific image in directx 11?</strong> </p>
  
  <p>Since the background sprite is the first to be drawn I can't activate the Blending later in the code when rendering the other sprites without every sprite turning blue. </p>
  
  <p>thanks in advance :) </p>
  
  <p>EDIT:
  I've been working on this issue for the past 3 weeks and still no solution. Everytime the blend state is enabled in the DeviceContext is seems to apply to every texture drawn on the screen no matter the order of rendering. </p>
  
  <p>Here is the source code of the header file:</p>
  
  <pre><code>class GameSpriteDemo : public Dx11DemoBase
  {
      public:
          GameSpriteDemo( );
          virtual ~GameSpriteDemo( );
  
          bool LoadContent( );
          void UnloadContent( );
  
          void Update( float dt );
          void Render( );
  
          void DisableBlending();
          ID3D11ShaderResourceView* getColorMap(int);
          int UniqSpriteAmount();
  
          // text rendering system
      private:
          bool DrawString( char* message, float startX, float startY );
  
      private:
          ID3D11VertexShader* solidColorVS_;
          ID3D11VertexShader* solidColorVS_2;
  
          ID3DX11Effect* effect_;
  
          vector&lt;ID3D11VertexShader*&gt; solidColorVShaders; 
          ID3D11PixelShader* solidColorPS_;
          ID3D11PixelShader* solidColorPS_2;
  
          ID3D11InputLayout* inputLayout_;
          ID3D11InputLayout* inputLayout2;
          ID3D11Buffer* vertexBuffer_;
          vector&lt;ID3D11Buffer*&gt; vertexBuffers;
  
          ID3D11ShaderResourceView* colorMap_;
          vector&lt;ID3D11ShaderResourceView*&gt; colorMaps;
          ID3D11SamplerState* colorMapSampler_;
          vector&lt;ID3D11SamplerState*&gt; colorSamplers;
          ID3D11BlendState* alphaBlendState_;
          ID3D11BlendState* alphaBlendStateOff;
  
  
          vector&lt;LPCTSTR&gt; elements2D;
          vector&lt;GameSprite&gt; sprites_;
          ID3D11Buffer* mvpCB_;
          XMMATRIX vpMatrix_;
  
  };
  
  #endif
  </code></pre>
  
  <p>Here is the source code of the cpp file: (the Base Class DxD11DemoClass is not needed since it only sets up SwapChain and D3DContext)</p>
  
  <pre><code>bool GameSpriteDemo::LoadContent( )
  {
      // add sprite textures to the engine, giving them index 0, 1, 2... etc. 
      elements2D.push_back("placeholder3.dds");
      elements2D.push_back("cav.dds");
      elements2D.push_back("Stats.dds");
  
      // create sprites
          XMFLOAT2 sprite1Pos( 0.0f, 500.0f);
      GameSprite sprite1(getDevice(), "placeholder3.dds", 0, sprite1Pos, 0.0f);
              XMFLOAT2 sprite1Scale( 0.5f, 0.5f );
              XMFLOAT2 mini(0.8f, 0.6f);
      sprite1.SetScale(mini);
      sprites_.push_back(sprite1);
  
      XMFLOAT2 sprite2Pos( 200.0f, 100.0f );
      GameSprite sprite2(getDevice(), "Stats.dds", 2, sprite2Pos, 2.0f);
      // sprites_.push_back(sprite2);
  
      XMFLOAT2 sprite3Pos( 290.0f, 300.0f );
      GameSprite sprite3(getDevice(), "cav.dds", 1, sprite3Pos, 2.0f);
      sprite3.SetScale(sprite1Scale);
      sprites_.push_back(sprite3);
  
      // create vertex buffers, colorMaps and colorSamplers
      for (int i = 0; i &lt;= elements2D.size(); i++) {
      solidColorVShaders.push_back(solidColorVS_);
      colorMaps.push_back(colorMap_);
      colorSamplers.push_back(colorMapSampler_);
      vertexBuffers.push_back(vertexBuffer_);
      }
  
      // continue 
      ID3DBlob* vsBuffer = 0;
  
      bool compileResult = CompileD3DShader( "TextureMap.fx", "VS_Main", "vs_4_0", &amp;vsBuffer );
  
      if( compileResult == false )
      {
          DXTRACE_MSG( "Error compiling the vertex shader!" );
          return false;
      }
  
      HRESULT d3dResult;
  
      d3dResult = d3dDevice_-&gt;CreateVertexShader( vsBuffer-&gt;GetBufferPointer( ),
          vsBuffer-&gt;GetBufferSize( ), 0, &amp;solidColorVShaders[0] );
  
      if( FAILED( d3dResult ) )
      {
          DXTRACE_MSG( "Error creating the vertex shader!" );
  
          if( vsBuffer )
              vsBuffer-&gt;Release( );
  
          return false;
      }
  
  
  
      D3D11_INPUT_ELEMENT_DESC solidColorLayout[] =
      {
          { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
          { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 }
      };
  
      unsigned int totalLayoutElements = ARRAYSIZE( solidColorLayout );
  
      d3dResult = d3dDevice_-&gt;CreateInputLayout( solidColorLayout, totalLayoutElements,
          vsBuffer-&gt;GetBufferPointer( ), vsBuffer-&gt;GetBufferSize( ), &amp;inputLayout_ );
  
      vsBuffer-&gt;Release( );
  
      if( FAILED( d3dResult ) )
      {
          DXTRACE_MSG( "Error creating the input layout!" );
          return false;
      }
  
      ID3DBlob* psBuffer = 0;
  
      compileResult = CompileD3DShader( "TextureMap.fx", "PS_Main", "ps_4_0", &amp;psBuffer );
  
      if( compileResult == false )
      {
          DXTRACE_MSG( "Error compiling pixel shader!" );
          return false;
      }
  
      d3dResult = d3dDevice_-&gt;CreatePixelShader( psBuffer-&gt;GetBufferPointer( ),
          psBuffer-&gt;GetBufferSize( ), 0, &amp;solidColorPS_ );
  
      psBuffer-&gt;Release( );
  
      if( FAILED( d3dResult ) )
      {
          DXTRACE_MSG( "Error creating pixel shader!" );
          return false;
      }
  
      // create ColorMap, ColorSampler and VertexBuffer for each unique sprite
      D3D11_SAMPLER_DESC colorMapDesc;
      D3D11_BUFFER_DESC vertexDesc;
      D3D11_SUBRESOURCE_DATA resourceData;
  
      for (int j = 0; j &lt; elements2D.size(); j++) {
  
      d3dResult = D3DX11CreateShaderResourceViewFromFile( d3dDevice_,
          elements2D[j], 0, 0, &amp;colorMaps[j], 0 );
  
      if( FAILED( d3dResult ) )
      {
          DXTRACE_MSG( "Failed to load the texture image!" );
          return false;
      }
  
      ZeroMemory( &amp;colorMapDesc, sizeof( colorMapDesc ) );
      colorMapDesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
      colorMapDesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
      colorMapDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
      colorMapDesc.ComparisonFunc = D3D11_COMPARISON_NEVER;
      colorMapDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
      colorMapDesc.MaxLOD = D3D11_FLOAT32_MAX;
  
      d3dResult = d3dDevice_-&gt;CreateSamplerState( &amp;colorMapDesc, &amp;colorSamplers[j] );
  
      if( FAILED( d3dResult ) )
      {
          DXTRACE_MSG( "Failed to create color map sampler state!" );
          return false;
      }
  
      float Width = sprites_[j].getWidth();
      float Height = sprites_[j].getHeight();
  
  
      VertexPos vertices[] =
      {
          { XMFLOAT3(  Width,  Height, 1.0f ), XMFLOAT2( 1.0f, 0.0f ) },
          { XMFLOAT3(  Width, -Height, 1.0f ), XMFLOAT2( 1.0f, 1.0f ) },
          { XMFLOAT3( -Width, -Height, 1.0f ), XMFLOAT2( 0.0f, 1.0f ) },
  
          { XMFLOAT3( -Width, -Height, 1.0f ), XMFLOAT2( 0.0f, 1.0f ) },
          { XMFLOAT3( -Width,  Height, 1.0f ), XMFLOAT2( 0.0f, 0.0f ) },
          { XMFLOAT3(  Width,  Height, 1.0f ), XMFLOAT2( 1.0f, 0.0f ) },
      };
  
      ZeroMemory( &amp;vertexDesc, sizeof( vertexDesc ) );
      vertexDesc.Usage = D3D11_USAGE_DEFAULT;
      vertexDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
      vertexDesc.ByteWidth = sizeof( VertexPos ) * 6;
  
      ZeroMemory( &amp;resourceData, sizeof( resourceData ) );
      resourceData.pSysMem = vertices;
  
      d3dResult = d3dDevice_-&gt;CreateBuffer( &amp;vertexDesc, &amp;resourceData, &amp;vertexBuffers[j] );
  
      if( FAILED( d3dResult ) )
      {
          DXTRACE_MSG( "Failed to create vertex buffer!" );
          return false;
      }
  
      }
      // end of foor loop
  
      // create text fonts
          d3dResult = D3DX11CreateShaderResourceViewFromFile( d3dDevice_,
          "font.dds", 0, 0, &amp;colorMap_, 0 );
  
      if( FAILED( d3dResult ) )
      {
          DXTRACE_MSG( "Failed to load the texture image!" );
          return false;
      }
  
      D3D11_SAMPLER_DESC colorMapDesc2;
      ZeroMemory( &amp;colorMapDesc2, sizeof( colorMapDesc2 ) );
      colorMapDesc2.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
      colorMapDesc2.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
      colorMapDesc2.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
      colorMapDesc2.ComparisonFunc = D3D11_COMPARISON_NEVER;
      colorMapDesc2.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
      colorMapDesc2.MaxLOD = D3D11_FLOAT32_MAX;
  
      d3dResult = d3dDevice_-&gt;CreateSamplerState( &amp;colorMapDesc2, &amp;colorMapSampler_ );
  
      if( FAILED( d3dResult ) )
      {
          DXTRACE_MSG( "Failed to create color map sampler state!" );
          return false;
      }
  
      D3D11_BUFFER_DESC vertexDesc2;
      ZeroMemory( &amp;vertexDesc2, sizeof( vertexDesc2 ) );
      vertexDesc2.Usage = D3D11_USAGE_DYNAMIC;
      vertexDesc2.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
      vertexDesc2.BindFlags = D3D11_BIND_VERTEX_BUFFER;
  
      const int sizeOfSprite = sizeof( VertexPos ) * 6;
      const int maxLetters = 24;
  
      vertexDesc2.ByteWidth = sizeOfSprite * maxLetters;
  
      d3dResult = d3dDevice_-&gt;CreateBuffer( &amp;vertexDesc2, 0, &amp;vertexBuffer_ );
  
      if( FAILED( d3dResult ) )
      {
          DXTRACE_MSG( "Failed to create vertex buffer!" );
          return false;
      }
  
      // end of font creation
  
      D3D11_BUFFER_DESC constDesc;
      ZeroMemory( &amp;constDesc, sizeof( constDesc ) );
      constDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
      constDesc.ByteWidth = sizeof( XMMATRIX );
      constDesc.Usage = D3D11_USAGE_DEFAULT;
  
      d3dResult = d3dDevice_-&gt;CreateBuffer( &amp;constDesc, 0, &amp;mvpCB_ );
  
      if( FAILED( d3dResult ) )
      {
          return false;
      }
  
  
      XMMATRIX view = XMMatrixIdentity( );
      XMMATRIX projection = XMMatrixOrthographicOffCenterLH( 0.0f, 1366.0f, 0.0f, 768.0f, 0.1f, 100.0f );
      vpMatrix_ = XMMatrixMultiply( view, projection );
  
  
      D3D11_BLEND_DESC blendDesc;
      ZeroMemory( &amp;blendDesc, sizeof( blendDesc ) );
      blendDesc.RenderTarget[0].BlendEnable = TRUE;
      blendDesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD;
      blendDesc.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA;
      blendDesc.RenderTarget[0].DestBlend = D3D11_BLEND_ONE;
      blendDesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
      blendDesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ZERO;
      blendDesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO;
      blendDesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
  
  
      float blendFactor[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
  
      d3dDevice_-&gt;CreateBlendState( &amp;blendDesc, &amp;alphaBlendState_ );
  
      // create the disabled blend state
      blendDesc.RenderTarget[0].BlendEnable = FALSE;
      d3dDevice_-&gt;CreateBlendState( &amp;blendDesc, &amp;alphaBlendStateOff );
      d3dContext_-&gt;OMSetBlendState( alphaBlendState_, blendFactor, 0xFFFFFFFF );
  
      // holy shit here we go again
          ID3DBlob* vsBuffer2 = 0;
          compileResult = CompileD3DShader( "TextMap.fx", "VS_Main", "vs_4_0", &amp;vsBuffer2 );
  
      if( compileResult == false )
      {
          DXTRACE_MSG( "Error compiling the vertex shader!" );
          return false;
      }
  
      d3dResult = d3dDevice_-&gt;CreateVertexShader( vsBuffer2-&gt;GetBufferPointer( ),
          vsBuffer2-&gt;GetBufferSize( ), 0, &amp;solidColorVS_2 );
  
          ID3DBlob* psBuffer2 = 0;
  
      compileResult = CompileD3DShader( "TextureMap.fx", "PS_Main", "ps_4_0", &amp;psBuffer2 );
  
      if( compileResult == false )
      {
          DXTRACE_MSG( "Error compiling pixel shader!" );
          return false;
      }
  
      d3dResult = d3dDevice_-&gt;CreatePixelShader( psBuffer2-&gt;GetBufferPointer( ),
          psBuffer2-&gt;GetBufferSize( ), 0, &amp;solidColorPS_2 );
  
      psBuffer2-&gt;Release( );
  
      return true;
  }
  
  
  void GameSpriteDemo::UnloadContent( )
  {
      if( colorMapSampler_ ) colorMapSampler_-&gt;Release( );
      if( colorMap_ ) colorMap_-&gt;Release( );
      if( solidColorVShaders[0] ) solidColorVShaders[0]-&gt;Release( );
      if( solidColorPS_ ) solidColorPS_-&gt;Release( );
      if( inputLayout_ ) inputLayout_-&gt;Release( );
      if( vertexBuffer_ ) vertexBuffer_-&gt;Release( );
      if( mvpCB_ ) mvpCB_-&gt;Release( );
      if( alphaBlendState_ ) alphaBlendState_-&gt;Release( );
      if( alphaBlendStateOff ) alphaBlendStateOff-&gt;Release( );
  
      colorMapSampler_ = 0;
      colorMap_ = 0;
      solidColorVShaders[0] = 0;
      solidColorPS_ = 0;
      inputLayout_ = 0;
      vertexBuffer_ = 0;
      mvpCB_ = 0;
      alphaBlendState_ = 0;
      alphaBlendStateOff = 0;
  }
  
  
  void GameSpriteDemo::Update( float dt )
  {
      // Nothing to update
  }
  
  bool GameSpriteDemo::DrawString( char* message, float startX, float startY )
  {
      // Size in bytes for a single sprite.
      const int sizeOfSprite = sizeof( VertexPos ) * 6;
  
      // Demo's dynamic buffer setup for max of 24 letters.
      const int maxLetters = 24;
  
      int length = strlen( message );
  
      // Clamp for strings too long.
      if( length &gt; maxLetters )
          length = maxLetters;
  
      // Char's width on screen.
      float charWidth = 32.0f / (1366.0f*1.0f);
  
      // Char's height on screen.
      float charHeight = 32.0f / (768.0f*1.0f);
  
      // Char's texel width.
      float texelWidth = 32.0f / 896.0f;
  
      // verts per-triangle (3) * total triangles (2) = 6.
      const int verticesPerLetter = 6;
  
      D3D11_MAPPED_SUBRESOURCE mapResource;
      HRESULT d3dResult = d3dContext_-&gt;Map( vertexBuffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &amp;mapResource );
  
      if( FAILED( d3dResult ) )
      {
          DXTRACE_MSG( "Failed to map resource!" );
          return false;
      }
  
      // Point to our vertex buffer's internal data.
      VertexPos *spritePtr = ( VertexPos* )mapResource.pData;
  
      const int indexA = static_cast&lt;char&gt;( 'A' );
      const int indexZ = static_cast&lt;char&gt;( 'Z' );
      const int index_a = static_cast&lt;char&gt;( 'a' );
  
      for( int i = 0; i &lt; length; ++i )
      {
          float thisStartX = startX + ( charWidth * static_cast&lt;float&gt;( i ) );
          float thisEndX = thisStartX + charWidth;
          float thisEndY = startY + charHeight;
  
          spritePtr[0].pos = XMFLOAT3( thisEndX,   thisEndY, 1.0f );
          spritePtr[1].pos = XMFLOAT3( thisEndX,   startY,   1.0f );
          spritePtr[2].pos = XMFLOAT3( thisStartX, startY,   1.0f );
          spritePtr[3].pos = XMFLOAT3( thisStartX, startY,   1.0f );
          spritePtr[4].pos = XMFLOAT3( thisStartX, thisEndY, 1.0f );
          spritePtr[5].pos = XMFLOAT3( thisEndX,   thisEndY, 1.0f );
  
          int texLookup = 0;
          int letter = static_cast&lt;char&gt;( message[i] );
  
          if (letter == index_a) {
              texLookup = (indexZ - indexA) + 2;
          }
          else if( letter &lt; indexA || letter &gt; indexZ )
          {
              // Grab one index past Z, which is a blank space in the texture.
              texLookup = ( indexZ - indexA ) + 1;
          }
          else
          {
              // A = 0, B = 1, Z = 25, etc.
              texLookup = ( letter - indexA );
          }
  
          float tuStart = 0.0f + ( texelWidth * static_cast&lt;float&gt;( texLookup ) );
          float tuEnd = tuStart + texelWidth;
  
          spritePtr[0].tex0 = XMFLOAT2( tuEnd, 0.0f );
          spritePtr[1].tex0 = XMFLOAT2( tuEnd, 1.0f );
          spritePtr[2].tex0 = XMFLOAT2( tuStart, 1.0f );
          spritePtr[3].tex0 = XMFLOAT2( tuStart, 1.0f );
          spritePtr[4].tex0 = XMFLOAT2( tuStart, 0.0f );
          spritePtr[5].tex0 = XMFLOAT2( tuEnd, 0.0f );
  
          spritePtr += 6;
      }
  
      d3dContext_-&gt;Unmap( vertexBuffer_, 0 );
  
     d3dContext_-&gt;Draw( 6 * length, 0 );
  
      return true;
  }
  
  
  void GameSpriteDemo::Render( )
  {
      if( d3dContext_ == 0 )
          return;
  
      float clearColor[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
      d3dContext_-&gt;ClearRenderTargetView( backBufferTarget_, clearColor );
  
      unsigned int stride = sizeof( VertexPos );
      unsigned int offset = 0;
  
      d3dContext_-&gt;IASetInputLayout( inputLayout_ );
      d3dContext_-&gt;IASetPrimitiveTopology( D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST );
  
      d3dContext_-&gt;VSSetShader( solidColorVShaders[0], 0, 0 );
      d3dContext_-&gt;PSSetShader( solidColorPS_, 0, 0 );
  
      XMMATRIX world;
      XMMATRIX mvp;
      int index;
  
      for (int k = 0; k &lt; sprites_.size(); k++) {
  
      index = sprites_[k].getIndex();
      d3dContext_-&gt;IASetVertexBuffers( 0, 1, &amp;vertexBuffers[index], &amp;stride, &amp;offset );
      d3dContext_-&gt;PSSetShaderResources( 0, 1, &amp;colorMaps[index] );
      d3dContext_-&gt;PSSetSamplers( 0, 1, &amp;colorSamplers[index] );
  
          world = sprites_[k].GetWorldMatrix();
          mvp = XMMatrixMultiply( world, vpMatrix_ );
          mvp = XMMatrixTranspose( mvp );
  
          d3dContext_-&gt;UpdateSubresource( mvpCB_, 0, 0, &amp;mvp, 0, 0 );
          d3dContext_-&gt;VSSetConstantBuffers( 0, 1, &amp;mvpCB_ );
  
          d3dContext_-&gt;Draw( 6, 0 );
      }
  
  
  
      // render text
  
  
  
          DisableBlending();
  
      d3dContext_-&gt;IASetVertexBuffers( 0, 1, &amp;vertexBuffer_, &amp;stride, &amp;offset );
      d3dContext_-&gt;PSSetShaderResources( 0, 1, &amp;colorMap_ );
      d3dContext_-&gt;PSSetSamplers( 0, 1, &amp;colorMapSampler_ );
      d3dContext_-&gt;VSSetShader( solidColorVS_2, 0, 0 );
      d3dContext_-&gt;PSSetShader( solidColorPS_2, 0, 0 );
  
  
      DrawString( "PROTOTYPE TEXT", -0.2f, 0.0f );
  
      swapChain_-&gt;Present( 0, 0 );
  }
  
  ID3D11ShaderResourceView* GameSpriteDemo::getColorMap(int index) {
      return colorMaps[index];
  }
  
  // this functions disables the alpha blending
  void GameSpriteDemo::DisableBlending() {
          float blendFactor[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
          d3dContext_-&gt;OMSetBlendState( alphaBlendStateOff, blendFactor, 0xFFFFFFFF );
  }
  </code></pre>
  
  <p>Screen of the results when drawing with blending enabled
  <a href="http://i49.tinypic.com/33kao9v.jpg" rel="nofollow">http://i49.tinypic.com/33kao9v.jpg</a></p>
  
  <p>and here is the HLSL code for the two FX files I'm using (the first for the sprites, the second for the text)</p>
  
  <p><strong>TextureMap.fx</strong></p>
  
  <pre><code>cbuffer cbChangesPerFrame : register( b0 )
  {
      matrix mvp_;
  };
  
  
  Texture2D colorMap_ : register( t0 );
  SamplerState colorSampler_ : register( s0 );
  
  struct VS_Input
  {
      float4 pos  : POSITION;
      float2 tex0 : TEXCOORD0;
  };
  
  struct PS_Input
  {
      float4 pos  : SV_POSITION;
      float2 tex0 : TEXCOORD0;
  };
  
  
  PS_Input VS_Main( VS_Input vertex )
  {
      PS_Input vsOut = ( PS_Input )0;
      vsOut.pos = mul( vertex.pos, mvp_ );
      vsOut.tex0 = vertex.tex0;
  
      return vsOut;
  }
  
  
  float4 PS_Main( PS_Input frag ) : SV_TARGET
  {
      return colorMap_.Sample( colorSampler_, frag.tex0 );
  }
  </code></pre>
  
  <p><strong>TextMap.fx</strong></p>
  
  <pre><code>Texture2D colorMap_ : register( t0 );
  SamplerState colorSampler_ : register( s0 );
  
  
  struct VS_Input
  
      {
          float4 pos  : POSITION;
          float2 tex0 : TEXCOORD0;
      };
  
      struct PS_Input
      {
          float4 pos  : SV_POSITION;
          float2 tex0 : TEXCOORD0;
      };
  
  
      PS_Input VS_Main( VS_Input vertex )
      {
          PS_Input vsOut = ( PS_Input )0;
          vsOut.pos = vertex.pos;
          vsOut.tex0 = vertex.tex0;
  
          return vsOut;
      }
  
  
      float4 PS_Main( PS_Input frag ) : SV_TARGET
      {
          return colorMap_.Sample( colorSampler_, frag.tex0 );
      }
  </code></pre>
  
  <p>I have wondered maybe to use pixel shaders to perform alpha blending for specific 2D images but my first attempts has not worked at all.</p>
  
  <p>Hope someone can find a solution somehow :) </p>
  
  <p>and thanks again for the help. </p>