[Effect] mode7

Share your Construct 2 effect files

Post » Sat Nov 01, 2014 7:00 pm

@Aurel
Feel free to post it. I haven't had time as of late to mess with it. I'm just glad it could be improved.
B
79
S
24
G
54
Posts: 4,746
Reputation: 40,755

Post » Sat Nov 01, 2014 9:40 pm

@Ashley Ouch. That means I have to add 2 more layers in every level. That will look like this:

BEFORE:

HUD
Foreground
Triggers (invisible)
> Ships/Others (mode7 applied)
> Track (mode 7 applied)
Background

NOW:

HUD
Foreground
Triggers (invisible)
> Additive layer for FX above the ships (mode7 applied)
> Ships/Others (mode7 applied)
> Additive layer for FX under the ships (mode7 applied)
> Track (mode 7 applied)
Background

I'm not afraid of the work for the elements to be sorted on the right layers, but 4 X mode 7 effects... I'm worried about perfs.
I guess I have no choice, I'll try. This mode 7 effect is optional and can only be selected in the graphic options as "VERY HIGH" (others being "LOW = no shaders/few particles and NORMAL=all shaders but no mode7")
Image | @AurelRegard on twitter
B
19
S
6
G
1
Posts: 307
Reputation: 2,495

Post » Sat Nov 01, 2014 10:30 pm

Excuse my ignorance, but couldn't you create a highly specific Mode7Additive effect?

...I, uh, have literally no idea how shaders work, just thinking aloud.
B
49
S
14
G
3
Posts: 540
Reputation: 5,611

Post » Sun Nov 02, 2014 12:00 pm

Shaders are more expensive than simply setting a blend mode, so I don't think a special Mode7Additive effect is going to improve anything.

If you've made all the improvements to the Mode7 effect I suggested (including separate shaders to remove the conditional), then I think it should be about as fast as normal rendering. The bottleneck is normally the number of texture lookups (normal rendering does one, but a blur might do ~10, requiring 10 times as many texture reads), conditionals (especially if unpredictable, which can make entire groups of cores stall if one mispredict occurs), or loops. Mode7 does one lookup, then some branchless math with no loops. I think in some cases the math is done "for free", because even if it weren't there the core would have spent the same amount of time stalling waiting for the next memory read to come through.

The only thing to worry about IMO is the fact you have two more layers which will be using their own texture. After the layer renders it then has to copy the canvas-sized texture for that layer to the screen. It's the type of thing that on mobile will hit your fillrate hard and possibly cause poor performance. However if you're targeting desktops/consoles you probably have more fillrate than you could know what to do with (especially on high end desktop graphics cards, you will probably sooner run out of CPU power trying to issue rendering commands than run out of fillrate). So fillrate is probably not a major concern there either.

So basically I wouldn't worry about it, it's a good way to get the effect working with different blend modes. Something you could do to help reduce the fillrate: if any of the layers are empty - or even if they have content, but it is offscreen - set them invisible. A visible but empty layer using an effect still takes fillrate (just to process a screen of transparent pixels); if it's invisible, it's entirely skipped, saving any rendering cost. So then you only pay the GPU cost when it's necessary, so e.g. if there are no FX under the ships then you don't spend any time at all processing shaders or using fillrate.

I wonder if the engine could skip layers automatically if they are empty. I might try experimenting with that in the next beta.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

Post » Sun Nov 02, 2014 2:38 pm

(layer skip if empty sounds like a very nice idea!)


Alright, it took me a bit of time, but everything is now up and running : )

- Mode7 shader simplified
- 2 more layers for additive blended sprites and particles, only used if mode 7 is activated (set to "invisible" if no mode7)
- sprites and particles are automaticaly moved to the new layers on created if mode 7 activated.
- sprites and particles are automaticaly moved back to the regular layers if mode 7 is desactivated during ingame.

I still have to test this on less powerfull hardware, but it runs ok on my laptop.

Many, many thanks for your help on this issue @Ashley , it made a huge difference.
I'll record a clean video with "mode7 on/off" to show how cool it looks, and post the shader very soon too : )
Image | @AurelRegard on twitter
B
19
S
6
G
1
Posts: 307
Reputation: 2,495

Post » Sun Nov 02, 2014 3:15 pm

DOWNLOAD, two flavors!

(SHADER) original mode7 with alpha channel fixed:

https://www.dropbox.com/s/l3os31etolq3i ... d.zip?dl=0

(SHADER) same, but optimized for fullscreen usage (faster!):

https://www.dropbox.com/s/bclis2lvbige6 ... d.zip?dl=0
Image | @AurelRegard on twitter
B
19
S
6
G
1
Posts: 307
Reputation: 2,495

Post » Sun Nov 02, 2014 5:57 pm

60FPS 1080p video showcasing the "mode7♥" shader on The Next Penelope.
Adds a bit of a 3D feel (and will be optional)

https://www.youtube.com/watch?v=xgb1pLg8mgY

Image
Image | @AurelRegard on twitter
B
19
S
6
G
1
Posts: 307
Reputation: 2,495

Post » Mon Nov 03, 2014 9:43 am

@Aurel

looks really nice man :) Does it have an impact on performance or why should it be optional?
Image
Check out our start-up and configure your own helmet in true 3D.
B
42
S
11
G
11
Posts: 1,152
Reputation: 9,886

Post » Mon Nov 03, 2014 1:34 pm

Looks ok on the performance side, but as it needs a frame to hide the distortion on the borders, I'm making sure people can desactivate it : )
Image | @AurelRegard on twitter
B
19
S
6
G
1
Posts: 307
Reputation: 2,495

Post » Wed Nov 05, 2014 10:35 am

Looks great. Thanks for sharing.
B
37
S
19
G
18
Posts: 613
Reputation: 10,231

PreviousNext

Return to Effects

Who is online

Users browsing this forum: No registered users and 0 guests