Multitexturing problem

Started by
7 comments, last by peter86 20 years, 8 months ago
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]
Advertisement
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]
Many old cards are picky and require that TEXTURE be arg1. Even if this turns out not to be the problem, it''s still good form for compatibility with older hardware.
- 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

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.
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

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

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?
It should be ..|D3DFVF_TEX2..
Add u2 & v2 to your Vertex Structure, and give the right texture-coordinates to them.

.lick
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?

This topic is closed to new replies.

Advertisement