Pixelate Post Effect

I hacked together a pixelate post effect.
pixelate post effect

the two things I couldn’t figure out:
—how to get the script attribute to the shader
—it doesn’t seem to update the resolutions on resize.
(it’s also not script 2.0 so probably should look into that and update)

Anyone wanna help?

It’s not script 2.0? It looks like it is to me - I just dropped your script into a script 2.0 project:

Project link:

https://playcanvas.com/project/411313/overview/pixelate

Seems to work fine. Nice. :slight_smile:

Only problem was that the script wouldn’t parse properly. I had to delete the definition of the effect before the script object is defined to make the parse succeed. I then re-added it and it worked. Maybe @vaios or @max know why.

1 Like

That’s great!

I still can’t figure out how to pass the attribute to the shader?
Also while resizing the window, weird scaling things happen?

Generally asking, are the post effects from https://github.com/playcanvas/engine/tree/master/extras/posteffects still up to date? When I try to parse one, it says “No Script Objects found”…

Help is appreciated, thanks!

These post effect scripts have not been updated to the new script system yet. I’ll try to do that as soon as possible :slight_smile: Although should be pretty straightforward to do it on your own for your copies if you wanna get it done sooner.

1 Like

I’m trying that right now but it’s not that easy for me, unfortunately…
Having a post effect example in Script 2.0 would be extremely helpful. :pray: :robot:

It looks like your script is 2.0? http://pastebin.com/vJGzTUST

Basically it’s just the script definition part that needs to change - the top part that defines the actual post effect doesn’t need to change.

1 Like

well the way to handle attributes apparentyl changed, and I can’t get the attribute from the editor into the shader…

Do you see the script attribute in the Editor? If not you need to re-parse the script (just select it in the asset explorer and click Parse on the Inspector.

Then inside your script in the handler of attr:pixelize you probably want to do something like:

this.on('attr:pixelize', function (value, prev) {
    effect.pixelize = value;
});

nice! now it works! Scope was wrong (of course), I was saying this.pixelize…


:grinning:
2 Likes

update here https://github.com/MateSteinforth/pixelate
https://www.youtube.com/watch?v=IGyJ0t8-o88

Nice :smiley:

I noticed in your video that you clicked the parse button for the script twice (once when you selected the script in the asset explorer and once when you added it to a script component). You don’t have to do this - just the first time would be enough :slight_smile:

1 Like

BTW I converted the engine scripts to scripts 2.0

2 Likes

imma revive this for everyone else that needs this

For a post effect there is an open PR here, you could grab the file and see how it works:

For a non post effect way on a pixelate effect check this post:

1 Like