Jump to content

  • Log In with Google      Sign In   
  • Create Account


how to program rotating cube using shader assembler


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 tcige   Members   -  Reputation: 206

Like
0Likes
Like

Posted 24 May 2013 - 02:20 AM

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"



Sponsor:

#2 Nik02   Crossbones+   -  Reputation: 2641

Like
1Likes
Like

Posted 24 May 2013 - 03:58 AM

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, 24 May 2013 - 04:01 AM.

Niko Suni


#3 tcige   Members   -  Reputation: 206

Like
0Likes
Like

Posted 24 May 2013 - 04:52 AM

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



#4 kauna   Crossbones+   -  Reputation: 2156

Like
0Likes
Like

Posted 24 May 2013 - 06:32 AM

Why are you using shader assembly?

 

Cheers!



#5 tcige   Members   -  Reputation: 206

Like
0Likes
Like

Posted 24 May 2013 - 07:05 AM

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



#6 tcige   Members   -  Reputation: 206

Like
0Likes
Like

Posted 24 May 2013 - 07:06 AM

Why are you using shader assembly?

 

Cheers!

 

it's cool and i have not learned hlsl



#7 kauna   Crossbones+   -  Reputation: 2156

Like
0Likes
Like

Posted 24 May 2013 - 07:37 AM

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!






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS