Skip to main content
gamedev.net
🔒 Locked

Help ,D3D renderstate influence

Started by luasitdown 3 replies 900+ views
Original Post
luasitdown
luasitdown

	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?
luasitdown
luasitdown
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);

luasitdown
luasitdown
by my debugging, I found problem is setTextureStageState will disable the light

is it true?
jollyjeffers
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
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |
luasitdown
luasitdown
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.