Page 1 of 3 123 LastLast
Results 1 to 10 of 23

Thread: Custom Compiz color filter

  1. #1
    Join Date
    Aug 2007
    Location
    Bangkok, TH
    Beans
    410

    Custom Compiz color filter

    Hi all!

    I just wanted to share with the community a color filter for the Color Filter plugin in Compiz that I had thought of and made, by looking at the sample filters. I used to love the negative plugin, which inverts the colors of the screen. I use it in the nighttime when the screen is just too bright for reading text or for coding. I prefer white text on a black background and maybe that's just me. But for those of you use the Negative plugin for the same reason as I do, read on!

    What I don't like about the Negative plugin is that it also inverts the colors and it makes it hard to recognize some icons, such is the status icons in your IM client (green for online, red for busy, etc). So I've made a plugin for the Color Filter plugin (not the Negative plugin) which inverts black and white but keeps the original color. Here is the code for the filter:

    Code:
    !!ARBfp1.0
    TEMP temp, neg, red, green, blue;
    TEX temp, fragment.texcoord[0], texture[0], RECT;
    RCP neg.a, temp.a;
    MAD temp.rgb, -neg.a , temp, 1.0;
    MUL temp, temp.a, temp;
    ADD green, temp.r, temp.b;
    ADD red, temp.g, temp.b;
    ADD blue, temp.r, temp.g;
    MUL red, red, 0.5;
    MUL green, green, 0.5;
    MUL blue, blue, 0.5;
    MOV temp.r, red;
    MOV temp.b, blue;
    MOV temp.g, green;
    MUL temp, fragment.color, temp;
    MOV result.color, temp;
    END
    To use this, run the following commands:
    Code:
    cd /usr/share/compiz/filters/
    sudo gedit nightmode
    Copy and paste the code for the filter into the text editor, save it and close it.

    Now open ccsm (CompizConfig Settings Manager) and turn on the Color Filter. Set your preferred keybindings and click New. Find the filter file in /usr/share/compiz/filters.

    That's it.

    I have attached a screenshot of the result.

    Please comment and tell me what you think and if you have better code to get the same result, let me know! After all, I didn't know what I was coding. It was trial-and-error and took me about 50 minutes to get this.
    Attached Images Attached Images

  2. #2
    Join Date
    Mar 2007
    Beans
    24
    Distro
    Kubuntu 9.10 Karmic Koala

    Re: Custom Compiz color filter

    Very cool! Thanks for sharing.

    How did you figure out how to write it, though? I haven't found any documentation on the scripting language.

  3. #3
    Join Date
    Aug 2007
    Location
    Bangkok, TH
    Beans
    410

    Re: Custom Compiz color filter

    Quote Originally Posted by BionicSeahorse View Post
    Very cool! Thanks for sharing.

    How did you figure out how to write it, though? I haven't found any documentation on the scripting language.
    You're welcome!

    I found this documentation:
    http://wiki.compiz.org/Plugins/Colorfilter
    which links to
    OpenGL Fragment Program, the language used for the filters.

    For the most part, it was trial-and-error. I looked at the negative filter and the "swapping colors" filters for reference.

  4. #4
    Join Date
    Nov 2009
    Location
    beijing, china
    Beans
    8
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: Custom Compiz color filter

    How would one only invert non-menu elements of a window?

  5. #5
    Join Date
    Aug 2007
    Location
    Bangkok, TH
    Beans
    410

    Re: Custom Compiz color filter

    Quote Originally Posted by baisong View Post
    How would one only invert non-menu elements of a window?
    It's not possible with this plugin. I'm not sure that it's even possible to do it with compiz.

  6. #6
    Join Date
    Aug 2007
    Location
    Bangkok, TH
    Beans
    410

    Re: Custom Compiz color filter

    I have made some changes to the filter. This new one has better contrast, and I've changed the way the color is calculated.

    Code:
    !!ARBfp1.0
    TEMP temp, mean, diff;
    TEX temp, fragment.texcoord[0], texture[0], RECT;
    MUL mean, temp.r, 0.3;
    MAD mean, temp.g, 0.59, mean;
    MAD mean, temp.b, 0.11, mean;
    MAD diff, -2.0, mean, 1.0;
    ADD_SAT temp.r, temp.r, diff;
    ADD_SAT temp.g, temp.g, diff;
    ADD_SAT temp.b, temp.b, diff;
    MUL temp, fragment.color, temp;
    MOV result.color, temp;
    END
    ***Note: There is still a problem with filtering the window decorations, so please turn that off in the Color Filter plugin. The alpha of the shadow from the window decoration seems to get flipped.

  7. #7

    Re: Custom Compiz color filter

    Anyone knows how to add the colorfilter to startup? So I wouldn't need to press <super>+d every time I turn the pc on?

  8. #8

    Re: Custom Compiz color filter

    Never mind solved adding to startup a scrip with the following code

    Code:
    #!/bin/bash
    
    sleep 20s && dbus-send --type=method_call --dest=org.freedesktop.compiz /org/freedesktop/compiz/colorfilter/allscreens/toggle_screen_key org.freedesktop.compiz.activate string:'root' int32:`xwininfo -root | grep id: | awk '{ print $4}'` &
    I'm working with a fake RGBA color filter:
    Code:
    !!ARBfp1.0
    TEMP texv, rep;
    TEX texv, fragment.texcoord[0], texture[0], RECT;
    MOV rep, {0.196078431, 0.196078431, 0.192156863};
    SUB rep, rep, texv;
    ABS rep, rep;
    MAX rep.b, rep.b, rep.r;
    MAX rep.b, rep.b, rep.g;
    SUB rep.b, rep.b, 0.0001;
    CMP rep.b, rep.b, 0.9, 1;
    MUL texv, texv, rep.b;
    MOV result.color, texv;
    END
    but I'd like to filter more than 1 color... Is there a way to load more than one filter at once in colorfilter? Or anyone knows how to change the code above to add more colors?

  9. #9
    Join Date
    May 2010
    Beans
    3
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Custom Compiz color filter

    Just to share a little bit as well I added two filters to my setup. Both of them are red based, very helpful for when you want to keep your night vision intact, like when you are out at sea and have the night watch. Of course they even work on my Windows XP VirtualBox so you would be able to use those win programs you might miss.

    First one is night-vision-negative

    Code:
    !!ARBfp1.0
    TEMP temp, neg;
    TEX temp, fragment.texcoord[0], texture[0], RECT;
    RCP neg.a, temp.a;
    MAD temp.rgb, -neg.a, temp, 1.0;
    MUL temp.rgb, temp.a, temp;
    MUL temp, fragment.color, temp;
    SUB temp.gb, temp, temp;
    MOV result.color, temp;
    END
    Second one is just night-vision, it is slightly brighter
    Code:
    !!ARBfp1.0
    TEMP temp, neg;
    TEX temp, fragment.texcoord[0], texture[0], RECT;
    RCP neg.a, temp.a;
    MUL temp.rgb, temp.a, temp;
    MUL temp, fragment.color, temp;
    SUB temp.gb, temp, temp;
    MOV result.color, temp;
    END
    Thanks Compiz guys, great code!!

  10. #10
    Join Date
    Mar 2008
    Beans
    14
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: Custom Compiz color filter

    Wow, the documentation on this is intense.

    I am looking for a filter that filters all blue light out. Kind like through a red or amber lense.

    I am not sure if this coincides with night vision BUT when blue light hits your eyes it basically tells your brain not to produce melatonin. I have been using blue blockers sunglasses (remember those?) at night to use my computer to not mess up my sleep. The white in the text using the above filters has to much blue light in the white.

    Any help would be great. Tried a few things.

    The best seems to be the first one by jsgoodall. Thank you.
    Last edited by yahooshua; September 30th, 2010 at 08:22 AM.

Page 1 of 3 123 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

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