Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

The shader is awesome but when I apply it the sprites lose their modulate color changes, which is unfortunate! Do you know how this could be fixed? I think it might have worked in the past but doesn't anymore due to Godot 4 changes

With a bit of research i found a solution! Here's the code with changes i did:


shader_type canvas_item;

uniform sampler2D flowMap; //Displacement map

uniform float strength;    //Force of the effect

uniform float speed;       //Speed of the effect

uniform int frames : hint_range(1, 10); //Frames of the effect

varying vec4 v_vertex_color;

void vertex() {

v_vertex_color = COLOR;

}

//Returns a value between 0 and 1 depending of the frames -> exemple: frames = 4, frame 1 = 0.25

float clock(float time){

float fframes = float(frames);

return floor(mod(time * speed, fframes)) / fframes;

}

void fragment(){

float c = clock(TIME); //Get clock frame

vec4 offset = texture(flowMap, vec2(UV.x + c, UV.y + c)) * strength; //Get offset

//COLOR = texture(TEXTURE, vec2(UV.x,UV.y) + normal.xy); //Apply offset

COLOR = v_vertex_color *  texture(TEXTURE, vec2(UV.x,UV.y) + offset.xy  - vec2(0.5,0.5)*strength ) ; //We need to remove the displacement

}

// TEST CLOCK

/*

void fragment(){

float c = clock(TIME);

COLOR = vec4( c, c, c, 1);

}

*/