🔒 Locked
Multitexturing Problems
Advertisement
Original Post
i checked through the forum and didn''t find many multitexturing problems - or it seems they didn''t help me out. so here''s a new one.
i''m having a little difficulty getting this to work. i can get blends to work only in the first pass. ie: diffuse and one texture. then when i go to the second pass my settings are for current and texture. if i select arg 0 (current) everything looks like it should. but if arg 1 (texture) is selected i get nothing. just white polies. dx returns okay for everything - even ValidateDevice. i know this should work since i ran some of the SDK samples and they blended fine on my test system.
i have no idea what i''m doing wrong but it must be something. i set the stages with SetTextureStageState and textures are being properly set with SetTexture providing the correct stage for them to work upon. are there some render states that i need to set? i am setting some of the blending ops. if anyone wants to view some sample code, or ask some question for clarification, just ask.
-tim
for the second stage (pass) you don''t want select arg 0 or 1, you want modulate. this will take arg0 (current - ie. the first pass) and arg1 (the second texture) and blend them together.
If you are actually doing this then I''m stumped...
Good luck,
Toby
Gobsmacked - by Toby Murray
If you are actually doing this then I''m stumped...
Good luck,
Toby
Gobsmacked - by Toby Murray
This particular section is done four times, each time replacing the first parameter with the corresponding state (ie, 0-3) as well as the rs0 with my other variables rs1 etc. The variable rs0.m_ColourInputA holds a define of type D3DTA_*. rs0.m_ColourOpX holds D3DTA_*. Lastly rs0.m_ColourOp holds a D3DTOP_*. These are set through a little GUI dialog. I have verified these values and they do correspond to the proper defines.
m_pD3D8Device->SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, 0);//TEMP TEMP
m_pD3D8Device->SetTextureStageState(0, D3DTSS_COLORARG1, rs0.m_ColourInputA | rs0.m_ColourOpX);
m_pD3D8Device->SetTextureStageState(0, D3DTSS_COLORARG2, rs0.m_ColourInputB | rs0.m_ColourOpX);
m_pD3D8Device->SetTextureStageState(0, D3DTSS_COLOROP, rs0.m_ColourOp);
m_pD3D8Device->SetTextureStageState(0, D3DTSS_ALPHAARG1, rs0.m_AlphaInputA | rs0.m_AlphaOpX);
m_pD3D8Device->SetTextureStageState(0, D3DTSS_ALPHAARG2, rs0.m_AlphaInputB | rs0.m_AlphaOpX);
m_pD3D8Device->SetTextureStageState(0, D3DTSS_ALPHAOP, rs0.m_AlphaOp);
As to selecting arg0 on the second pass, it should work fine. It will just effectively discard the first pass of the alpha or colour - but still use the CPU time.
m_pD3D8Device->SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, 0);//TEMP TEMP
m_pD3D8Device->SetTextureStageState(0, D3DTSS_COLORARG1, rs0.m_ColourInputA | rs0.m_ColourOpX);
m_pD3D8Device->SetTextureStageState(0, D3DTSS_COLORARG2, rs0.m_ColourInputB | rs0.m_ColourOpX);
m_pD3D8Device->SetTextureStageState(0, D3DTSS_COLOROP, rs0.m_ColourOp);
m_pD3D8Device->SetTextureStageState(0, D3DTSS_ALPHAARG1, rs0.m_AlphaInputA | rs0.m_AlphaOpX);
m_pD3D8Device->SetTextureStageState(0, D3DTSS_ALPHAARG2, rs0.m_AlphaInputB | rs0.m_AlphaOpX);
m_pD3D8Device->SetTextureStageState(0, D3DTSS_ALPHAOP, rs0.m_AlphaOp);
As to selecting arg0 on the second pass, it should work fine. It will just effectively discard the first pass of the alpha or colour - but still use the CPU time.
He's not saying he's trying to "blend" using SELECTARG toby, he was providing it as a testing example.
If he uses SELECTARG2 in the second stage, effectively discarding the results of the first stage, he should see the second texture. He's not.. he's seeing a white polygon. Therein lies the issue, not the fact that he's not using D3DTOP_MODULATE.
Anywho..
Ok, jovial, what happens if instead of using your data structures (rs0, rs1 etc... OT why didn't you just make an array called rs?) you manually set the first and second stages?
Comment your automated TextureStageState code out and just type in
SetTexture (0,texturepointerwhatever);
SetTexture (1,texturepointerwhatever2);
SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_TEXTURE);
SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE);
SetTextureStageState (1, D3DTSS_COLORARG1, D3DTA_CURRENT);
SetTextureStageState (1, D3DTSS_COLORARG2, D3DTA_TEXTURE);
SetTextureStageState (1, D3DTSS_COLOROP, D3DTOP_MODULATE);
SetTextureStageState (2,D3DTSS_COLOROP, D3DTOP_DISABLE);
SetTextureStageSTate (0, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
See if the problem is in your higher level automation rather than in the actual rendering.
I assume you've swapped the textures around (switched 0 with 1) to make sure it's not a problem with the texture itself?
[edited by - sorrow on April 15, 2002 4:00:27 PM]
If he uses SELECTARG2 in the second stage, effectively discarding the results of the first stage, he should see the second texture. He's not.. he's seeing a white polygon. Therein lies the issue, not the fact that he's not using D3DTOP_MODULATE.
Anywho..
Ok, jovial, what happens if instead of using your data structures (rs0, rs1 etc... OT why didn't you just make an array called rs?) you manually set the first and second stages?
Comment your automated TextureStageState code out and just type in
SetTexture (0,texturepointerwhatever);
SetTexture (1,texturepointerwhatever2);
SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_TEXTURE);
SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE);
SetTextureStageState (1, D3DTSS_COLORARG1, D3DTA_CURRENT);
SetTextureStageState (1, D3DTSS_COLORARG2, D3DTA_TEXTURE);
SetTextureStageState (1, D3DTSS_COLOROP, D3DTOP_MODULATE);
SetTextureStageState (2,D3DTSS_COLOROP, D3DTOP_DISABLE);
SetTextureStageSTate (0, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
See if the problem is in your higher level automation rather than in the actual rendering.
I assume you've swapped the textures around (switched 0 with 1) to make sure it's not a problem with the texture itself?
[edited by - sorrow on April 15, 2002 4:00:27 PM]
Yeah, I swapped the textures. No go. They''re both 256x512 (I''ll probably try some square one''s later today) but individually they show up fine.
As for pasting that in (well almost a paste, I changed the colour disable to 2, not 1 but that seems to be a typo), no change. Still don''t get the effect of the second texture blending in. Only the first and diffuse.
Is there anything in initialization of D3D that needs to be done to support this? Perhaps I''m just doing something incredibly stupid.
Thanks for helping.
-tim
As for pasting that in (well almost a paste, I changed the colour disable to 2, not 1 but that seems to be a typo), no change. Still don''t get the effect of the second texture blending in. Only the first and diffuse.
Is there anything in initialization of D3D that needs to be done to support this? Perhaps I''m just doing something incredibly stupid.
Thanks for helping.
-tim
well, unfortunately i''m using a TNT. i did test it out on a GF1 though, with the same results. i also ran the multitexturing demo that came with the SDK on the TNT and that worked fine. i suppose i''ll go through the tedious process of transplanting my code into the sample to see what''s going wrong.
-tim
-tim
err yeah.. sorry bout that, I''ll actually READ next time whats on the post... 
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement