generating fire effect palettes?

Started by
2 comments, last by En3my 21 years, 1 month ago
Hi, I couldn''t decide whether to post this here on in the beginner''s section, cause it''s most probably not hard at all. I have just finished coding a 2D fire effect, and I need a good palette for it to look good. Since recently begun working with palettes I''m not that good on manipulating colors, so I came here. I want to create a 256 color look-up table, where 0 (black) is cold and 255 (white) represent very hot. In between I want a spectrum from red to yellow. I never were any good at painting and mixing colors as you can see, so I need some help setting up the look-up table init code (a 256 byte char array). Thanks!
Advertisement
It sounds like you want a palette representing blackbody emmission (the thing that goes from black to red to yellow to white). This palette is based on the color of iron as it is heated.

I know that Photoshop has a built-in blackbody palette; you could export it from there. Alternatively, google for some info about blackbody radiation and build your own. Alternatively, just fake your own by dividing the palette into 3 pieces and giving each a gradient.

But... but that''s what HITLER would say!!
this might do it (my syntax may be off):


    byte pallete[256][3];int divide = 255/3;//black to redfor(int i = 0; i < divide; i++) { palette[i][0] = i*3; palette[i][1] = 0; palette[i][2] = 0;}// red to yellowfor(int i = divide; i < divide * 2; i++) { palette[i][0] = 255; palette[i][1] = (i-divide)*3; palette[i][2] = 0;}//yellow to whitefor(int i = (divide*2); i < 256; i++) { palette[i][0] = 255; palette[i][1] = 255; palette[i][2] = (i - (divide *2))*3}  


and no i did not test this, but it seems right, i know the array is 256 x3, but i dont see how you can get the color red or yellow or anything for that matter in only one byte. Perhaps i do not understand palettes at all in which case you can ignore this. Otherwise,given an index 0-255, you will get black->red->yellow->white from the above.
[/source]

[edited by - mstein on March 4, 2003 12:59:05 PM]
Yes, you are right - it''s a 256*3 array. Thanks for giving me the algorithm! I will try it out right away! Blackbody emission sounds really interesting, I will take a look at that as well! I will go for the fake for a start, but I will look into the blackbody emission for sure! I will check back here a bit later to see if someone else comes here to share their knowledge!

This topic is closed to new replies.

Advertisement