Alpha channels on the fly

Started by
10 comments, last by NotTaxes 22 years, 8 months ago
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
'Doing the impossible is kind of fun' - Walt Disney
Advertisement
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
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
'Doing the impossible is kind of fun' - Walt Disney
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
Why not just use additive alpha blending on the selected object? It would set it apart nicely...
Sorry, can you explain that a bit?

''Doing the impossible is kind of fun'' - Walt Disney
'Doing the impossible is kind of fun' - Walt Disney
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
"This is stupid. I can't believe this! Ok, this time, there really IS a bug in the compiler."... 20 mins pass ..."I'M AN IDIOT!!!"
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
'Doing the impossible is kind of fun' - Walt Disney
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
'Doing the impossible is kind of fun' - Walt Disney
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?

This topic is closed to new replies.

Advertisement