[Effect] Outline

Share your Construct 2 effect files

Post » Wed Jun 08, 2016 5:03 am

@R0J0hound

Thanks for the super detailed reply :) Massively helpful as always!

The problem I have with putting different "parts" on different layers is (again, the C2 bane of game making;) because of instance picking of the same objects. I used a container to get around my issues - since using loops to resolve the picking problems because very CPU intensive and I was getting major fps drop with only 15-20 characters (now I can make 60 or 70 before fps starts dropping). Anyway, the issue with having say, an arm or leg on another layer is;

Explaination: I have a "character" who is made up of several components - this "character" however is being created multiple times to create *every* character in the game. Think of it as a "blank" I guess, mannequin? These blank characters can be visualised differently using animations and specific frame settings - so one characters arm might have different colours to another. Changing the outline colour for the layer itself would obviously change the colour for all instances of the "arm" or whatever - which would mean everything would be the same outline colour regardless of intended design/colour. Each arm and leg is made of 10 segments (giving a "noodle" style appearance) with which I can change the appearance/colour/texture of any segment independently. I could have long sleeves or short sleeves for example - requiring a different coloured outline for multiple parts of the same "object".

I think paster may work for all intents and purposes, however I think it may over-complicate what I'm trying to do. I'm also not sure what impact (if any) it will have on performance since there can/will/may be up to 40-50 instances of a "character" present on-screen simultaneously at any given time.

I would just simply "bake" the outline into the graphical content itself, but since there is a form of zordering/rotation to the character, and the limbs are animated using qarp and lerp mathematics - baked outlines would subsequently appear "on top" of stuff that I don't want. If I made a 2nd sprite to match each instance in a container (always placed behind the character) to act as the outline... that would work - but I suspect the extra CPOU overhead for placing instances (to make sure the correct colours are being placed behind the corresponding parts) would cut my fps in half or more.

As is stands, the way my character "blank" is being created already chews up a fair bit of CPU time since it's running a qarp equation for 40 separate parts (per instance of the character) - and I'm not even sure that this will be suitable in the long run. Adding any extra loops (even for basic/simple placement or comparisons) that are related to the character already dramatically affect the performance.

My final resort would be to just ignore the idea of using an outline at all - but it's a look that I particularly like and being able to incorporate it in an elegant manner would be ideal.

Feel free to let me know if you have any thoughts about it - since you're a wizard and all that.

Don't stress about making an example cap though, unless you really want something to do to pass the time - I'm confident I can work out paster with the example pseudo-code you've supplied.

Much appreciated as always!

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
45
S
17
G
37
Posts: 2,853
Reputation: 25,966

Post » Wed Jun 08, 2016 6:21 pm

@SoldjahBoy
Here's an example. I did the outline by scaling the object instead of moving eight copies which seems to work better with round or square objects.
https://dl.dropboxusercontent.com/u/542 ... tline.capx

The picking is unavoidable. You could store a list of uid's of the objects in each group in an array so you could loop over the array and pick by uid. That would be faster than normal picking with a high number of instances. Utilizing pick nth instance and iid is another option instead of uid but things can change when instances are destroyed.

This can also be manipulated a lot depending on what you want to do. If only one outline is shown at a time you can have only one paster object.

I also fiddled with the idea of changing the group based on the object's z order and came up with this:
https://dl.dropboxusercontent.com/u/542 ... line2.capx
Your idea of the groups being always the same should work too. You just need to zsort the groups.

As far as performance, you probably can get a boost by just using the fx like in the first example, still the rendering perfomance will be a bit slower or at least it should be similar if each group was on it's own layer.
B
79
S
24
G
55
Posts: 4,755
Reputation: 41,273

Post » Thu Jun 09, 2016 3:56 am

@R0J0hound

Thanks very much mate, I will check those out later this afternoon once I've finished work. I'll let you know how I go with it, and what I end up doing :D

Cheers bud ;)

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
45
S
17
G
37
Posts: 2,853
Reputation: 25,966

Post » Sat Jun 25, 2016 4:52 pm

@R0J0hound

Thank you for making this nice effect available :)

Sadly, I ran into a problem. After export, outline is all messed up. I'm using NW.JS v0.15.0 and Construct2 r227.

Outline in C2 NW.JS preview:
h*t*t*p*s://dl.dropboxusercontent.com/u/43020976/C2%20pics/outline/in%20preview.jpg

Outline in NW.JS after exporting
h*t*t*p*s://dl.dropboxusercontent.com/u/43020976/C2%20pics/outline/after%20exporting.jpg

I even made a plank project to see if I could reproduce this problem. Well, same problem occurred after export. Any idea what is causing this? Or how I can fix it?

-M-
B
12
S
2
Posts: 50
Reputation: 844

Post » Sat Jun 25, 2016 6:02 pm

@Mithrill
That has been mentioned before I think. I think it's related to export in general, but I can't test on my machine since I can't use webgl. Best I can tell the pixelwidth/pixelheight variables that C2 provides to shaders is giving different values on export.

Try the same test you did with this effect on the pixelate effect since it also uses those variables. If the results are different then that would make a good bug report since it involves only vanilla C2. If the results are the same then the problem is with how I used the variables in this shader, but I don't see the issue.
B
79
S
24
G
55
Posts: 4,755
Reputation: 41,273

Post » Sun Jun 26, 2016 10:29 am

@R0J0hound

I made a test with the pixelate effect like you suggested. I even installed a fresh copy of C2. Again like you mentioned, to make test with a vanilla version. Then I only installed your outline effect. Results: pixelate effect is also broken after exporting to NW.JS. I also exported to html5 and effect is broken. In preview pixelate effect is working but after export, well, see yourself:

first state In preview:
h*t*t*p*s://dl.dropboxusercontent.com/u/43020976/C2%20pics/pixelate/pixelate%20first%20state%20in%20preview.jpg

second state In preview:
h*t*t*p*s://dl.dropboxusercontent.com/u/43020976/C2%20pics/pixelate/pixelate%20second%20state%20in%20preview.jpg

last state In preview:
h*t*t*p*s://dl.dropboxusercontent.com/u/43020976/C2%20pics/pixelate/pixelate%20last%20state%20in%20preview.jpg


Below are the results after exporting:

First state:
h*t*t*p*s://dl.dropboxusercontent.com/u/43020976/C2%20pics/pixelate/pixelate%20first%20state%20after%20export.jpg

Last state:
h*t*t*p*s://dl.dropboxusercontent.com/u/43020976/C2%20pics/pixelate/pixelate%20last%20state%20after%20export.jpg

Maybe I should post a bug report?

-M-
B
12
S
2
Posts: 50
Reputation: 844

Post » Sun Jun 26, 2016 6:37 pm

If the pixelate effect is getting broken on export then, yes report just that. Don't include the outline effect in the report, since third party stuff can't be in bug reports. If it gets fixed then the outline effect will likely be fixed as well.
B
79
S
24
G
55
Posts: 4,755
Reputation: 41,273

Post » Mon Sep 19, 2016 7:11 pm

How does it works? Wht's param1 and param2?
Thank you!
B
10
S
3
Posts: 35
Reputation: 672

Post » Mon Sep 19, 2016 9:02 pm

@Ciao121
You unzip the file into the effects folder in C2's install directory and then it's as easy as using any other effect.
B
79
S
24
G
55
Posts: 4,755
Reputation: 41,273

Post » Tue Sep 20, 2016 8:06 am

Hi R0J0hound,
looking at the xml make me understand how it works. Thanks!
B
10
S
3
Posts: 35
Reputation: 672

Previous

Return to Effects

Who is online

Users browsing this forum: No registered users and 0 guests