Jump to content
  • Advertisement

Archived

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

XOR, OR, AND, and opacity without addition or multiplication

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

The title says it all, I think. I''m using DirectDraw7 and Visual Basic 6 (My C/C++ skills are rather limited, but I''m working to change that!). Using ROP effects (Binary logic: OR, XOR, and AND) with a BltFX blit, is there a way, through multiple blits to offscreen surfaces, etc, to do a rough equivalent to additive or multiplative blending? My experiments so far have involved a grayscale bitmap with a radial gradiant (black in center, white at edges) which I have been trying to make act as a simple soft shadow. Using OR, I have managed to get the effect I want, but only on fully saturated surfaces. On other surfaces, I get stange ring effects. Would there be some way to, perhaps, use a grayscale bitmap as an opacity mask, and then blit an image on top, or something of that nature? I''m having a lot of trouble "thinking in binary," and haven''t been able ocome up with any good solutions. Is what I''m aiming at even do-able, or will I need to use GetLockedArray and manually change each pixel? Because, if so, I know VB won''t be up to the task, and I''l have to learn some more C++ to write a DLL to do that. And even then, even if I do it entirely with Inline ASM, it''ll still be slow. So I''m looking for answers in binary logic. Or I could just fake it with "every-other-pixel" or diffuse style pseudo-transparency. If anyone has any ideas or suggestions, I would be most appreciative!

Share this post


Link to post
Share on other sites
Advertisement
The easiest way to handle eliminating the multiplication is to do it all beforehand in a lookup table. I just did a post the other day on this and you can find it here: http://www.gamedev.net/community/forums/topic.asp?topic_id=40017

It uses all ORing, shifting, and array offsets to lookup the data so the actual mechanics of doing the opacity is right quick. The only slow part, and this is the killer, is the 2 reads and 1 write to video memory. My framerate drops from 75fps to about 6.5 currently.

Needless to say, I''m still working on it. I''m also trying to work on an idea I had that''s close to what you proposed about blitting to a workspace of sorts. If I can get it to work, I''ll post the code here.

random

---
Wait, you mean I have to actually... THINK?!

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!