Need help with a Shader - coordinate weirdness [2nd post]

Share your Construct 2 effect files

Post » Tue Feb 10, 2015 3:24 pm

Well, here's what I could gather so far:

Chrome: Glitches
Firefox: Glitches
Opera: Glitches
nw.js: Glitches

Safari: Shaders didn't work
IE11: Shaders didn't work
B
19
S
6
G
6
Posts: 1,101
Reputation: 5,646

Post » Wed Feb 11, 2015 12:24 am

The artifacts are caused because your images "touch" the border of the texture, as you can see here:

Image

So when sampling outside of the texture bounds, it samples the same border pixel (opaque) like if the texture repeated the border to infinity. This causes the glitches.
You can fix this by manually adding a 1px transparent border to your images or extending the effect bounding box in the shader xml.
Scirra Employee
B
131
S
46
G
16
Posts: 706
Reputation: 16,065

Post » Wed Feb 11, 2015 6:06 am

Animmaniac wrote:You can fix this by manually adding a 1px transparent border to your images or extending the effect bounding box in the shader xml.


Thanks for the input, Animmaniac, but my question is more about inconsistent behaviour - as you can see in the animated gif - one time you get the effect, move and object away, then back the same amount and the effect is different, move it away again, then back and it's suddenly fragmented. And my images are 254x254 so on export they get the obligatory 1px transparent border (I also just made this image have the border in preview and it's the same).

Image

Extending the bounding box for something like this usually makes things worse as then even more artefacts appear for overlapping objects (or you get unneeded elements on the other side). R0J0 observed it in his outline Shader (so he disabled bounding box extension) and I did in this one as well. Also, as said before for some reason adding any other Shader into the mix already sort-of extends the bounding box, even if it's not mentioned anywhere. If my inline Shader is the only one in the stack on a square that fills the texture it looks as it should - empty (since there's nothing to sample from the outside):

Image

If I use it as the only Shader it works predictably, every time. So, perhaps something is happening with Shader stacking - hopefully it can be addressed.
B
19
S
6
G
6
Posts: 1,101
Reputation: 5,646

Post » Wed Feb 11, 2015 5:31 pm

I did some tests but I can't reproduce this inconsistent behavior that you are describing.

You can try for yourself here.
*I did some modifications to the shader based on what I think you are trying to achieve, but it works the same regardless of the modifications.

Here's what it looks like when previewing in Chrome:

Image

I left a transparent border in two sides of the images (right and bottom) so it's easy to spot the differences with and without a border. You can see in the image that only the sides with a transparent border are rendered correctly.

Also added sine behaviors and a rotate to see what effects non round positions could have. It's possible to see some oscillation on the non-transparent borders of the circle, but nothing on the square.

Everything works consistently here, and adding other effects doesn't seem to extend the bounding box. Adding a transparent border or extending the texture through the xml solves the problem on my PC.

Are you getting the same results?
Last edited by Animmaniac on Wed Feb 11, 2015 7:34 pm, edited 1 time in total.
Scirra Employee
B
131
S
46
G
16
Posts: 706
Reputation: 16,065

Post » Wed Feb 11, 2015 6:26 pm

Animmaniac wrote:I did some tests but I can't reproduce this inconsistent behavior that you are describing.

You can try for yourself here.
*I did some modifications to the shader based on what I think you are trying to achieve, but it works the same regardless of the modifications.

I'll need to compare what those modifications do. The way it has an outline, but respects the alpha of the insides is great. Thanks!

Animmaniac wrote:Are you getting the same results?

I wasn't, because the test wasn't the same as mine - the moment we change the shader stack (shader BEFORE the effect) everything goes plenty bad here. I have changed your demo to show this:
Gliiitcheees.png


Glitches ahoy.capx


In my case it needs to be at least beyond one other Shader (one that trims things) so, unfortunately, I cannot change the stack order.

