Blue Matrix screensaver (and howto) - Tree of Souls - An Avatar Community Forum
Tree of Souls - An Avatar Community Forum
Go Back   Tree of Souls - An Avatar Community Forum » General Forums » Development

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 08-09-2010, 03:36 AM
Sight Unseen's Avatar
Karyu
Sight Unseen is a perfectly ordinary magical unicorn.
 
Join Date: Mar 2010
Location: Silicon Valley
Posts: 1,349
Cool Blue Matrix screensaver (and howto)

Everything on my PC is blue. I started putting it together right around the time I first saw Avatar, and then the reason for it being blue changed completely, I sort of dedicated it to my love of the Na'vi I guess, idk. Well, the GTK theme came together, I installed 4 blue LED 120mm fans in the PC, and I went crazy and used like half a bag of blue LEDs from digikey replacing LEDs on my monitors, computer, optical mouse, keyboard, xbox (*grumble* smd, lots of work), router, switch, server, speakers... the list goes on. The one thing I needed was a decent blue screensaver that has lots of movement, because my TV is Twist Nematic LCD based, and will get imprinted with whatever is displayed on it for more than about an hour. So a slideshow of Neytiri was out of the question (burn in... but mostly parent disapproval because they think Neytiri is basically softcore pron ...anyways) I have to lock my screen with it.

So something subtle... The Matrix. Not Avatar based, but decent anyway. Then I went a step further... The Matrix, In Blue. So I got the source for xscreensaver-5.10 from the site and started reverse-engineering.

Keep reading... I'm getting to the code. If you want to do this, go ahead and download the source here and untar. http://www.jwz.org/xscreensaver/xscr...er-5.11.tar.gz

xscreensaver includes two different versions of "The Matrix", but I am Interested in the 3D one, glmatrix, with camera rotation and a few other goodies. So after a few hours, I found that the color of the screensaver is controlled by 2 different things.

The file ./hacks/images/matrix3.xpm is split into the textures for the matrix glyphs. and is a color .xpm at 512x598, with no transparency. Now I know what you're thinking. Just alter the color of the image in GIMP/Photoshop/Whatever and you're done! Yes, that's one of the steps, switch the blue and green channels using your favorite image manipulation software (I use the GIMP).

It's more complicated than that. Since the image has no alpha channel, the code is really clever. It takes the value for the green channel and uses it for alpha. If you were to compile the source code right now, your glyphs would be almost invisible.

In the source file ./hacks/glx/glmatrix.c, this action is directed by this code:
Quote:
rpos = 0, gpos = 8, bpos = 16, apos = 24;

for (y = 0; y < xi->height; y++)
for (x = 0; x < xi->width; x++)
{
unsigned long p = XGetPixel (xi, x, y);
unsigned char r = (p >> rpos) & 0xFF;
unsigned char g = (p >> gpos) & 0xFF;
unsigned char b = (p >> bpos) & 0xFF;
unsigned char a = ~g;
g = 0xFF;
p = (r << rpos) | (g << gpos) | (b << bpos) | (a << apos);
XPutPixel (xi, x, y, p);
}
}
In the bold lines, change "unsigned char a = ~g;" to "unsigned char a = ~b;", and "g = 0xFF;" to "b = 0xFF;"; save and exit. That's it. a 2 character change, and now the code uses the blue channel value to control alpha when loading textures into graphics ram instead of green.

now for compiling, you know the drill.
sudo apt-get build-dep xscreensaver
cd into the source
./configure
make
hold breath
sudo make install
drink some kind of cold beverage

Results: (not in full screen here, it will be full screen when installed)


All this was done in Ubuntu Lucid 10.04, amd64. If anyone wants it, I could upload a precompiled binary and source code to go with it, but that would be a tad overkill for such a small change.

Last edited by Sight Unseen; 08-09-2010 at 08:22 AM.
Reply With Quote
  #2  
Old 08-09-2010, 04:08 AM
Patrice Maire's Avatar
Taronyu
Patrice Maire deals with skxawngs all day.
 
Join Date: Jun 2010
Location: San Diego, CA
Posts: 429
Default

Very cool!!!!
__________________
Reply With Quote
  #3  
