Jump to content
  • Advertisement
Sign in to follow this  
tcige

how to program rotating cube using shader assembler

This topic is 1948 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

first i substitute a few common vertex shader funtions for SetFVF

 

then i multiply view/projection/world matrix to substitute SetVertexShaderConstantF for SetTransform

 

but the rotating effect is odd and if x/y/z's value is lower then zero, it will not be displayed

 

the shader assembler is as follows

 

"vs_1_1\n"
"dcl_position v0\n"
"dcl_color v1\n"
"m4x4 oPos, v0, c0\n"
"mov oD0, v1\n"

Share this post


Link to post
Share on other sites
Advertisement

The problem is not within that shader. That is a simple generic transformation that expects the WVP matrix in the constant registers 0...3, and that the incoming vertex has position and color elements. It doesn't care at all whether the transformation represents rotation or something else entirely.

 

Have you tried to transpose the WVP matrix before using SetVertexShaderConstantF? The m4x4 is a macro instruction that is implemented as four dp4:s across consecutive float4 registers on the drivers/hardware, and due to this the transpose is needed if using D3DX matrix utility functions to generate the transform.

 

The transpose is cheaper to do once on the host program, as opposed to running it on each vertex.

Edited by Nik02

Share this post


Link to post
Share on other sites

The problem is not within that shader. That is a simple generic transformation that expects the WVP matrix in the constant registers 0...3, and that the incoming vertex has position and color elements. It doesn't care at all whether the transformation represents rotation or something else entirely.

 

Have you tried to transpose the WVP matrix before using SetVertexShaderConstantF? The m4x4 is a macro instruction that is implemented as four dp4:s across consecutive float4 registers on the drivers/hardware, and due to this the transpose is needed if using D3DX matrix utility functions to generate the transform.

 

The transpose is cheaper to do once on the host program, as opposed to running it on each vertex.

 

thanks, and D3DXMatrixTranspose works when below zero statically

 

but the cube is still missing when rotating, and i use one static variable to set the angle dynamically as fvf

Share this post


Link to post
Share on other sites

The problem is not within that shader. That is a simple generic transformation that expects the WVP matrix in the constant registers 0...3, and that the incoming vertex has position and color elements. It doesn't care at all whether the transformation represents rotation or something else entirely.

 

Have you tried to transpose the WVP matrix before using SetVertexShaderConstantF? The m4x4 is a macro instruction that is implemented as four dp4:s across consecutive float4 registers on the drivers/hardware, and due to this the transpose is needed if using D3DX matrix utility functions to generate the transform.

 

The transpose is cheaper to do once on the host program, as opposed to running it on each vertex.

 

thanks again

 

i put the rotating matrix from the third to the second parameter when calling D3DXMatrixMultiply and it works now

Share this post


Link to post
Share on other sites

Why are you using shader assembly?

 

Cheers!

 

it's cool and i have not learned hlsl

Share this post


Link to post
Share on other sites

The shader assembly isn't supported since SM4.0 (Direct3D 10+), so shader assembly is getting deprecated. Well, of course there is the cool factor and more importantly it is useful to know shader assembly if you are debugging shader code and you want to know what's happening exactly. 

 

Otherwise, learn hlsl for any shader longer than you have written. AFAIK, every SM1.0 level pixel shader can represented using texture stage combinations, because of limited number of instructions. 

 

Cheers!

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!