In general I think it's related to this - the way Shader-using thing sequencing works (or doesn't): viewtopic.php?f=184&t=124665
You do not have the required permissions to view the files attached to this post.
B
19
S
6
G
6
Posts: 1,101
Reputation: 5,646

Post » Wed Feb 11, 2015 7:33 pm

I see now, I get the same glitched results. It's strange that the problem only occurs at a specific stack order.

But it's definitely a bug. Now I understand why one of my drop shadow shaders behaves weirdly when I change the opacity of an object or layer it's applied to. It's probably related to the problem you depicted in the other topic.

My guess is that it happens in C2's compositor. Maybe it can be an overlook caused by some kind of render optimization (?).
I have a very recent Nvidia card with up to date drivers, so there's only a very small chance of being a driver's bug.
Scirra Employee
B
131
S
46
G
16
Posts: 706
Reputation: 16,065

Post » Wed Feb 11, 2015 8:09 pm

Animmaniac wrote:I see now, I get the same glitched results. It's strange that the problem only occurs at a specific stack order.

Well, I think it's not that much specific as "every following shader gets screwed" sort of thing.

Animmaniac wrote:But it's definitely a bug.

Amen to that! Finally someone gets it!

Animmaniac wrote:Now I understand why one of my drop shadow shaders behaves weirdly when I change the opacity of an object or layer it's applied to. It's probably related to the problem you depicted in the other topic.

Huh, you also have a drop shadow Shader? Or it hasn't been published?

Animmaniac wrote:My guess is that it happens in C2's compositor. Maybe it can be an overlook caused by some kind of render optimization (?).
I have a very recent Nvidia card with up to date drivers, so there's only a very small chance of being a driver's bug.

And I have tested on a very old and semi-old Nvidia cards. Now we just have to hope this does get considered a problem and not "standard behaviour" and gets fixed. Most of my pixel-friendly Shaders depend on it.

Edit: I would submit a bug report for both of these, but then the best way to show it is using my own Shaders so that might complicate things... Oh well, might just go ahead and do it (but probably tomorrow).
B
19
S
6
G
6
Posts: 1,101
Reputation: 5,646

Post » Wed Feb 11, 2015 8:27 pm

Somebody wrote:Amen to that! Finally someone gets it!

I recommend posting a minimal repro capx as example if you find glitches like these, otherwise is hard for someone to know if it's really a bug. There's too much variables involved, and sometimes depending how it is setup it doesn't show up (like this time). I tested your shader and it worked as expected initially. But it needs a different stack order to manifest.

Somebody wrote:Huh, you also have a drop shadow Shader? Or it hasn't been published?

I have dozens of shaders that I did to myself but I never published (except for Alpha Threshold and old CC effects). Most of them still needs proper descriptions for parameters, some code clean up to remove commented junk, and proper usage examples. Like I said in another topic, I intend to publish them sometime but I never find the time to do it. Someday perhaps...
Scirra Employee
B
131
S
46
G
16
Posts: 706
Reputation: 16,065

Post » Wed Feb 11, 2015 8:37 pm

Animmaniac wrote:I recommend posting a minimal repro capx as example if you find glitches like these, otherwise is hard for someone to know if it's really a bug. There's too much variables involved, and sometimes depending how it is setup it doesn't show up (like this time). I tested your shader and it worked as expected initially. But it needs a different stack order to manifest.

As said above it will get a little tricky given the custom Shaders, but I guess Ashley will just have to install them. Will look into it.

Somebody wrote:I have dozens of shaders that I did to myself but I never published (except for Alpha Threshold and old CC effects). Most of them still needs proper descriptions for parameters, some code clean up to remove commented junk, and proper usage examples. Like I said in another topic, I intend to publish them sometime but I never find the time to do it. Someday perhaps...

You really should, people seem to like those things :)
B
19
S
6
G
6
Posts: 1,101
Reputation: 5,646

Previous

Return to Effects

Who is online

Users browsing this forum: No registered users and 0 guests