Jump to content
  • Advertisement
Sign in to follow this  
darrenmarklines

Second texturestage alpha value [RESOLVED]

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

Hi, I'm new to multi texturing, so please bear with me. I have a reflection map on my second texture stage...
m_pD3DDevice->SetTextureStageState( 1, D3DTSS_COLOROP,   D3DTOP_ADD );
m_pD3DDevice->SetTextureStageState( 1, D3DTSS_COLORARG1, D3DTA_TEXTURE );
m_pD3DDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR );
seems to work fine, except that I want to change the amound of 'reflectivity' so that I can vary the amount of the first stage texture I see by passing something like an alpha value to the second stage. How can I do this? [Edited by - darrenmarklines on August 11, 2006 12:18:49 PM]

Share this post


Link to post
Share on other sites
Advertisement
Use colorop MultiplyAdd (and arg0). I can never remember if the documentation's arg3 = arg0, or if arg1=arg0, arg2=arg1, arg3=arg2. Just reorder things until it works. ;)

stage 0 color = diffuse texture * lighting
stage 0 alpha = anything
stage 1 color = cubetex * tfactor + current
stage 1 alpha = anything
stage 2 color = stage 2 alpha = disable

or

Use D3DTOP_MODULATEALPHA_ADDCOLOR with your reflection as arg2, current as arg1, and have stage 0 setup the blend amount in stage 0's alpha.

ie:
stage 0 color = diffuse texture * lighting
stage 0 alpha = tfactor (D3DRS_TEXTUREFACTOR to set)
stage 1 color = (stage 0 color) + (stage 0 alpha) * (cubemap)
stage 1 alpha = something
stage 2 color = stage 2 alpha = disable

The multiplyadd may not be available on some older hardware, but it will allow a color tint on the reflection as it's using tfactor's RGB, not just alpha.

All the math for all the modes is documented fairly clearly in the SDK. Go to index, type D3DTEXTUREOP, and look at what's available.

Share this post


Link to post
Share on other sites
Thanks, setting the tfactor was what I wanted.


m_pD3DDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_MULTIPLYADD );
// EnvironmentShininess is a unsigned long specifying ARGB colour
m_pD3DDevice->SetRenderState( D3DRS_TEXTUREFACTOR , m_EnvironmentShininess );
m_pD3DDevice->SetTextureStageState( 1, D3DTSS_COLORARG1, D3DTA_TEXTURE );
m_pD3DDevice->SetTextureStageState( 1, D3DTSS_COLORARG2, D3DTA_TFACTOR );

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!