Jump to content
  • Advertisement
Sign in to follow this  
Flurreh Kitsune Flufftail

Issue after converting D3D8 to D3D9

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

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

Share this post


Link to post
Share on other sites
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).

Edited by Buckeye

Share this post


Link to post
Share on other sites

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.

Edited by Nik02

Share this post


Link to post
Share on other sites
 

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! :)

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!