Here's the thread:
http://www.coniserver.net/ubbthreads/showflat.php?Cat=&Board=UBB3&Number=499869That code in the thread is almost identically to what is below, except it included the resizing locally, and the new version includes an experimental flickering alpha effect. I use the new panelRefresh from this thread, now. I actually used to use 6 640x480 panels and scaled up. The memory hit was much lower, however it didn't look as nice at higher resolutions because of pixelation. I only recently changed to 1600x1200 bitmaps for it. I may change back to the lower resolution, though. I don't think I ever used the filter flag with it, because I was using it before we had a filter flag and never bothered to use it. I think I'll test it out with the smaller images and see what it looks like with filter turned on.
If you've played the Silent Hill games, you'll be familiar with what this is for. It adds subtle filmgrain appearance to the view. It rapidly switches from bitmap to bitmap and it makes it look like an old movie. It can also be done via shader, but I remember the version used in 3DGS game project "The Kid" slowing down the framerate quite a bit compared to the old school method below(which The Kid also used as an alternative and resulted in better fps, plus I thought it looked better).
Code:
panel filmGrainPanel
{
layer = 200;
pos_x = 0;
pos_y = 0;
flags = overlay,filter;
}
var grainFlag;
var grainToggle = 1;
bmap grain1 = <grain1.tga>;
bmap grain2 = <grain2.tga>;
bmap grain3 = <grain3.tga>;
bmap grain4 = <grain4.tga>;
bmap grain5 = <grain5.tga>;
bmap grain6 = <grain6.tga>;
function filmGrain()
{
panelRefresh(filmGrainPanel);
grainFlag = 1;
while(grainToggle == 1)
{
filmGrainPanel.alpha = random(100); filmGrainPanel.alpha = clamp(filmGrainPanel.alpha, 20, 100);
filmGrainPanel.bmap = grain1; filmGrainPanel.visible = on; wait(-0.09); filmGrainPanel.visible = off;
filmGrainPanel.bmap = grain2; filmGrainPanel.visible = on; wait(-0.09); filmGrainPanel.visible = off;
filmGrainPanel.alpha = random(100); filmGrainPanel.alpha = clamp(filmGrainPanel.alpha, 30, 70);
filmGrainPanel.bmap = grain3; filmGrainPanel.visible = on; wait(-0.09); filmGrainPanel.visible = off;
filmGrainPanel.alpha = random(100); filmGrainPanel.alpha = clamp(filmGrainPanel.alpha, 30, 90);
filmGrainPanel.bmap = grain4; filmGrainPanel.visible = on; wait(-0.09); filmGrainPanel.visible = off;
filmGrainPanel.alpha = random(100); filmGrainPanel.alpha = clamp(filmGrainPanel.alpha, 30, 60);
filmGrainPanel.bmap = grain5; filmGrainPanel.visible = on; wait(-0.09); filmGrainPanel.visible = off;
filmGrainPanel.bmap = grain6; filmGrainPanel.visible = on; wait(-0.09); filmGrainPanel.visible = off;
}
filmGrainPanel.visible = off; bmap_purge(grain1); bmap_purge(grain2); bmap_purge(grain3); bmap_purge(grain4); bmap_purge(grain5); bmap_purge(grain6); grainFlag = 0;
}
EDIT: Reducing to 640x480 reduced it to around 6MB. Using TGAs instead of PCX doubled it to 12MB but looks much better when scaled, so 6 640x480 TGA files for the effect. It requires an IF check in the panelRefresh to accomodate the reduced resolution(since the baseline is 1600x1200). Since, this effect is a series of noise screens, I can get away with scaling up and maintaining quality:
Code:
if(pnl == filmGrainPanel)
{
pnl.scale_x = screen_size.x / 640;
pnl.scale_y = screen_size.y / 480;
}
else
{
pnl.scale_x = screen_size.x / maxRes.x;
pnl.scale_y = screen_size.y / maxRes.y;
}