Issue after converting D3D8 to D3D9

Started by
3 comments, last by Buckeye 9 years, 6 months ago
Hey guys,

I've been porting an old game from D3D8 to D3D9 and now I'm having a small issue.
The game client renders everything just fine but the textures won't blend correctly in the map editor which uses the same libraries as the client does.

That's how it looks like:

ditShvV.jpg

It renders just fine using D3D8 but I want to have D3D9 in both, the client and the map editor. I really don't have any idea why this happens.
What could cause that? I was suspecting the sampler states to be the root of the evil but whatever I did with them, I was just able to make it worse - not better.

Best regards
Advertisement

The game client renders everything just fine but the textures won't blend correctly in the map editor which uses the same libraries as the client does.

Making a really obvious suggestion: if you have a DX9 app that does something properly, compare the routines and settings that work with those that don't work in the other DX9 app. Look at things like device creation, render target settings, texture stage states, sampler settings, etc.

Your post is essentially: "I have one app that works, and another that doesn't. What's wrong?"

Perhaps if you provide some setup and rendering code snippets from both apps, someone can spot the problem.

EDIT: Nik02's post also raises the question - what does the correct result look like? The image posted looks like simple additive blending (alpha ~ 0.5 or thereabouts).

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

I agree with Buckeye.

That said, the artifacts give the impression that the texture used as the mixing coefficient between the ground and the vegetation uses nearest-point filtering for magnification, while it (presumably) should use bilinear.

Niko Suni

 

The game client renders everything just fine but the textures won't blend correctly in the map editor which uses the same libraries as the client does.

 
Making a really obvious suggestion: if you have a DX9 app that does something properly, compare the routines and settings that work with those that don't work in the other DX9 app. Look at things like device creation, render target settings, texture stage states, sampler settings, etc.
 
Your post is essentially: "I have one app that works, and another that doesn't. What's wrong?"
 
Perhaps if you provide some setup and rendering code snippets from both apps, someone can spot the problem.
 

Well, I've been trying for hours already. I debugged everything, looked what exactly is going on and even reverted all my changes and converted everything again.

And now, as I'm writing this, I (accidentally!) found the error. Somehow I must've hit my capslock key and upon hitting it, everything went alright even though the map editor wasn't even focused, I was just writing here with it being visible on my second screen.

It was caused by the SamplerStates being set wrong, I didn't notice that because the correct setting was activated on VK_CAPITAL.

/*if (GetAsyncKeyState(VK_CAPITAL))	{*/		
STATEMANAGER.SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_GAUSSIANQUAD);

STATEMANAGER.SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_GAUSSIANQUAD);
STATEMANAGER.SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_GAUSSIANQUAD);
STATEMANAGER.SetSamplerState(1, D3DSAMP_MINFILTER, D3DTEXF_GAUSSIANQUAD);
STATEMANAGER.SetSamplerState(1, D3DSAMP_MAGFILTER, D3DTEXF_GAUSSIANQUAD);
STATEMANAGER.SetSamplerState(1, D3DSAMP_MIPFILTER, D3DTEXF_GAUSSIANQUAD);
/*}
else
{
STATEMANAGER.SetSamplerState(0, D3DSAMP_MINFILTER,      D3DTEXF_LINEAR);
STATEMANAGER.SetSamplerState(0, D3DSAMP_MAGFILTER,	D3DTEXF_LINEAR);
STATEMANAGER.SetSamplerState(0, D3DSAMP_MIPFILTER,	D3DTEXF_LINEAR);
STATEMANAGER.SetSamplerState(1, D3DSAMP_MINFILTER,	D3DTEXF_LINEAR);
STATEMANAGER.SetSamplerState(1, D3DSAMP_MAGFILTER,	D3DTEXF_LINEAR);
STATEMANAGER.SetSamplerState(1, D3DSAMP_MIPFILTER,	D3DTEXF_LINEAR);
}*/
Everything's alright this way. :)
I thought D3DTEXF_LINEAR would be correct because the client never uses D3DTEXF_GAUSSIANQUAD. It only uses D3DTEXF_LINEAR and D3DTEXF_POINT, that's what confused me so I never even thought of that causing these issues.

8HhbwIB.jpg
That's the correct result by the way.

Thanks guys! :)

Thanks for posting the resolution. Nice results, BTW.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

This topic is closed to new replies.

Advertisement