Jump to content

  • Log In with Google      Sign In   
  • Create Account

#Actualkorvax

Posted 13 November 2012 - 03:06 PM

Might be a stupid question but if I what to create a black texture how do I do that.
Im doing the following to create black texture, but my FPS is dropping quiet a lot when this texture is in use.. My feeling is that I have created a "NULL" texture
and its black because Im missing "color" to it. I was trying to force a yellow color in the pixel shader but its still black.. is there something that I missing pls? Im quiet new to directx..
[source lang="cpp"] ID3D11ShaderResourceView* pTextureRV = NULL; ID3D11Texture2D* pTex2D = NULL; D3D11_TEXTURE2D_DESC textureDesc; ZeroMemory(&textureDesc, sizeof(textureDesc)); // Setup the render target texture description. textureDesc.Width = 1; textureDesc.Height = 1; textureDesc.MipLevels = 1; textureDesc.ArraySize = 1; textureDesc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT; textureDesc.SampleDesc.Count = 1; textureDesc.Usage = D3D11_USAGE_DEFAULT; textureDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE; textureDesc.MiscFlags = 0; D3D11_SHADER_RESOURCE_VIEW_DESC svrDesc; svrDesc.Format = textureDesc.Format; svrDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; svrDesc.Texture2D.MostDetailedMip = 0; svrDesc.Texture2D.MipLevels = 1; hr = m_pDevice->CreateShaderResourceView(pTex2D, &svrDesc, &pTextureRV);[/source]

my simple shader:


[source lang="cpp"]Texture2D txDiffuse : register( t0 );SamplerState samLinear : register( s0 );cbuffer CONSTANT_BUFFER : register( b0 ){ matrix World; matrix View; matrix Projection;}struct VS_INPUT{ float4 Pos : POSITION; float2 Tex : TEXCOORD0;};struct PS_INPUT{ float4 Pos : SV_POSITION; float2 Tex : TEXCOORD0;};//--------------------------------------------------------------------------------------// Vertex Shader//--------------------------------------------------------------------------------------PS_INPUT VS( VS_INPUT input ){ PS_INPUT output = (PS_INPUT)0; output.Pos = mul( input.Pos, World ); output.Pos = mul( output.Pos, View ); output.Pos = mul( output.Pos, Projection ); output.Tex = input.Tex; return output;}//--------------------------------------------------------------------------------------// Pixel Shader//--------------------------------------------------------------------------------------float4 PS( PS_INPUT input) : SV_Target{ return txDiffuse.Sample( samLinear, input.Tex )*float4( 1.0f, 1.0f, 0.0f, 1.0f );}[/source]

#3korvax

Posted 13 November 2012 - 03:06 PM

Might be a stupid question but if I what to create a black texture how do I do that.
Im doing the following to create black texture, but my FPS is dropping quiet a lot when this texture is in use.. My feeling is that I have created a "NULL" texture
and its black because Im missing "color" to it. I was trying to force a yellow color in the pixel shader but its still black.. is there something that I missing pls? Im quiet new to directx..
[source lang="cpp"] ID3D11ShaderResourceView* pTextureRV = NULL; ID3D11Texture2D* pTex2D = NULL; D3D11_TEXTURE2D_DESC textureDesc; ZeroMemory(&textureDesc, sizeof(textureDesc)); // Setup the render target texture description. textureDesc.Width = 1; textureDesc.Height = 1; textureDesc.MipLevels = 1; textureDesc.ArraySize = 1; textureDesc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT; textureDesc.SampleDesc.Count = 1; textureDesc.Usage = D3D11_USAGE_DEFAULT; textureDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE; textureDesc.MiscFlags = 0; D3D11_SHADER_RESOURCE_VIEW_DESC svrDesc; svrDesc.Format = textureDesc.Format; svrDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; svrDesc.Texture2D.MostDetailedMip = 0; svrDesc.Texture2D.MipLevels = 1; hr = m_pDevice->CreateShaderResourceView(pTex2D, &svrDesc, &pTextureRV);[/source]

my simple shader:


[source lang="cpp"]Texture2D txDiffuse : register( t0 );SamplerState samLinear : register( s0 );cbuffer CONSTANT_BUFFER : register( b0 ){ matrix World; matrix View; matrix Projection;}struct VS_INPUT{ float4 Pos : POSITION; float2 Tex : TEXCOORD0;};struct PS_INPUT{ float4 Pos : SV_POSITION; float2 Tex : TEXCOORD0;};//--------------------------------------------------------------------------------------// Vertex Shader//--------------------------------------------------------------------------------------PS_INPUT VS( VS_INPUT input ){ PS_INPUT output = (PS_INPUT)0; output.Pos = mul( input.Pos, World ); output.Pos = mul( output.Pos, View ); output.Pos = mul( output.Pos, Projection ); output.Tex = input.Tex; return output;}//--------------------------------------------------------------------------------------// Pixel Shader//--------------------------------------------------------------------------------------float4 PS( PS_INPUT input) : SV_Target{ return txDiffuse.Sample( samLinear, input.Tex )*float4( 1.0f, 1.0f, 0.0f, 1.0f );}[/source]

#2korvax