Old 08-09-2010, 08:30 PM
Loverofnature's Avatar
Tsamsiyu
Loverofnature has no status.
 
Join Date: Apr 2010
Location: Body: Denmark Spirit: Pandora
Posts: 712
Send a message via MSN to Loverofnature Send a message via Skype™ to Loverofnature
Default

can i get this matrix screensaver in Mac/windows?
__________________




"Free your Mind" - Morpheus
Reply With Quote
  #4  
Old 08-09-2010, 08:50 PM
Human No More's Avatar
Toruk Makto, Admin
Human No More has no status.
 
Join Date: Mar 2010
Location: In a datacentre
Posts: 11,748
Default

Impressive, I like blue

I'll have to take a look at it and see if I can get it to work in windows when I'm a bit less tired.

Edit: quick look later and I doubt it... I'll put it on my Linux install though, not that that really gets that much use
__________________
...
Reply With Quote
  #5  
Old 08-10-2010, 12:08 AM
Eltu's Avatar
Administrator
Eltu is home.
 
Join Date: Mar 2010
Location: Eugene, OR
Posts: 2,418
Default

Ubuntu ftw.
__________________
Reply With Quote
  #6  
Old 08-10-2010, 01:07 AM
stdout's Avatar
King of Output Streams
stdout .
 
Join Date: Mar 2010
Posts: 247
Default

Quote:
Originally Posted by Eltu View Post
Ubuntu ftw.
Isn't it great I'll have to reinstall Windows to play Crysis again, but for the foreseeable future it'll be Ubuntu exclusively on my PC

As for the screensaver, once I've learned C I'll take a look at the code myself.
__________________
Reply With Quote
  #7  
Old 08-10-2010, 02:42 AM
X.,.Pandora.,.X's Avatar
Tsulfätu
X.,.Pandora.,.X Is finally home
 
Join Date: May 2010
Location: North Carolina
Posts: 1,580
Default

well....i was going to do it, but idk half of what you posted...
__________________
Reply With Quote
  #8  
Old 08-10-2010, 04:34 PM
Gunny's Avatar
Karyu
Gunny DUBSTEP!!!
 
Join Date: Mar 2010
Location: Denton, TX
Posts: 1,488
Send a message via Skype™ to Gunny
Default

^^ditto! hahahahaha went right over my head pretty much XD
__________________

J Sully: "gunnish is a special accent only spoken by Gunny!"
Kestor: "Gunnish turns Zoe on."
Reply With Quote
  #9  
Old 08-10-2010, 10:14 PM
Sight Unseen's Avatar
Karyu
Sight Unseen is a perfectly ordinary magical unicorn.
 
Join Date: Mar 2010
Location: Silicon Valley
Posts: 1,349
Default

Quote:
Originally Posted by X.,.Pandora.,.X View Post
well....i was going to do it, but idk half of what you posted...
If you use linux and have a dual core processor, i have the linux equivalent of exe's if you want them, premodded.
Reply With Quote
  #10  
Old 01-20-2011, 06:15 AM
Sight Unseen's Avatar
Karyu
Sight Unseen is a perfectly ordinary magical unicorn.
 
Join Date: Mar 2010
Location: Silicon Valley
Posts: 1,349
Default

I just found a similar, really, really similar tutorial here. It appears someone beat me to it. (note the date)
The Matrix Is Blue | Lalit Kapoor I tried doing it this way first, but on my 6500k monitor, the glyphs still looked rather green because the green channel is still the brightest in the texture file. In addition, green still controls the alpha channel, which may cause problems later. If you wanted your glyphs, say, hot pink, you would replace the alpha = green line with some simple math to find the average of all three rgb values, and use that for alpha. You can also do some crazy things with the xpm file, like changing the characters to binary, chinese, etc. Just adding some thoughts to this old tutorial.

Also you'll notice I posted a comment there. Oops, 2010, not 2011. No edit button .

Last edited by Sight Unseen; 01-20-2011 at 06:36 AM.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



Visit our partner sites:

      pandoraworld.ru



All times are GMT +1. The time now is 08:55 PM.

Based on the Planet Earth theme by Themes by Design


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Content Relevant URLs by vBSEO ©2011, Crawlability, Inc.
All images and clips of Avatar are the exclusive property of 20th Century Fox.