Skip to main content
gamedev.net
🔒 Locked

Multi-Texturing Problem

Started by Xeno Mar 13, 2003 at 8:00 PM 5 replies 1.1k views
Original Post
Xeno
Xeno
hi , i just wrote a code to see if i understood the multi-texturing stuff. so i told directx to select the texture0 (fire_tex) into stage0 without changes , and then to select texture1(wall_tex) into stage1 without changes , so what i should get is texture1 rendered on the polygon , no? for some reason its corrupted, and the result looks like directx duplicated the first pixel of texture1(wall_tex) over the whole polygon istead of mapping the whole texture over the polygon... its strange... , coz it happens just when im selecting texture1 into stage 1 with D3DTSS_COLOROP = D3DTOP_SELECTARG1, however , when im selecting texture0 (D3DTSS_COLOROP = D3DTOP_SELECTARG2)into stage 1 its working probably. thats the code that doesnt work: display.SetRenderTexture(&fire_tex,0); display.SetRenderTexture(&wall_tex,1); display.ReturnDevice()->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); display.ReturnDevice()->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 ); display.ReturnDevice()->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); display.ReturnDevice()->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 ); display.ReturnDevice()->SetTextureStageState( 1, D3DTSS_COLORARG1, D3DTA_TEXTURE ); display.ReturnDevice()->SetTextureStageState( 1, D3DTSS_COLORARG2, D3DTA_CURRENT ); display.ReturnDevice()->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_SELECTARG1 ); display.ReturnDevice()->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE ); display.ReturnDevice()->SetTextureStageState(2,D3DTSS_COLOROP,D3DTOP_DISABLE); display.ReturnDevice()->SetTextureStageState(2,D3DTSS_ALPHAOP,D3DTOP_DISABLE); DWORD dwNumPasses = 2; display.ReturnDevice()->ValidateDevice( &dwNumPasses ); and that one will work: display.SetRenderTexture(&fire_tex,0); display.SetRenderTexture(&wall_tex,1); display.ReturnDevice()->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); display.ReturnDevice()->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 ); display.ReturnDevice()->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); display.ReturnDevice()->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 ); display.ReturnDevice()->SetTextureStageState( 1, D3DTSS_COLORARG1, D3DTA_TEXTURE ); display.ReturnDevice()->SetTextureStageState( 1, D3DTSS_COLORARG2, D3DTA_CURRENT ); display.ReturnDevice()->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_SELECTARG2 ); display.ReturnDevice()->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE ); display.ReturnDevice()->SetTextureStageState(2,D3DTSS_COLOROP,D3DTOP_DISABLE); display.ReturnDevice()->SetTextureStageState(2,D3DTSS_ALPHAOP,D3DTOP_DISABLE); DWORD dwNumPasses = 2; display.ReturnDevice()->ValidateDevice( &dwNumPasses ); anyone have any suggestions? [edited by - xeno on March 13, 2003 9:04:58 PM] [edited by - xeno on March 13, 2003 9:05:46 PM]
------------------------------- Goblineye Entertainment------------------------------
don
don
From the DX SDK docs, "Texture Blending Operations and Arguments":

Note: You can disable a texture stage—and any subsequent texture blending stages in the cascade—by setting the color operation for that stage to D3DTOP_DISABLE. Disabling the color operation effectively disables the alpha operation as well. >>Alpha operations cannot be disabled when color operations are enabled. Setting the alpha operation to D3DTOP_DISABLE when color blending is enabled causes undefined behavior.<<

Xeno
Xeno
it still doesnt work , i changed it to:


display.SetRenderTexture(&fire_tex,0);
display.SetRenderTexture(&wall_tex,1);

display.ReturnDevice()->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
display.ReturnDevice()->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
display.ReturnDevice()->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
display.ReturnDevice()->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );

display.ReturnDevice()->SetTextureStageState( 1, D3DTSS_COLORARG1, D3DTA_TEXTURE );
display.ReturnDevice()->SetTextureStageState( 1, D3DTSS_COLORARG2, D3DTA_CURRENT );
display.ReturnDevice()->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );

display.ReturnDevice()->SetTextureStageState( 1, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
display.ReturnDevice()->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );

display.ReturnDevice()->SetTextureStageState(2,D3DTSS_COLOROP,D3DTOP_DISABLE);
display.ReturnDevice()->SetTextureStageState(2,D3DTSS_ALPHAOP,D3DTOP_DISABLE);


DWORD dwNumPasses = 2;
display.ReturnDevice()->ValidateDevice( &dwNumPasses );


and still nothing..

[edited by - xeno on March 13, 2003 9:56:52 PM]
------------------------------- Goblineye Entertainment------------------------------
Xeno
Xeno
anyone?
------------------------------- Goblineye Entertainment------------------------------
Osc
Osc
Are you giving any texture coordiantes to the second stage?

If you''re using the same texture coordinates for both textures, you can just use:

display.ReturnDevice()->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 0);
Xeno
Xeno
ok , it works , but , shouldnt the first texture coords be as default for all the texture stages?
------------------------------- Goblineye Entertainment------------------------------
don
don
No. The default texture coordinate index for a texture stage is the same as the stage number.

Topic Locked

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

Sign in to reply to this topic.