Posted 13 November 2012 - 03:05 PM

Might be a stupid question but if I what to create a black texture how do I do that.
Im doing the following to create black texture, but my FPS is dropping quiet a lot when this texture is in use.. My feeling is that I have created a "NULL" texture
and its black because Im missing "color" to it. I was trying to force a yellow color in the pixel shader but its still black.. is there something that I missing pls? Im quiet new to directx..
[source lang="cpp"] ID3D11ShaderResourceView* pTextureRV = NULL; ID3D11Texture2D* pTex2D = NULL; D3D11_TEXTURE2D_DESC textureDesc; ZeroMemory(&textureDesc, sizeof(textureDesc)); // Setup the render target texture description. textureDesc.Width = 1; textureDesc.Height = 1; textureDesc.MipLevels = 1; textureDesc.ArraySize = 1; textureDesc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT; textureDesc.SampleDesc.Count = 1; textureDesc.Usage = D3D11_USAGE_DEFAULT; textureDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE; textureDesc.MiscFlags = 0; D3D11_SHADER_RESOURCE_VIEW_DESC svrDesc; svrDesc.Format = textureDesc.Format; svrDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; svrDesc.Texture2D.MostDetailedMip = 0; svrDesc.Texture2D.MipLevels = 1; hr = m_pDevice->CreateShaderResourceView(pTex2D, &svrDesc, &pTextureRV);[/source]

my simple shader.


[source lang="cpp"]Texture2D txDiffuse : register( t0 );SamplerState samLinear : register( s0 );cbuffer CONSTANT_BUFFER : register( b0 ){ matrix World; matrix View; matrix Projection;}//--------------------------------------------------------------------------------------struct VS_INPUT{ float4 Pos : POSITION; float2 Tex : TEXCOORD0;};struct PS_INPUT{ float4 Pos : SV_POSITION; float2 Tex : TEXCOORD0;};//--------------------------------------------------------------------------------------// Vertex Shader//--------------------------------------------------------------------------------------PS_INPUT VS( VS_INPUT input ){ PS_INPUT output = (PS_INPUT)0; output.Pos = mul( input.Pos, World ); output.Pos = mul( output.Pos, View ); output.Pos = mul( output.Pos, Projection ); output.Tex = input.Tex; return output;}//--------------------------------------------------------------------------------------// Pixel Shader//--------------------------------------------------------------------------------------float4 PS( PS_INPUT input) : SV_Target{ return txDiffuse.Sample( samLinear, input.Tex )*float4( 1.0f, 1.0f, 0.0f, 1.0f );}[/source]

#1korvax

Posted 13 November 2012 - 03:04 PM

Might be a stupid question but if I what to create a black texture how do I do that.
Im doing the following to create black texture, but my FPS is dropping quiet a lot when this texture is in use.. My feeling is that I have created a "NULL" texture
and its black because Im missing "color" to it. I was trying to force a yellow color in the pixel shader but its still black.. is there something that I missing pls? Im quiet new to directx..
[source lang="cpp"] ID3D11ShaderResourceView* pTextureRV = NULL; ID3D11Texture2D* pTex2D = NULL; D3D11_TEXTURE2D_DESC textureDesc; ZeroMemory(&textureDesc, sizeof(textureDesc)); // Setup the render target texture description. textureDesc.Width = 1; textureDesc.Height = 1; textureDesc.MipLevels = 1; textureDesc.ArraySize = 1; textureDesc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT; textureDesc.SampleDesc.Count = 1; textureDesc.Usage = D3D11_USAGE_DEFAULT; textureDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE; textureDesc.MiscFlags = 0; D3D11_SHADER_RESOURCE_VIEW_DESC svrDesc; svrDesc.Format = textureDesc.Format; svrDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; svrDesc.Texture2D.MostDetailedMip = 0; svrDesc.Texture2D.MipLevels = 1; hr = m_pDevice->CreateShaderResourceView(pTex2D, &svrDesc, &pTextureRV);[/source]

my simple shader.
[source lang="cpp"]Texture2D txDiffuse : register( t0 );SamplerState samLinear : register( s0 );cbuffer CONSTANT_BUFFER : register( b0 ){ matrix World; matrix View; matrix Projection;}//--------------------------------------------------------------------------------------struct VS_INPUT{ float4 Pos : POSITION; float2 Tex : TEXCOORD0;};struct PS_INPUT{ float4 Pos : SV_POSITION; float2 Tex : TEXCOORD0;};//--------------------------------------------------------------------------------------// Vertex Shader//--------------------------------------------------------------------------------------PS_INPUT VS( VS_INPUT input ){ PS_INPUT output = (PS_INPUT)0; output.Pos = mul( input.Pos, World ); output.Pos = mul( output.Pos, View ); output.Pos = mul( output.Pos, Projection ); output.Tex = input.Tex; return output;}//--------------------------------------------------------------------------------------// Pixel Shader//--------------------------------------------------------------------------------------float4 PS( PS_INPUT input) : SV_Target{ return txDiffuse.Sample( samLinear, input.Tex )*float4( 1.0f, 1.0f, 0.0f, 1.0f );}[/source]

PARTNERS