Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: subtractive blending in java 2d

  1. #1
    Junior Member
    Join Date
    Jun 2010
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default subtractive blending in java 2d

    hi. I am trying to do lightmaps in JOGL. i plan to have the textures and lightmaps stored in Graphics2D or BufferedImage objects . the program will then subtract the value of each component in the map from the texture. (i'm using subtraction because black will represent full lighting.). How do i do this?

    Thanks in advance!!


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,722
    Thanks
    45
    Thanked 1,974 Times in 1,948 Posts

    Default Re: subtractive blending in java 2d

    Nothing that you wrote relates to what I know of java programming. Can you describe your problem in programming terms vs your application terms. Programs consist of instructions and data. Data is in bytes.
    Last edited by Norm; June 14th, 2010 at 08:24 PM.

  3. #3
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: subtractive blending in java 2d

    JOGL is an OpenGL binding that allows Java to access OpenGL's C defined methods. Unfortunately, I haven't worked too much with either JOGL or OpenGL (at least, not successfully). It seems like what you want, though, is an Alpha channel, right? This way, whatever's closest to 0 alpha is transparent (and therefore lets all lighting through at) and as it gets closer to max alpha (1.0f or 0xff, which ever format you're using) it becomes opaque so no light comes through.

    If you put the specified values into BufferedImages, you can use AlphaComposites and the Graphics2D to combine the two images.

    I have some examples of doing this here, but it's a little messy (I'd recommend looking at the first code block, it's a little clearer what's happening)

  4. #4
    Junior Member
    Join Date
    Jun 2010
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: subtractive blending in java 2d

    say my lightmap is image A, and the texture is image B. Black will mean full light (no color subtracted). i want the red componont form image A to be subtracted form image B, and the same thing with the green and blue components. this should allow me to do colored lights. A blue surface with a red light shined on it should show up black. with an alpha channel it would show up purple. that is not what i want.

Similar Threads

  1. blending in java2d
    By deepthought in forum Java Theory & Questions
    Replies: 1
    Last Post: June 11th, 2010, 01:45 PM