transforming in world space?????
Hi guys,
for some reason, that I cant seem to work out, my polys that should be being rendered arent....heres the background:
got my HLSL doing all the work....eg:
VS_OUT vs_main( VS_IN In )
{
VS_OUT Out;
Out.ProjPos = mul( matWVP, In.ObjPos );
Out.UV = In.UV;
return Out;
};
with an appropriate PS:
float4 ps_main( PS_IN In ) : COLOR
{
return tex2D( ColorTexture, In.UV );
};
This compiles fine. However :-) When coming to render the thing, nothing appears......now, if I do then following:
g_pd3dDevice->SetTransform(D3DTS_VIEW, &m_matV); g_pd3dDevice->SetTransform( D3DTS_PROJECTION, &m_matP );
I get everything in the centre of screen ( although they should be moving around the screen )....so my question is, how do I do a SetTransform to setup the VIEW and PROJECTION matrices in HLSL??? I was under the impression that my VS sorted this out, as I am setting the WorldViewProjection matrix ( matWVP ) directly from the code side. The WorldViewProjection matrix is being calculated in code.
Hope this made sense and that I've supplied enough info.
Hope someone can help :-)
The problem lies in how you are multiplying your position with your transformation matrix to place it in screen space.
Out.ProjPos = mul( matWVP, In.ObjPos );
should be
Out.ProjPos = mul( In.ObjPos, matWVP );
Make sure that you are also correctly sending the parameters through to your shader if you are using the effect framework.
Examples of these would be the following.
c++ example
C# example
I hope this helps.
Take care.
Out.ProjPos = mul( matWVP, In.ObjPos );
should be
Out.ProjPos = mul( In.ObjPos, matWVP );
Make sure that you are also correctly sending the parameters through to your shader if you are using the effect framework.
Examples of these would be the following.
c++ example
ID3DXEffect::SetMatrix("ModelViewProj", &ModelViewProj);//And in your shader the appropriate variablefloat4x4 ModelViewProj;
C# example
Effect.SetValue("ModelViewProj", modelViewProj);//And in your shader the appropriate variablefloat4x4 ModelViewProj;
I hope this helps.
Take care.
bah! I've tried that already :-) Just about to try it again though, make sure I didnt mess up some how....get back to you in two ticks...thanks...
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement