Jump to content
  • Advertisement
Sign in to follow this  
RavNaz

transforming in world space?????

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 variable
float4x4 ModelViewProj;


C# example

Effect.SetValue("ModelViewProj", modelViewProj);
//And in your shader the appropriate variable
float4x4 ModelViewProj;



I hope this helps.
Take care.

Share this post


Link to post
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 this post


Link to post
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?

[edit]

I am using the effect framework....

m_pEffect->SetMatrix( pStringHandle, &Mat );

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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!