This is the testing Godot forums! All forum posts unique to this forum will be deleted! Please use the main forums here for any posts you want to keep. All forum rules still apply.

Can anyone fix this shader problem for me? (Answered)

MentirasMentiras Posts: 37Member
edited April 2020 in Shaders

So I found this "portal" shader on youtube and hacked it together as best as I could. What I would like it to do is to keep the animation within the sprite, currently, it does not. I tried to get some help from another youtube shader guy (the original author has been mia for 2 years) but I have not been able to get the results I am looking for =/

    shader_type canvas_item;

    uniform float timescale = 0.5;

    uniform sampler2D normal;

    void fragment(){

        NORMAL = texture(normal,UV).rgb * vec3(2.0,-2.0,1.0) - vec3(1.0,-1.0,0.0);
        float PI = 3.14159265358979323844;

        vec2 shifted_UVs = UV - vec2(0.5,0.5);

        vec2 angle_offset = vec2(cos(TIME*timescale)*0.6, sin(TIME*timescale)*0.6);
        float angle = 0.5*atan(shifted_UVs.x+angle_offset.x, shifted_UVs.y+angle_offset.y)/PI;

        float wave_amplitude = 0.01;
        float wave_number = 1.0;
        float radius = length(shifted_UVs)+cos(TIME*2.1)*cos(angle*wave_number*PI+TIME)*sin(angle*wave_number);

        vec2 polar_TCs = vec2(radius*2.0, angle + 0.5);

        vec2 screen_radius = vec2(0.02);
        vec2 screen_angle = vec2(radius*radius*cos(TIME+angle*wave_number*PI*2.0), radius*radius*sin(TIME+angle));

        vec2 screen_polar_SSCs = SCREEN_UV+vec2(screen_angle*screen_radius);

        vec4 screen_texture = texture(SCREEN_TEXTURE, screen_polar_SSCs);
        vec4 sprite_texture = texture(TEXTURE, polar_TCs);

        if(radius < 0.5){
            if (sprite_texture.a < 0.25){
                COLOR.rgba = screen_texture.rgba;
                COLOR.rgba = sprite_texture.rgba;


  • MegalomaniakMegalomaniak Posts: 2,580Admin

    You should perhaps link to the youtube videos you are talking about.

  • MentirasMentiras Posts: 37Member

    That's where I asked for help, and I tried but could not figure it out.
    and I could not find the original link, but ill keep looking and update if I do.

  • MegalomaniakMegalomaniak Posts: 2,580Admin
    edited March 2020

    Aha, there we go, finally a comprehensible question(as in, clearly presenting the problem, or perhaps I just misread the first post):

    So I found this portal shader on youtube and hacked it together as best as I could. What I'd like it to do is make the animation all contained inside the sprite I use (in this case the godot logo) what it does is animates and cuts off at the edges of the sprite.

    change line 12 to:

                    vec2 shifted_UVs = (UV - vec2(0.5,0.5)) * 2.0;
  • MentirasMentiras Posts: 37Member

    here is the original

  • MentirasMentiras Posts: 37Member

    Thank you very much. That was exactly what I was looking for =)

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.