Archived

This topic is now archived and is closed to further replies.

Multitexturing problem

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

When I try to multitexture an object it either appears black I use D3DTOP_MODULATE or only one texture is visible if I use D3DTOP_ADD. What could be wrong? See code below:
g_pd3dDevice->SetTexture( 0, g_pWallTexture );
g_pd3dDevice->SetTexture( 1, g_pDarkMapTexture );
g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_SELECTARG1 );

g_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLORARG1, D3DTA_CURRENT );
g_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLOROP,   D3DTOP_MODULATE );
g_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLORARG2, D3DTA_TEXTURE );
[edited by - peter86 on August 5, 2003 1:14:59 PM]

Share this post


Link to post
Share on other sites
That's a definite sign that one of your textures either isn't working or it's pure black. The texture that isn't working is the one that IS NOT being seen when using D3DTOP_ADD.

Basically, if one texture is coming out all black, and your modulating it with another, the final result will come out all black because anything multiplied by zero (the value for black) will be zero.

As for adding, of course if a texture is all black, it's color values are all zeros. Therefore when you add it with another texture, the final result will BE that other texture sinse adding zero to anything doesn't change the value.

Check your darkmap texture. Is it naturally all black?

Also, does your card support multiple textures? Most do, but check D3DCAPS::MaxTextureBlendStages and D3DCAPS::MaxSimultaneousTextures to be sure.

---
Brent Gunning | My Site

[edited by - RapidStunna on August 5, 2003 3:02:58 PM]

Share this post


Link to post
Share on other sites
- Nothing in the debug output?
- Tested it in the REF device?
- What''s your card?
- What''s the alphaOp set to?
- Have you disabled stage 2? (colorOp and alphaOp set to disable)
- Test it with the sample that comes with the SDK, named MFCTex or something similar.

Peace,
Muhammad Haggag

Share this post


Link to post
Share on other sites
There''s nothing in the debug output, it dosen''t work in REF mode either. I have a TNT2 Riva card (which has the needed caps). I''ve tryed setting AlphaOp and Stage2, but without success. It works fine with MFCTex and I''ve tryed using the stage code it produced.

Share this post


Link to post
Share on other sites
1) Since you''re using 2 stages worth of textures:do you have 2 sets of texture coordinates per vertex?, if so what does your FVF look like, if not, what does your TEXCOORDINDEX state setup look like?

2) Try putting a ValidateDevice() call in just before your Draw*Primitive() call to see if the driver is unhappy with any part of your setup.

3) What do you have set for the alpha states? General rule of thumb - keep the alpha pipe open for the same number of stages as the colour pipe - even if that just means a bunch of "SELECTARGn, CURRENT"''s.

4) Have you verified that both textures have actually come through ok - by displaying each as texture 0 for example

--
Simon O''Connor
ex -Creative Asylum
Programmer &
Microsoft MVP

Share this post


Link to post
Share on other sites
Here''s my FVF definition: #define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1)

I don''t have any TEXCOORDINDEX, the device is okay and I''ve tryed setting the alphastates too but it didn''t help. Both textures are okay, I''ve checked them.

What could be wrong?

Share this post


Link to post
Share on other sites
quote:
Original post by Pipo DeClown
It should be ..|D3DFVF_TEX2..
Add u2 & v2 to your Vertex Structure, and give the right texture-coordinates to them.


How do I assign multiple texture coordinates then?

Share this post


Link to post
Share on other sites