# transforming in world space?????

This topic is 4525 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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 :-)

##### Share on other sites
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
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.

##### Share on other sites
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...

##### Share on other sites
gutted! I was hoping I had screwed up....nah it still just shows the same grey screen that I am clearing :-(

Any other ideas?

I am using the effect framework....

m_pEffect->SetMatrix( pStringHandle, &Mat );

pStringHangle being "matWVP" and Mat the calcuated worldprojview matrix....

• 10
• 16
• 9
• 13
• 41