User Tag List

Results 1 to 7 of 7

Thread: New INK EFFECT algorithm...Better than Additive

  1. #1
    No Products Registered

    Join Date
    Jan 2008
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    New INK EFFECT algorithm...Better than Additive

    I've written an algorithm that works better than additive blending for backgrounds with light and dark areas.

    int R1 = (red channel of object pixel)
    int G1 = (green channel of object pixel)
    int B1 = (blue channel of object pixel)

    int R2 = (red channel of background pixel)
    int G2 = (green channel of background pixel)
    int B2 = (blue channel of background pixel)

    int R3 = (new red channel for pixel)
    int G3 = (new green channel for pixel)
    int B3 = (new blue channel for pixel)

    float alpha = R1 + G1 + B1;
    int max = 0;
    if (R1 > max) {
    max = R1;
    }
    if (G1 > max) {
    max = G1;
    }
    if (B1 > max) {
    max = B1;
    }
    R1 = R1 / max * 255;
    G1 = G1 / max * 255;
    B1 = B1 / max * 255;

    R3 = (R1 * alpha + R2 * 255) / (alpha + 255);
    G3 = (G1 * alpha + G2 * 255) / (alpha + 255);
    B3 = (B1 * alpha + B2 * 255) / (alpha + 255);

    I tested this algorithm with a basic object:
    Algorithm Test

    As you can see the lines do not tint everything to white, but rather toward a fully saturated version of that color.

    If you have the ability to do so, please put this in the next version of HWA, it will increase the quality of my games drastically.

  2. #2
    No Products Registered

    Join Date
    Jan 2008
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: New INK EFFECT algorithm...Better than Additive

    I did make a mistake on the algorithm...
    after this bit

    if (B1 > max) {
    max = B1;
    }

    write

    if (max == 0) {
    max = 1;
    }

  3. #3
    No Products Registered

    Join Date
    Jul 2006
    Location
    Texas
    Posts
    1,225
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: New INK EFFECT algorithm...Better than Additiv

    It's just the 'screen' effect.

    EDIT: And yes in a later version you will be able to do this, because currently you cannot get the background pixel, but in the future (next build?) you will be able to.

  4. #4
    Animaniacs
    Guest

    Re: New INK EFFECT algorithm...Better than Additiv

    I have been having problems with the additive ink effect in my game also... the top layer using this effect gets lighter on lighter backgrounds and darker on darker backgrounds. This algorithm looks like the perfect fix blending the layers more like they would in real life.

    Check out the link to the Algorithm Test.

  5. #5
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Jun 2006
    Location
    Darlington, UK
    Posts
    3,298
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: New INK EFFECT algorithm...Better than Additiv

    Your example image looks a lot like you just made the top image 50% transparent...

    EDIT: Ah I see. It takes the saturation of the colour, sets it to 1 and sticks the original saturation (/2) in the alpha channel. So 100% red becomes 100% red 50% alpha, 50% red becomes 100% red 25% alpha, etc.

  6. #6
    Clicker Multimedia Fusion 2
    BrandonC's Avatar
    Join Date
    Jun 2006
    Location
    PA, USA
    Posts
    931
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: New INK EFFECT algorithm...Better than Additiv

    So how exactly does one go about using this? Is there a shader for download or something?

  7. #7
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Jun 2006
    Location
    Darlington, UK
    Posts
    3,298
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: New INK EFFECT algorithm...Better than Additiv

    No there isn't

Similar Threads

  1. Additive Blending in iOS
    By SevenSails in forum iOS Export Module Version 2.0
    Replies: 7
    Last Post: 13th December 2012, 05:13 PM
  2. Additive blend
    By scaneider in forum Hardware Accelerated Runtime
    Replies: 2
    Last Post: 12th October 2012, 10:34 PM
  3. Overlay Blur effect algorithm?
    By neat_Kliker2 in forum Multimedia Fusion 2 - Technical Support
    Replies: 0
    Last Post: 16th August 2008, 12:09 PM
  4. Active with Additive blending question
    By mobichan in forum Multimedia Fusion 2 - Technical Support
    Replies: 6
    Last Post: 8th June 2008, 02:26 PM
  5. HWA Additive Blending issue
    By Bruto in forum File Archive
    Replies: 5
    Last Post: 20th January 2008, 05:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •