Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
1 registered members (TipmyPip), 18,618 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Visual Field Blur - Also Cheap and Faked (Pro Ed) #78975
06/22/06 00:22
06/22/06 00:22
Joined: Aug 2002
Posts: 681
Massachusetts, USA
Ichiro Offline OP
User
Ichiro  Offline OP
User

Joined: Aug 2002
Posts: 681
Massachusetts, USA


Since the mods haven't banned me for spamming all over the place, I wanted to share another cheap trick. This one is a poor-man's blur effect that attempts to mimic the way our eyes see (that is, the image is clearest towards the center of our vision and blurriest at the periphery). The topmost image is a normal, un-blurred shot; the center one blurs the edges slightly; and bottom one blurs the edges significantly. In the latter two images, the P. Pod text on the left appears blurred, while the center text is still crisp.

Here's the code (requires A6 Pro as well as the motion blur snippets from the other thread):

Code:
// Panels for the set_visual_field function:
panel panel_visual_field {
bmap bitmap_motion_blur;
layer = -1;
flags = transparent;
}
panel panel_visual_field_2 {
bmap bitmap_motion_blur;
layer = -2;
flags = transparent;
}


//
// Change how blurry the screen appears, and at what locations.
//
// zoomval (usually 0..100, but can go higher) determines how blurry the
// periphery is, while keeping the center of the screen crisp.
// x_offset and y_offset determine how much to blur the screen in the x and y
// directions, respectively.
//
// (Note: this is hardcoded to a 1024x768 screen, but can be made to be
// dynamic.)
//
function set_visual_field(zoomval, x_offset, y_offset) {
zoomval /= 1000;

// Turn the effect off:
if(zoomval==0 && x_offset==0 && y_offset==0) {
set_motion_blur(0); // Lazy way to reset camera.bmap.

// Make the blurry panels invisible:
panel_visual_field.visible=0;
panel_visual_field_2.visible=0;
return;
}

// Just a lazy way to set up camera.bmap:
set_motion_blur(100);
panel_motion_blur.transparent=0;

// Position the first blurred copy of the view halfway between the "real" one and panel_visual_field_2:
panel_visual_field.scale_x=1+zoomval/2;
panel_visual_field.scale_y=1+zoomval/2;
panel_visual_field.pos_x=0-(panel_visual_field.scale_x*1024-1024)/2+x_offset/2;
panel_visual_field.pos_y=0-(panel_visual_field.scale_y*768-768)/2+y_offset/2;
panel_visual_field.transparent=1;
panel_visual_field.alpha=50;
panel_visual_field.filter=1;
panel_visual_field.visible=1;

// Position the second blurred copy of the view:
panel_visual_field_2.scale_x=1+zoomval;
panel_visual_field_2.scale_y=1+zoomval;
panel_visual_field_2.pos_x=0-(panel_visual_field_2.scale_x*1024-1024)/2+x_offset;
panel_visual_field_2.pos_y=0-(panel_visual_field_2.scale_y*768-768)/2+y_offset;
panel_visual_field_2.transparent=1;
panel_visual_field_2.alpha=50;
panel_visual_field_2.filter=1;
panel_visual_field_2.visible=1;
}



To get the images in the above shots, I did:

set_visual_field(0, 0, 0); // Off
set_visual_field(10, 0, 0); // Slight edge blurring
set_visual_field(20, 0, 0); // Heavy edge blurring

You can also make the entire screen slightly blurry with this:

set_visual_field(0, 2, 0); // Horizontal smearing

Or make it look like the player's glasses have broken apart:

set_visual_field(50, 50, 50); // Yeesh

I'm posting here rather than User Contributions, as this is all still a work-in-progress; any feedback or suggestions are welcome.


Dejobaan Games - Bringing you quality video games for over 75 years.
Re: Visual Field Blur - Also Cheap and Faked (Pro [Re: Ichiro] #78976
06/22/06 15:38
06/22/06 15:38
Joined: Sep 2002
Posts: 8,177
Netherlands
PHeMoX Offline
Senior Expert
PHeMoX  Offline
Senior Expert

Joined: Sep 2002
Posts: 8,177
Netherlands
Hey that would be a pretty cool effect for a 2D sonic like game I think. '2D Depth of vision' hehehehe ... Cool !
And thanks for sharing! This really helps a lot since it took me some time to figure out that there isn't a 'render_to_texture' command, but it involves view.bmap and so fort ...

Cheers


PHeMoX, Innervision Software (c) 1995-2008

For more info visit: Innervision Software
Re: Visual Field Blur - Also Cheap and Faked (Pro [Re: PHeMoX] #78977
06/22/06 17:25
06/22/06 17:25
Joined: Mar 2006
Posts: 35
Sao Paulo, Brazil
EdMercer Offline
Newbie
EdMercer  Offline
Newbie

Joined: Mar 2006
Posts: 35
Sao Paulo, Brazil
Since it's informal national holliday today (the brazilian soccer team plays japan in one hour) I won't have time to test your code before the studio closes up but I'll try it tomorrow with some speed variation too and post results. Great code as well !

Re: Visual Field Blur - Also Cheap and Faked (Pro [Re: EdMercer] #78978
06/22/06 19:13
06/22/06 19:13
Joined: Jun 2005
Posts: 656
G
Grafton Offline
User
Grafton  Offline
User
G

Joined: Jun 2005
Posts: 656
This looks really nice, but I am having a little trouble getting it working.
I copied the above into a included empty wdl along with your motion blur script
above it. Then I enclosed the alpha frame evaluation in a starter loop and set
set_visual_field(20, 0, 0); and no effect or error?
However, if I set "set_motion_blur(18);" with the same wdl, the motion blur
seems to work fine. so I must be missing something in this snippit. I will have
to work on this a little more.

I wonder if there is a way to make the outside blurred edge constantly move
outwards as if zooming in while the central area remains unblurred?

Thanks for sharing these ultra cool effects, very generous of you!


Not two, not one.
Re: Visual Field Blur - Also Cheap and Faked (Pro [Re: Grafton] #78979
06/23/06 05:06
06/23/06 05:06
Joined: Aug 2002
Posts: 681
Massachusetts, USA
Ichiro Offline OP
User
Ichiro  Offline OP
User

Joined: Aug 2002
Posts: 681
Massachusetts, USA
Humm. Good question; perhaps do something like this, without the alpha re-evaluation loop...
Code:
set_motion_blur(100);
panel_motion_blur.transparent=0;
panel_visual_field.pos_x=20;
panel_visual_field.transparent=1;
panel_visual_field.alpha=50;
panel_visual_field.filter=1;
panel_visual_field.visible=1;


...if that doesn't blur things a bit, it may be that bitmap_motion_blur isn't being written(?)


Dejobaan Games - Bringing you quality video games for over 75 years.

Moderated by  HeelX, Spirit 

Gamestudio download | 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