From fixed pipeline to basic equivalent shader

Started by
0 comments, last by Mauro Tamm 5 years, 4 months ago

I have been playing around with a old game source (~2002, dx8) and upgrading it to dx9 (for now) and getting it to work - just for the sake of learning  (instead of just writing new code and learning little).
But since the source doesn't seem to have working shader logic - it's up to me to fix it. 

Currently limited to VS_1_1 (asm - because game has also precompiled shaders i don't want to start rewriting before i get it to work to begin with).

The shader i have problem with is one they apply to some items added to the map.

The ones without shader work fine - the matrix is calculated fine (rot, scale, position etc).

Non shader version passes it to 


SetTransform(D3DTS_WORLD, (D3DXMATRIX*)w_matrix)

And this works fine.

Now the shader part passes it to the vertex shader logic that set's all the shader variables.
And calls


SetVertexShader()

 And this is where the entire map gets messed up - stuff collapsed to a single point or not even visible anymore etc.

So what does the setTransform do in this case that i could replicate with a shader / what should i pass in?

Taking basic shader something like this (or even less)?


vs_1_1
dcl_position v0

; Transform to view space(world matrix is identity)
; m4x4 r9, v0, c0

; Transform to projection space
; m4x4 r10, r9, c4

; Store output position
mov oPos, v0

 


	D3DXMATRIXA16 viewMat;
	D3DXMatrixMultiply(&viewMat, (D3DXMATRIX*)mWorldMat, &state->mMatView);
	D3DXMatrixTranspose(&viewMat, &viewMat);
	pd3dDevice->SetVertexShaderConstantF(0, (float*)&viewMat, 4);

	// Set the projection space constant
	D3DXMATRIXA16 projMat;
	D3DXMatrixTranspose(&projMat, &state->mMatProj);
	pd3dDevice->SetVertexShaderConstantF(4, (float*)&projMat, 4);


Not 100% sure if the data in state is correctly stored - so what should those two actually be or are they even needed to replicate how "D3DTS_WORLD" works? Can u get some world/proj matrix from directx?
Spent two days on this and i can't get it working.

I can update with any additional info if required. I need a pointer to the right direction with this at least.


PS! apparently a missing SetVertexShader(0) later in the code to stop the shader from applying to everything else.

This topic is closed to new replies.

Advertisement