2 registered members (AndrewAMD, Quad),
595
guests, and 4
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Panel based, autoresizing, fullscreen filmgrain
#43314
03/27/05 18:48
03/27/05 18:48
|
Joined: Aug 2000
Posts: 7,490
Orange Brat
OP
Senior Expert
|
OP
Senior Expert
Joined: Aug 2000
Posts: 7,490
|
Panel based, autoresizing, fullscreen filmgrain
It uses a single set of six 640 x 480 PCX images, and the scale factors are dependent on this size. If you use a different size, you'll have to change the scale values to match. As is, it takes up just over 6.2MB of video memory when active, and it'll purge itself when grainToggle = 0.
Code:
panel* pnl;
var grainToggle;
bmap grain1 = <grain1.pcx>;
bmap grain2 = <grain2.pcx>;
bmap grain3 = <grain3.pcx>;
bmap grain4 = <grain4.pcx>;
bmap grain5 = <grain5.pcx>;
bmap grain6 = <grain6.pcx>;
panel filmGrainPanel
{
layer = 200;
pos_x = 0;
pos_y = 0;
alpha = 5; //change to suit your needs
flags = transparent,overlay;
}
function filmGrain()
{
pnl = filmGrainPanel;
grainToggle = 1;
while(grainToggle == 1)
{
if(video_mode == 6) { pnl.scale_x = 1; pnl.scale_y = 1; } else { //640x480
if(video_mode == 7) { pnl.scale_x = 1.25; pnl.scale_y = 1.25; } else { //800x600
if(video_mode == 8) { pnl.scale_x = 1.6; pnl.scale_y = 1.6; } else { //1024x768
if(video_mode == 9) { pnl.scale_x = 2; pnl.scale_y = 2.134; } else { //1280x1024
if(video_mode == 11) { pnl.scale_x = 2.5; pnl.scale_y = 2.5; } } } } } //1600x1200
pnl.bmap = grain1; pnl.visible = on; sleep(0.09); pnl.visible = off;
pnl.bmap = grain2; pnl.visible = on; sleep(0.09); pnl.visible = off;
pnl.bmap = grain3; pnl.visible = on; sleep(0.09); pnl.visible = off;
pnl.bmap = grain4; pnl.visible = on; sleep(0.09); pnl.visible = off;
pnl.bmap = grain5; pnl.visible = on; sleep(0.09); pnl.visible = off;
pnl.bmap = grain6; pnl.visible = on; sleep(0.09); pnl.visible = off;
}
pnl.visible = off; bmap_purge(grain1); bmap_purge(grain2); bmap_purge(grain3); bmap_purge(grain4); bmap_purge(grain5); bmap_purge(grain6);
}
Here's some starter images. Use Winrar to open it. I highly recommend you create your own(use Gimp filmgrain/noise filters) so your project's grain isn't the same as every other one that uses it: http://www.geocities.com/hainesrs/grain6PCX.rar
My User Contributions master list - my initial post links are down but scroll down page to find list to active links
|
|
|
Re: Panel based, autoresizing, fullscreen filmgrain
[Re: Orange Brat]
#43315
03/28/05 04:26
03/28/05 04:26
|
Joined: Aug 2002
Posts: 673 Las Cruces, NM
JimFox
User
|
User
Joined: Aug 2002
Posts: 673
Las Cruces, NM
|
Thanks, Orange Brat! I feel a bit stupid, but I have no clue what "filmgrain" actually means, except in the literal sense of photographic film. Could you talk me through this? I would be interested in learning how to have panels autoresize to fill the screeen at any resolution. Does this have anything to do with that? Regards,
Jim
|
|
|
Re: Panel based, autoresizing, fullscreen filmgrain
[Re: JimFox]
#43316
03/28/05 08:03
03/28/05 08:03
|
Joined: Aug 2000
Posts: 7,490
Orange Brat
OP
Senior Expert
|
OP
Senior Expert
Joined: Aug 2000
Posts: 7,490
|
1. Video mode 7 line's scale_x had a wrong value...it has been corrected.
2. Changed the panel name to filmGrainPanel to eliminate a double definition error.
Filmgrain is the noise pattern you see on old movies and on modern ones with an intentional filter placed during post. The Silent Hill games use it as does our very own The Kid, as well as, my own. It gives horror games a little more atmosphere, although it's good to provide an on/off switch for framrerate purposes. In the case of this code, all you have to do is set grainToggle to 0 and it takes care of the cleanup.
The autoresizing is a simple matter of altering the scale_x and scale_y to the appropriate value based on the resolution. I don't know how well it would work with panels with words on them or dithering, but it works fine for noise patterns and I'd think flat color. You could also display the PCX files as screen entities. They automatically resize depending on the resolutino, but it doesn't look as nice as using panels.
My User Contributions master list - my initial post links are down but scroll down page to find list to active links
|
|
|
Re: Panel based, autoresizing, fullscreen filmgrain
[Re: Orange Brat]
#43317
04/02/05 07:16
04/02/05 07:16
|
Joined: Oct 2003
Posts: 2,628 IL,US
FeiHongJr
Expert
|
Expert
Joined: Oct 2003
Posts: 2,628
IL,US
|
thanks ill have to check it out i know i couldve used them conversion numbers for the panel size a few weeks back ended up going thru figuring out each one manually in the game. i know theres gotta be a math formula to figure it out but im no good at math.. sorry off topic . looks interesting ill give it a go and let you know if i have any problems thanks again
Edit:: im using the panel resize for menus and it does make them appear a little more blocky but it really isnt too bad i guess if you were to go the other way around and start with larger panels then reduce the size depending on screen resolution it might not be as bad. never tried it but that would require more memory so *shrugs*
Last edited by FeiHongJr; 04/02/05 07:22.
|
|
|
Re: Panel based, autoresizing, fullscreen filmgrai
[Re: FeiHongJr]
#43320
09/02/06 11:30
09/02/06 11:30
|
Joined: Jul 2001
Posts: 6,904
HeelX
Senior Expert
|
Senior Expert
Joined: Jul 2001
Posts: 6,904
|
I implemented another method that adapts to the screen resolution AND consumes only ~ 150 KB of videomemory by still looking the same as OrangeBrat did it. Have fun! Here is the link: I am the link! Hell yeah!From the readme: -------------------------------------------------------------------- Low memory consumptioning realtime filmgrain Created by: Christian Behrenberg - 2006-09-02 -------------------------------------------------------------------- Instead of circulate some big sized bitmaps for a realtime filmgrain, I use the natural property of grain: it is tileable. I took a filmgrain sample picture and converted it into a 512x512 DDS texture to save memory. It is only 129 KB big! The method to emulate the previous method is to shift repeatingly the UV parameters of the skin in random matter. No one will see that you are just shifting the texture and badabing! you have a well done filmgrain effect. To achieve this, I use a screenentity for this. It is a 2 polygonal plane with the typical 4:3 ratio. So, nothing big in here. Additionally, I randomize each cycle the alpha value in a certain range. With this package I provide 2 MDLs. The MDLs contain already the DDS texture, if you wish to link them to the external files, I added them also. I included two different grainstyles: the first one is the default black and white one, the second is a sepia version whereas I adapted the color of the grain to the typically sepia color. You can easily decide what you want by commenting in/out the corresponding line in the WDL. To implement the grain just copy the code into your project or include the WDL. To start the refreshing function, just call HUD_grainRefresh(); once.. in your main loop, in your HUD initialization or whatever. You can easily change the variables to create your personal grain-style. NOTE: The disadvantage that it is a screenentity is, that it changes size when you change the camera.arc. So you may should write additional lines to compensate that side effect. Just modify dynamically the .x property of the HUD_grain entity. Have fun and finish that AAA title THIS CODE AND ITS CONTENTS ARE FREEWARE if you like to write any thanks into your credits, feel free to send me a note so that I can play your game seeing my grain (what a rhyme!) in action Greetings Christian Behrenberg
Last edited by HeelX; 09/02/06 11:32.
|
|
|
Re: Panel based, autoresizing, fullscreen filmgrai
[Re: Orange Brat]
#43322
09/03/06 12:33
09/03/06 12:33
|
Joined: Jul 2001
Posts: 6,904
HeelX
Senior Expert
|
Senior Expert
Joined: Jul 2001
Posts: 6,904
|
I took it from the template of the current beta and modified it, because the template material shifts in mat_effUVrender the texture cyclicly with total_ticks, but I prefer to do that on my own. So.. assign this material and in the refresh function replace .u and .v with skill1 and skill2. I guess its better when you store the effect part in the material in a .fx file, just because this is just the effect itself plus its naming convention and, well, I guess you will access the effect from the original grain material. Code:
//-------------------------------------------------------------------- // UV Shifting // FFP Effect, which shifts faster the texture than using .u/v //-------------------------------------------------------------------- function mat_effUVrender(); function mat_effUVinit();
//primary effect material material mat_effUV { event = mat_effUVinit; effect = " matrix matMtl;
technique effUVspeed { pass one { TextureTransformFlags[0] = Count2; TextureTransform[0] = <matMtl>; } } technique fallback { pass one { } } "; }
//helper-function: Init function mat_effUVinit() { mtl.matrix11 = float(1); // default u scale mtl.matrix21 = 0; mtl.matrix12 = 0; mtl.matrix22 = float(1); // default v scale
mtl.event = mat_effUVrender; mtl.ENABLE_RENDER = on; }
//helper-function: refresh function mat_effUVrender() { //Skill1 & Skill2 are used for the shifting mtl.matrix31 = floatd(my.skill1, 256); mtl.matrix32 = floatd(my.skill2, 256); }
|
|
|
|