Fixing the Radial Starfield shader to get in sprite center

Get help using Construct 2

Post » Tue Sep 20, 2016 5:58 pm

I'm fighting again with a shader XD, in this case i want to modify the radial starfield, this one:
effect-radial-starfield_t128707

The first wrong thing is that with an empty template i put a sprite, add the shader and the radial appears in the bottom left instead instead the center ¿? :( .

In the demo of the shader is in the middle so i don't know if with the C2 updates something changed in coordinates but i tried various config on C2 and i was unable to get in the center :( .

So, i opened the .fx and tried to change various things but only was able to change the Y position, never the X ¿?

I tried to do that here:
Code: Select all
vec2 vScreenPos = vScreenUV * 2.0 - 1.0;
vScreenPos.x *= resolution.x / resolution.y;


And after various hours changing values in all the entire shader nothing, i was able to change everything less that XD.

For my game i want get some kind of parallax/follows the mouse or the hero, so i will need the center of the radial always be in the center of the sprite, then with events i can move it to do some kind of parallax depending of the mouse/hero position.

I guess a X.pos/Y.pos parameter will be the ideal, but with simply get the radial always in the center of the sprite will be enough for me, i can edit after to get what i want.

@Gigatron Any idea what is wrong ? :S

Thanks in advance!
Last edited by matriax on Tue Sep 20, 2016 6:37 pm, edited 1 time in total.
B
25
S
10
G
3
Posts: 577
Reputation: 4,556

Post » Tue Sep 20, 2016 6:36 pm

I solved a thing, one of the problems was in the .xml

Code: Select all
<extend-box-horizontal>1</extend-box-horizontal>
<extend-box-vertical>1</extend-box-vertical>


With that at start of layout appears wrong, but when you resize the window the center of the radial starfield goes to the center of the window, i don't know why but works. (using letterbox scale on"Fullscreen in Browser")

The problem is that if i move the shader not matter, the startfield is processed at the center of the window not the sprite that have the shader... :(
B
25
S
10
G
3
Posts: 577
Reputation: 4,556

Post » Tue Sep 20, 2016 6:54 pm

matriax wrote:I solved a thing, one of the problems was in the .xml

Code: Select all
<extend-box-horizontal>1</extend-box-horizontal>
<extend-box-vertical>1</extend-box-vertical>


With that at start of layout appears wrong, but when you resize the window the center of the radial starfield goes to the center of the window, i don't know why but works. (using letterbox scale on"Fullscreen in Browser")

The problem is that if i move the shader not matter, the startfield is processed at the center of the window not the sprite that have the shader... :(


Just insert this inside lines ... set vscreenpos to vtex and center this one by *2.-1.0;

vScreenPos=vTex*2.-1.;

Code: Select all
vec2 vScreenPos = vScreenUV * 2.0 - 1.0;
   vScreenPos.x *= resolution.x / resolution.y;

   vScreenPos=vTex*2.-1.; // <----------- ***********
B
66
S
24
G
29
Posts: 823
Reputation: 22,644

Post » Tue Sep 20, 2016 7:25 pm

Ahhh! Worked perfect @Gigatron THANKS! !

Now i'm going to try the parallax effect to see if i cant get the effect desired. If not i will try again the X.pos and Y.pos with the shader fixed.
B
25
S
10
G
3
Posts: 577
Reputation: 4,556


Return to How do I....?

Who is online

Users browsing this forum: sean080 and 6 guests