Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, Quad, 1 invisible), 601 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Panel based, autoresizing, fullscreen filmgrain #43314
03/27/05 18:48
03/27/05 18:48
Joined: Aug 2000
Posts: 7,490
O
Orange Brat Offline OP

Senior Expert
Orange Brat  Offline OP

Senior Expert
O

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 Offline
User
JimFox  Offline
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
O
Orange Brat Offline OP

Senior Expert
Orange Brat  Offline OP

Senior Expert
O

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 Offline
Expert
FeiHongJr  Offline
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.

http://www.freewebs.com/otama_syndicate/index.htm - Each master to his own technique.

- Not me said the bee, Nor I said the fly.
Re: Panel based, autoresizing, fullscreen filmgrain [Re: FeiHongJr] #43318
04/02/05 18:17
04/02/05 18:17
Joined: Aug 2000
Posts: 7,490
O
Orange Brat Offline OP

Senior Expert
Orange Brat  Offline OP

Senior Expert
O

Joined: Aug 2000
Posts: 7,490
You're right...it would probably look better going from larger to smaller, but for noise panels I don't think it matters.


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] #43319
04/02/05 20:45
04/02/05 20:45
Joined: Oct 2003
Posts: 2,628
IL,US
FeiHongJr Offline
Expert
FeiHongJr  Offline
Expert

Joined: Oct 2003
Posts: 2,628
IL,US
i agree i was just saying that since you mentioned using it for panels and what not but your right it probally doesnt matter much and does cut back on the overall size and memory the same applies for my game as well since graphix are not really my goal. I just like to complete one still havent got to check it out but it does look promising. I was a huge fan of the first silent hill and had plans of doing a horror type game eventually so this will be a very nice addition thanks again


http://www.freewebs.com/otama_syndicate/index.htm - Each master to his own technique.

- Not me said the bee, Nor I said the fly.
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
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

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: HeelX] #43321
09/02/06 23:54
09/02/06 23:54
Joined: Aug 2000
Posts: 7,490
O
Orange Brat Offline OP

Senior Expert
Orange Brat  Offline OP

Senior Expert
O

Joined: Aug 2000
Posts: 7,490
Thanks for the contribution. That looks as good as what I was doing and for only a fraction of the vid mem.

I actually did something like this a couple years ago. I can't remember why I didn't go with it. I think it was pixelated poorly, so I abandoned it. The U and V are deprecated, so I'll have to convert this over to the shifting material, although I see you already have that in your todo. I can't find it in the template folders(it used to be in effects), but I probably wouldn't know what to do with it anyway.


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 filmgrai [Re: Orange Brat] #43322
09/03/06 12:33
09/03/06 12:33
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

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);
}



Re: Panel based, autoresizing, fullscreen filmgrai [Re: HeelX] #43323
09/03/06 12:55
09/03/06 12:55
Joined: Aug 2000
Posts: 7,490
O
Orange Brat Offline OP

Senior Expert
Orange Brat  Offline OP

Senior Expert
O

Joined: Aug 2000
Posts: 7,490
Thanks. I assigned the mat_effUV material to the filmgrain entity, but it doesn't seem to be doing anything. The random alpha part still works, but the grain texture has disappeared.


My User Contributions master list - my initial post links are down but scroll down page to find list to active links
Page 1 of 2 1 2

Moderated by  adoado, checkbutton, mk_1, Perro 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1