I have currently some issues with my shader code:
cbuffer matrizen : register( b0 )
{
row_major matrix World;
row_major matrix View;
row_major matrix Projection;
};
struct VS_INPUT
{
float4 Pos : POSITION;
};
struct PS_INPUT
{
float4 Pos : SV_POSITION;
};
//--------------------------------------------------------------------------------------
// 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);
return output;
}
//--------------------------------------------------------------------------------------
// Pixel Shader
//--------------------------------------------------------------------------------------
float4 PS( PS_INPUT input) : SV_Target
{
return float4(1.0f,0.0f,0.0f,1.0f);
}actually this code is mostly copied from the directx sample browser and should work as it also works in the sample project. The Problem is, it doesnt displays anything if i apply the matrix transformations inside the vertex shader. The Matrices are assigned over this code.
struct Mats
{
XMMATRIX World;
XMMATRIX View;
XMMATRIX Projection;
};
........................
Mats mat;
mat.World = XMMatrixIdentity(); //no geometry transformations
XMVECTOR Eye = XMVectorSet( 0.0f, 0.0f, 5.0f, 0.0f );
XMVECTOR At = XMVectorSet( 0.0f, 0.0f, 0.0f, 0.0f );
XMVECTOR Up = XMVectorSet( 0.0f, 1.0f, 0.0f, 0.0f );
mat.View = XMMatrixLookAtLH( Eye, At, Up ); //looking on the triangle
mat.Projection = XMMatrixPerspectiveFovLH( XM_PIDIV4, (FLOAT)width / (FLOAT)height, 0.01f, 100.0f ); //calculating perspective matrix
immediatecontext->UpdateSubresource( Matrixbuffer 0, NULL, &mat, 0, 0 ); //updating matrices
drawing the content:
immediatecontext->VSSetShader( vertexshader, NULL, 0 ); //using the vertexshader immediatecontext->VSSetConstantBuffers( 0, 1, &Matrixbuffer ); //assign matrices to the vertexshader immediatecontext->PSSetShader( pixelshader, NULL, 0 ); //using the pixelshader immediatecontext->Draw( 3, 0 ); //drawing three vertices (one single triangle) swapchain->Present( 0, 0 );
I guess there is a really easy solution to this problem but currently i dont know how i could fix that.
EDIT: Leaving the matrices Identity matrices doesnt solves the problem so the problem has to be inside the matrix assignment (without doing the matrix transformations it display the triangle)
Edited by directx user, 03 June 2012 - 08:01 AM.






