Skip to main content
gamedev.net
🔒 Locked

Texture blending

Started by bartiss Oct 27, 2005 at 3:36 PM 1 replies 550+ views
Original Post
bartiss
bartiss
Hi, Is it possible to blend two textures with MODULATE, but: 1st texture is a common diffuse texture 2nd texture is a lightmap with color and alpha channel I would like to MODULATE those textures using alpha channel along, so the second texture should be MODULATED with first one only where alpha channel allows it. I knwo how to BLENDTEXTUREALPHA 2nd on 1st, but it's not MODULATION I get only adding, so the color from 2nd texture almost completely overdraws color from 1st texture. Is there a way to do it using only SetTextureStage() ? I have no time to learn shaders right now :-) Maybe some other time. Thanks
Namethatnobodyelsetook
Namethatnobodyelsetook
I'm going to use a sort of "stage, op, args" notation to save myself some time here. Hopefully it's clear.

0C, selectarg1, texture // get diffuse texture color
0A, selectarg1, current // select something, as we can't have no alphaop

1C, modulate, texture, current // Mix light with diffuse
1A, selectarg1, texture // get alpha mask
1, resultarg, temp

2C, blendcurrentalpha, current, temp // blend between current(stage0) and temp(stage1)
2A, selectarg1, current

3C+3A disable

After drawing ensure you change stage1 resultarg back to current so future effects aren't affected.

Also, as a correction to what you said, Blend*Alpha isn't an add, it's a lerp... a transition from arg1, to arg2 by the blend percentage.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.