Sign in to follow this  

Help ,D3D renderstate influence

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

	d->SetTexture(0, m_tex);
	d->SetTexture(1, m_detailTex1);
	d->SetTexture(2, m_alpha1);
	d->SetTexture(3, m_detailTex2);
	d->SetTexture(4, m_alpha2);
	


	d->SetSamplerState(1, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP);
	d->SetSamplerState(1, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP);

	d->SetSamplerState(1, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
	d->SetSamplerState(1, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
	d->SetSamplerState(1, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);


	d->SetSamplerState(2, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
	d->SetSamplerState(2, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
	d->SetSamplerState(2, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);


	d->SetSamplerState(3, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
	d->SetSamplerState(3, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
	d->SetSamplerState(3, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);

	d->SetSamplerState(4, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
	d->SetSamplerState(4, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
	d->SetSamplerState(4, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);


	//base pic
	d->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
	d->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
	d->SetTextureStageState(0, D3DTSS_RESULTARG, D3DTA_TEMP);

	// detail pic1
	d->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE);
	d->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
	//	first alpha
	d->SetTextureStageState(2, D3DTSS_COLOROP, D3DTOP_BLENDTEXTUREALPHA);
	d->SetTextureStageState(2, D3DTSS_COLORARG1, D3DTA_CURRENT);
	d->SetTextureStageState(2, D3DTSS_COLORARG2, D3DTA_TEMP);
	d->SetTextureStageState(2, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
	d->SetTextureStageState(2, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);

I set multitexturing for terrain. and finish do terrain rendering.I do
		d->SetTexture(0, 0);
		d->SetTexture(1, 0);
		d->SetTexture(2, 0);			
		d->SetTexture(4, 0);
		d->SetTexture(3, 0);

		d->SetTextureStageState(0, D3DTSS_RESULTARG, D3DTA_CURRENT);

		d->SetTextureStageState(4, D3DTSS_COLOROP, D3DTOP_DISABLE);
		d->SetTextureStageState(4, D3DTSS_COLORARG1, 0);
		d->SetTextureStageState(4, D3DTSS_COLORARG2, 0);
		d->SetTextureStageState(4, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
		d->SetTextureStageState(4, D3DTSS_ALPHAARG1, 0);

		d->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
		d->SetTextureStageState(1, D3DTSS_COLORARG1, 0);
		d->SetTextureStageState(1, D3DTSS_COLORARG2, 0);
		d->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
		d->SetTextureStageState(1, D3DTSS_ALPHAARG1, 0);

		d->SetTextureStageState(2, D3DTSS_COLOROP, D3DTOP_DISABLE);
		d->SetTextureStageState(2, D3DTSS_COLORARG1, 0);
		d->SetTextureStageState(2, D3DTSS_COLORARG2, 0);
		d->SetTextureStageState(2, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
		d->SetTextureStageState(2, D3DTSS_ALPHAARG1, 0);

		d->SetTextureStageState(3, D3DTSS_COLOROP, D3DTOP_DISABLE);
		d->SetTextureStageState(3, D3DTSS_COLORARG1, 0);
		d->SetTextureStageState(3, D3DTSS_COLORARG2, 0);
		d->SetTextureStageState(3, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
		d->SetTextureStageState(3, D3DTSS_ALPHAARG1, 0);

but the render state of terain still influence other rendering, make the curious happen. for example, the light is available to some entity,but disable to else entity but I do not set render state of terrain. all is ok. how to do?

Share this post


Link to post
Share on other sites
d->SetTextureStageState(2, D3DTSS_COLORARG1, D3DTA_CURRENT);
d->SetTextureStageState(2, D3DTSS_COLORARG2, D3DTA_TEMP);
d->SetTextureStageState(2, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
d->SetTextureStageState(2, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
I mean how to disable texturestagestate as disable texture d->setTexture(0,0);

Share this post


Link to post
Share on other sites
How do you mean "disable the light" - you mean your fixed function D3DLIGHT9-based lighting, or something using vertex/pixel shaders?

Setting D3DTOP_DISABLE on the first unused state should be sufficient for disabling the multitexturing. Are you definitely sure this code is being called? I've had silly bugs before where it can sometimes (e.g. with an error) skip over the "clean up" code and leave the device in an unknown state.

Maybe posting a couple of screenshots of the after effects - what you are getting, and (if possible) what you want to be getting.

hth
Jack

Share this post


Link to post
Share on other sites
Quote:
Original post by jollyjeffers
How do you mean "disable the light" - you mean your fixed function D3DLIGHT9-based lighting, or something using vertex/pixel shaders?

Setting D3DTOP_DISABLE on the first unused state should be sufficient for disabling the multitexturing. Are you definitely sure this code is being called? I've had silly bugs before where it can sometimes (e.g. with an error) skip over the "clean up" code and leave the device in an unknown state.

Maybe posting a couple of screenshots of the after effects - what you are getting, and (if possible) what you want to be getting.

hth
Jack


Sovled:

look

d->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
d->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
d->SetTextureStageState(0, D3DTSS_RESULTARG, D3DTA_TEMP);

this alter the state , so it must be restore to default.

Share this post


Link to post
Share on other sites

This topic is 4342 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this