Sign in to follow this  

texture masking

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

I need to create partial transparency in a texture. I can do it perfectly with texture masking, but this is really slow, since i have to turn off my vertex shaders, and draw the shapes with two different textures. Is there a faster way to do this? I would think there would be an easier way, like only draw pixels that arnt a certain color on texture, does this exist?

Share this post


Link to post
Share on other sites
Ok firstly my shader knowledge has only ever extended as far as a couple of lighthouse tutorials accumulating to about 2 hours experience, however I think I know enough to answer your question. ( If not then this is my disclaimer :P )

Basically you have two textures on your object which you pass to your shader. One which is your objects actual texture and the second is a black and white texture, black depicting the areas you dont want to draw and white depicting the areas that you do.

Then in your fragment shader you look up the texture color from your second texture at your current pixel if it is black (0,0,0) you just 'continue;' in your shader program and dont draw anything for the current pixel.

This is essentially an 'Alpha channel' as was described in the last post.

Hope this helps! :)

Share this post


Link to post
Share on other sites
Quote:
Original post by chipmeisterc
Ok firstly my shader knowledge has only ever extended as far as a couple of lighthouse tutorials accumulating to about 2 hours experience, however I think I know enough to answer your question. ( If not then this is my disclaimer :P )

Basically you have two textures on your object which you pass to your shader. One which is your objects actual texture and the second is a black and white texture, black depicting the areas you dont want to draw and white depicting the areas that you do.

Then in your fragment shader you look up the texture color from your second texture at your current pixel if it is black (0,0,0) you just 'continue;' in your shader program and dont draw anything for the current pixel.

This is essentially an 'Alpha channel' as was described in the last post.

Hope this helps! :)


isnt that exactly what texture masking is? Im using the technique form Nehe tut 20, http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=20. Isnt that the alpha channel metbod? The problem i am having with it is it is slow since i have to bind the mask and bind the texuture for very triangle that i am drawing. I tried to make it faster by drawing all of the masks, then drawing all of the texture on top to minimize binding time, but the overlaping part mess up. Is there a faster method to do this? or am i jsut doing it wrong?

Also i am doing this in 3d, and the tutorial is for 2d, so is there anything different I have to do?

Share this post


Link to post
Share on other sites

This topic is 3698 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this