Original Post
Hi
I have a constant buffer that I'm updating each frame, it contains one matrix and one float4, the problem seems that the matrix part is updating
while the color part is getting all zeros no matter anything...
my structure oout of shader (i.e. in the source code) is this:
struct BufferInfo
{
XMFLOAT4 color;
XMMATRIX mat;
};
constant buffer declaration is this:
D3D11_BUFFER_DESC constDesc;
ZeroMemory(&constDesc,sizeof(constDesc));
constDesc.BindFlags=D3D11_BIND_CONSTANT_BUFFER;
constDesc.ByteWidth=sizeof(BufferInfo);
constDesc.Usage =D3D11_USAGE_DEFAULT;
d3dResult=d3dDevice->CreateBuffer(&constDesc,0,&mvpcCB);
the draw/update part:
BufferInfo bufferInfo01;
XMMATRIX world=sprite->GetWorldMatrix();
XMMATRIX mvp=XMMatrixMultiply(world, vpMatrix);
mvp=XMMatrixTranspose(mvp);
bufferInfo01.mat = mvp;
bufferInfo01.color = color;
d3dContext->UpdateSubresource(mvpcCB,0,0,&bufferInfo01,0,0);
d3dContext->VSSetConstantBuffers(0,1,&mvpcCB);
--------------------
the shader part:
cbuffer cbChangesPerFrame : register(b0)
{
float4 col_;
matrix mvp_;
};
the pixel shader:
float4 PS_Main(PS_Input frag) : SV_TARGET
{
return colorMap_.Sample(colorSampler_,frag.tex0)*float4(col_[0],col_[1],col_[2],1.0f);
}
if I don't use (return colorMap_.Sample(colorSampler_,frag.tex0)*float4(col_[0],col_[1],col_[2],1.0f);) and use this:
return colorMap_.Sample(colorSampler_,frag.tex0)*col_;
the text (since this is a text renderer, it renders text) won't appear (its alpha will be zero) and it will be black since RGB are all zeroes..
seems that only the matrix part is updates, the color part is updates...any suggestions why is this weird thing happening??
Thanks
I have a constant buffer that I'm updating each frame, it contains one matrix and one float4, the problem seems that the matrix part is updating
while the color part is getting all zeros no matter anything...
my structure oout of shader (i.e. in the source code) is this:
struct BufferInfo
{
XMFLOAT4 color;
XMMATRIX mat;
};
constant buffer declaration is this:
D3D11_BUFFER_DESC constDesc;
ZeroMemory(&constDesc,sizeof(constDesc));
constDesc.BindFlags=D3D11_BIND_CONSTANT_BUFFER;
constDesc.ByteWidth=sizeof(BufferInfo);
constDesc.Usage =D3D11_USAGE_DEFAULT;
d3dResult=d3dDevice->CreateBuffer(&constDesc,0,&mvpcCB);
the draw/update part:
BufferInfo bufferInfo01;
XMMATRIX world=sprite->GetWorldMatrix();
XMMATRIX mvp=XMMatrixMultiply(world, vpMatrix);
mvp=XMMatrixTranspose(mvp);
bufferInfo01.mat = mvp;
bufferInfo01.color = color;
d3dContext->UpdateSubresource(mvpcCB,0,0,&bufferInfo01,0,0);
d3dContext->VSSetConstantBuffers(0,1,&mvpcCB);
--------------------
the shader part:
cbuffer cbChangesPerFrame : register(b0)
{
float4 col_;
matrix mvp_;
};
the pixel shader:
float4 PS_Main(PS_Input frag) : SV_TARGET
{
return colorMap_.Sample(colorSampler_,frag.tex0)*float4(col_[0],col_[1],col_[2],1.0f);
}
if I don't use (return colorMap_.Sample(colorSampler_,frag.tex0)*float4(col_[0],col_[1],col_[2],1.0f);) and use this:
return colorMap_.Sample(colorSampler_,frag.tex0)*col_;
the text (since this is a text renderer, it renders text) won't appear (its alpha will be zero) and it will be black since RGB are all zeroes..
seems that only the matrix part is updates, the color part is updates...any suggestions why is this weird thing happening??
Thanks