Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

KriS-XK

Vertex shader DX8 -> DX9

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

This effect file is loaded by directx8 without any problems, but direct9 doesn''t want to load it. What''s wrong?
  
// light position in object (!) space

vector vLT0;

// transposed world*view*projection transform

matrix mwvp;


// shadow volume extruder

// c0	-	transposed world*view*proj matrix

// c4	-	light position in object (!) space

// c5	-	x: extrude-distance; y: extrude-from (LP.N<y);


vertexshader vs = 
decl
{
	stream 0;
	float v0[3];				// position

	float v3[3];				// normal

}
asm
{
	vs.1.1

	// compute point->light vector

	add	r0.xyz, -c4.xyz, v0.xyz		// r0: LP (point->light vector)

	dp3	r0.w, r0.xyz, r0.xyz		// r0.w: |LP|^2

	rsq	r0.w, r0.w					// r0.w: 1/|LP|

	mul	r0.xyz, r0.xyz, r0.www		// r0: normalized LP


	// dot with normal

	dp3	r0.w, r0.xyz, v3.xyz		// r0.w: LP dot N


	// EXTRUDE BACKFACES

	// test if dot less than given factor

	slt	r0.w, c5.y, r0.w			// r0.w: 0.0f if frontface, 1.0f if backface


	// extrude

	mul	r0.w, r0.w, c5.x			// r0.w: extrusion amount

	mad	r0.xyz, r0.xyz, r0.www,	v0.xyz
	mov	r0.w, v0.w					// r0: final world pos


	// to projection space

	m4x4 oPos, r0, c0
};

technique t0
{
	pass p0
	{
		vertexshader = <vs>;

		VertexShaderConstant[0]	= <mwvp>;
		VertexShaderConstant[4] = <vLT0>;
		VertexShaderConstant[5] = (60.0f,0.0f,0.0f,0.0f);

		CullMode = CCW;

		TextureFactor = 0x00202030;

		StencilEnable = True;
		StencilFunc = Always;
		StencilRef = 0x00000000;
		StencilMask = 0xffffffff;
		StencilWriteMask = 0xffffffff;
		StencilZFail = Incr;
		StencilFail = Keep;
		StencilPass = Keep;

        AlphaBlendEnable = True;
        SrcBlend = One;
        SrcBlend = Zero;
        DestBlend = One;

		//FillMode = Wireframe;


		ZWriteEnable = False;
		ZEnable = True;
		ZFunc = Less;

		ColorOp[0]   = SelectArg1;
		ColorArg1[0] = TFactor;
		ColorOp[1] = Disable;
	}

	pass p1
	{
		CullMode = CW;

		StencilZFail = Decr;
	}
}
  

Share this post


Link to post
Share on other sites
Advertisement
No answers eh?

I''ll take a quick stab, I think you need to add vertex decl mapping for DX9... from the docs:


VertexShader =
asm
{
vs_1_1

dcl_position v0
dcl_normal v3
dcl_texcoord v7
dcl_texcoord v8

m4x4 oPos, v0, c4 //

etc

Chapel

Share this post


Link to post
Share on other sites

  • 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!