The new forums will be named Coin Return (based on the most recent vote)! You can check on the status and timeline of the transition to the new forums here.
The Guiding Principles and New Rules document is now in effect.

Java shadow rendering

HyoukoHyouko Registered User regular
edited March 2007 in Help / Advice Forum
Time for my bi-monthly Java question, folks. I'm trying to put together a 2D lighting system in Java, by way of a black BufferedImage overlay with selected bits of its alpha channel left clear where the light's supposed to be shining. Trouble is, I can't figure out how to render to the alpha channel - setting pixels on the WritableRaster from the getAlphaRaster() method doesn't seem to do anything, and anyhow I'd really rather be writing to the channel with full-blown images.

My alternative is to to draw the shadows rather than the lights, which in theory I could do (I know how to render with an AlphaComposite thingummy). The trouble here is that the game I'm working on for this is probably going to have Doom Three Darkness (tm) - it'll be much more efficient to render the light than the shadow (particularly considering how the light will have weird shapes and it'll be much easier to draw the weird shapes than it will be to draw everything that is not the weird shapes). If there's an option to invert the alpha channel when compositing, that'd work, too.

--
All that is left to me is the sound of the snow underfoot.
Hyouko on

Posts

  • HyoukoHyouko Registered User regular
    edited March 2007
    ...and as usual I eventually figured it out myself. You can overwrite an image's alpha channel by drawing to it with the an AlphaComposite.SRC composite, in case anyone's curious.

    Hyouko on
    --
    All that is left to me is the sound of the snow underfoot.
Sign In or Register to comment.