Jump to content


Photo

Object Blurring


  • Please log in to reply
4 replies to this topic

#1 sykner809

sykner809

    GMC Member

  • New Member
  • 122 posts

Posted 19 September 2011 - 12:01 AM

DESCRIPTION:
changes the common "draw_sprite_ext" function to "draw_set_ext_blurry".

INSTRUCTIONS:
Simply draw the desired object in the draw event with "draw_sprite_ext_blurry(sprite,subimage,x,y,xscale,yscale,rotation,color,alpha,blur)"
(The argument blur is the radius that an object is spread out)

PRO's :)
-no need for any setup in create/step events!
-!!!allows you to change the alpha!!!

CON's :(
-might slow down above 15 and below -15
-uses the variable "r"

SUGGESTIONS:
-Works best by using the variable depth to create a focusing effect.
-Do not overuse!!!

CREDIT:
-yes, please give it. Just use Sykner.

DOWNLOAD:
click here

THE SCRIPT:
r=abs(floor(argument9))
if(r==0)
{
    draw_sprite_ext(argument0,argument1,argument2,argument3,argument4,argument5,argument6,argument7,argument8)
}
if(r==1)
{
    draw_sprite_ext(argument0,argument1,argument2,argument3,argument4,argument5,argument6,argument7,.5*argument8)
    draw_sprite_ext(argument0,argument1,argument2,argument3,argument4,argument5,argument6,argument7,.5*argument8)
    draw_sprite_ext(argument0,argument1,argument2,argument3+1,argument4,argument5,argument6,argument7,.5*argument8)
    draw_sprite_ext(argument0,argument1,argument2-1,argument3,argument4,argument5,argument6,argument7,.5*argument8)
    draw_sprite_ext(argument0,argument1,argument2-1,argument3+1,argument4,argument5,argument6,argument7,.5*argument8)
}
else
{
    for(i=r*-1;i<r+1;i+=1)
    {
        for(j=r*-1;j<r+1;j+=1)
        {
            if(i+j<r)
            {
                draw_sprite_ext(argument0,argument1,argument2+j,argument3+i,argument4,argument5,argument6,argument7,(argument8/r)/r)
            }
        }
    }
}

Edited by sykner809, 22 September 2011 - 04:56 AM.

  • 0

#2 sykner809

sykner809

    GMC Member

  • New Member
  • 122 posts

Posted 22 September 2011 - 04:58 AM

--BUMP--

Added download link.
  • 0

#3 creativebunch

creativebunch

    The Bunchiest

  • GMC Member
  • 930 posts
  • Version:GM:Studio

Posted 24 September 2011 - 05:44 PM

Your code can be considerably shortened:
var r, i, j;
r = abs(floor(argument9))
i = r * -1;
if (r == 0) { draw_sprite_ext(argument0, argument1, argument2, argument3, argument4, argument5, argument6, argument7, argument8); exit; }
repeat ((r * 2) + 1) {
    j = r * -1;
    repeat ((r * 2) + 1) {
        if (i + j < r)
            draw_sprite_ext(argument0, argument1, argument2 + j, argument3 + i, argument4, argument5, argument6, argument7, (argument8 / r) / r);
        j += 1;
    }
    i += 1;
}
Using repeat instead of for gives a performance boost, also you do not need to have it use r as a local variable, you should declare it temporary along with your loop variables.

Other than that it's a nice script.
  • 0

#gmc - It's the goddamn GMC IRC
Beat Hell Pre-Alpha v2.1.0 | Slender2d | Creeping Insanity

indiedb_88x31.png

buXyYwQ.png
I am looking for a pixel/3D artist to team up with me to work on some games. Send me a message if interested.


#4 sykner809

sykner809

    GMC Member

  • New Member
  • 122 posts

Posted 29 September 2011 - 04:11 AM

Your code can be considerably shortened:

var r, i, j;
r = abs(floor(argument9))
i = r * -1;
if (r == 0) { draw_sprite_ext(argument0, argument1, argument2, argument3, argument4, argument5, argument6, argument7, argument8); exit; }
repeat ((r * 2) + 1) {
    j = r * -1;
    repeat ((r * 2) + 1) {
        if (i + j < r)
            draw_sprite_ext(argument0, argument1, argument2 + j, argument3 + i, argument4, argument5, argument6, argument7, (argument8 / r) / r);
        j += 1;
    }
    i += 1;
}
Using repeat instead of for gives a performance boost, also you do not need to have it use r as a local variable, you should declare it temporary along with your loop variables.

Other than that it's a nice script.


CreativeBunch, I thank you for your advise, but unfortunately, your script takes 4000 Kb more memory than the original according to task manager.

Edited by sykner809, 29 September 2011 - 04:19 AM.

  • 0

#5 creativebunch

creativebunch

    The Bunchiest

  • GMC Member
  • 930 posts
  • Version:GM:Studio

Posted 29 September 2011 - 06:25 PM

My manager does not show that. When I test it I get higher than 10% increase in fps.
  • 0

#gmc - It's the goddamn GMC IRC
Beat Hell Pre-Alpha v2.1.0 | Slender2d | Creeping Insanity

indiedb_88x31.png

buXyYwQ.png
I am looking for a pixel/3D artist to team up with me to work on some games. Send me a message if interested.