Fixing the Radial Starfield shader to get in sprite center

0 favourites
  • 4 posts
From the Asset Store
A set of 10 pixel art animated magic effects with icons. 2 Fire, 2 Earth, 2 Wind, 2 Water, Portal, Explosion.
  • I'm fighting again with a shader XD, in this case i want to modify the radial starfield, this one:

    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:

    vec2 vScreenPos = vScreenUV * 2.0 - 1.0;
    vScreenPos.x *= resolution.x / resolution.y;[/code:3gompju2]
    
    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!
  • I solved a thing, one of the problems was in the .xml

    <extend-box-horizontal>1</extend-box-horizontal>
    <extend-box-vertical>1</extend-box-vertical>[/code:3ao4s55r]
    
    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...
  • I solved a thing, one of the problems was in the .xml

    <extend-box-horizontal>1</extend-box-horizontal>
    <extend-box-vertical>1</extend-box-vertical>[/code:3qox0e1n]
    
    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.;

    vec2 vScreenPos = vScreenUV * 2.0 - 1.0;
    	vScreenPos.x *= resolution.x / resolution.y;
    
    	vScreenPos=vTex*2.-1.; // <----------- ***********[/code:3qox0e1n]
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)