I'm trying to convert some DirectX code to Ogre3D and was wondering what the following translates to:

pDev->SetTextureStage(0, D3DTSS_TEXCOORDINDEX, 0)
pDev->SetTextureStage(0, D3DTSS_COLORARG1,     D3DTA_TEXTURE)
pDev->SetTextureStage(0, D3DTSS_COLOROP,       D3DTOP_MODULATE)
pDev->SetTextureStage(0, D3DTSS_COLORARG2,     0)

What is the modulation operation happening here? Is the texture getting modulated with the background? Or is it getting zeroed?

I've tried searching for what this means and unfortunately I haven't come across anything meaningful. Any help to shed light on this matter will be much appreciated.

| improve this question | | | | |

This is one of the D3DTA macros; checking in d3d9types.h reveals that D3DTA_DIFFUSE is defined as 0x00000000 so that's the one.

It's obvious that the reason why is because you can bitwise-or these with various options, so the rendering backend is checking to see if the option to do so has been selected and is using a DWORD instead of the macro directly. E.g. it might look something like:

DWORD colorarg2option = D3DTA_DIFFUSE;
if (options.colorarg2 & something) colorarg2option |= D3DTA_COMPLEMENT;
if (options.colorarg2 & somethingelse) colorarg2option |= D3DTA_ALPHAREPLICATE;
pDev->SetTextureStage (0, D3DTSS_COLORARG2, colorarg2option);
| improve this answer | | | | |
  • \$\begingroup\$ That totally makes sense! Thanks a lot for that info :) \$\endgroup\$ – Vite Falcon Nov 15 '11 at 22:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.