Jump to content
  • Advertisement
Sign in to follow this  
xerodsm

Blending Question

This topic is 3616 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 trying to blend two images, where one image is like a mask, and represents what I want to be drawn on the screen, and the other image represents a pattern of what I want to be drawn as the texture for the mask. For example. The mask will keep it's position and coordinates on the screen, but the pattern texture will move it's texture coordinates around so it looks like the image is flowing. Here is an example of what I'm talking about: Mask - Pattern - Result- ( I want it so I can change the tex coords on just the pattern like this ) Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
Well, you need multitexturing (or atleast 2 texture coords), one for your mask and one for your animated texture. Then you need to calculate your final output color in a shader so that final_color.rgb=color_texture(1. texture coord) and final_color.a=mask(2. texture coord). Now you could either use blending (more expensive) or alpha testing (better in this case) to mask your animated texture.

blending:
blend_source_mode = source_alpha
blend_dest_mode = inverse_source_alpha

alpha testing:
enable alpha testing, set your reference alpha value to 0.5 and the comparision operation to greater_equal.

--
Ashaman

Share this post


Link to post
Share on other sites
Well, you don't need shaders.

Just provide two texture coordinates per vertex and assign each texture unit the corresponding coordinate set.

You could also employ a texture matrix to transform the texture coordinates for a specific texture unit (e.g. scaling/translating).

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!