[DISCUSSION] my shader effect is broken, but only on export?

Share your Construct 2 effect files

Post » Mon May 18, 2015 12:53 am

Hi!

So recently I've tried to learn GLSL and I managed to put together a shader for the finish screen in Airscape. It works totally fine in preview, but weirdly enough on export it's slightly broken.

It seems to be independent of export platform and browser.

Here's the project that demonstrates the brokenness

Here's the shader itself.

(The shader is in two parts, but both share the same bug so I thought I'd provide the one part).

In preview, it looks like this:
Image

Exported, it looks like this.
Image

I briefly tested it on a Mac and it looked even worse in export, with weird pixel glitching etc. No idea if it's related, or a separate problem.

Does anyone have any idea what's going on? I'm assuming the problem lies in the shader data being added to c2runtime.js on export. The problem happens with or without minification though.

Thanks!
Last edited by sqiddster on Mon May 18, 2015 11:57 pm, edited 1 time in total.
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,699

Post » Mon May 18, 2015 6:36 am

I've had some issues with shaders not working properly after sprite-sheeting, try setting downscaling to LOW on the project properties, see if it has any effect.
Image
B
80
S
30
G
12
Posts: 517
Reputation: 12,713

Post » Tue May 19, 2015 10:42 am

@Lof thank you! That was the problem. I managed to work around it by making the source image 30x30px, I guess because that's a power of 2 with a 1px margin on each side.
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,699

Post » Tue May 19, 2015 11:51 am

Cool, glad i could help.
Image
B
80
S
30
G
12
Posts: 517
Reputation: 12,713

Post » Tue May 19, 2015 12:56 pm

In your case you must declare this variable ;
Code: Select all
vec2 resolution = vec2( 1./pixelWidth, 1./pixelHeight);


and inside main code ;
vec2 uv = vec2(vTex.x * resX, vTex.y * resY); <--- your code

this is the same but easy ...
try :
Code: Select all
void main()
{
vec2 uv = (1.*vTex)*  resolution.xy ;     // this will center correctly the sun
.
.
.
}
B
66
S
24
G
29
Posts: 823
Reputation: 22,644


Return to Effects

Who is online

Users browsing this forum: No registered users and 0 guests