Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

NotTaxes

Alpha channels on the fly

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

Is there a way to create and assign an alpha-mask to a texture on the fly? If I load the texture using CreateTextureFromFileEx I can specify that I want to load Alpha, but is there a way I could do it just before I render? Ideally I would like to have, for example, two alpha patterns (one chequered and one just standard diagonal stripes). Then I want to render the polygon with the diagonal stripes transparent normally, but then with the chequered transparency when I move the mouse over it. Any ideas? ''Doing the impossible is kind of fun'' - Walt Disney

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
is this d3d or opengl?

i think the only(fast) way to do it would be to have two textures, and switch them, or two alpha textures and switch the one you are blending with it

Share this post


Link to post
Share on other sites
Using D3D... but the problem with using multiple textures is the memory thingy. I want to use this technique to show high-lights when I move over the polygon. If I''ve got 50 textures, then with that method I''d need to actually have 100... bit of a memory concern.

''Doing the impossible is kind of fun'' - Walt Disney

Share this post


Link to post
Share on other sites
if each texture is going to have it''s own way of being highlighted,
then each texture will need it''s own highlighted texture as said before
but instead of using a texture to highlight why not just draw a wire frame thing(box) around the object to highlight
or
if you use the same texture to highlight everything just draw a primitive containing the highlight texture just in front of the polygon

Share this post


Link to post
Share on other sites
Why not just use additive alpha blending on the selected object? It would set it apart nicely...

Share this post


Link to post
Share on other sites
What Moe is talking about is drawing the triangle twice (overtop of itself), and adding the color values (set with certain render states), to produce a final triangle 2x as bright as the original

Share this post


Link to post
Share on other sites
OIC. That''s interesting, but it doesn''t give the required effect. I''m really trying to apply an Alpha channel to a texture on demand. Thanks for the idea though.

''Doing the impossible is kind of fun'' - Walt Disney

Share this post


Link to post
Share on other sites
Sorry, posted the last before finishing.

What I want to do is have, for example, two alpha-channeled bitmaps called AlphaA and AlphaB. Then if I have a normal texture (tex1) I would like to say

Draw Tex1 with AlphaA or
Draw Tex1 with no Alpha or
Draw Tex1 with AlphaB

I figure it must be possible using TextureStageState, but I just don''t know how... something like

SetTexture 0, AlphA
SetTexture 1,Tex1

DrawPrimitive xyz

and with the correct texturestagestates this should work. I have tried using this, but the Alpha thing gets messed up in the second texture stage and I end up with a texture that has big black blocks in it, instead of big transparent blocks.


''Doing the impossible is kind of fun'' - Walt Disney

Share this post


Link to post
Share on other sites
I am having a problem with alpha blending too. when I tried to change the alpha values using SetTextureStage, it was putting a blue effect over all the other objects, so what it was doing was placing my texture, partially transparent, over the other objects. This was fine, because the object was supposed to be glass and have much the same effect. My problem is I can''t get the actual sheet of glass to be semi-transparent. Can anyone point me in the right direction?

Share this post


Link to post
Share on other sites

  • 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!