Noah Copeland
Member
So I've got heat wave / retro underwater effect shader. You can see it applied to a sprite above. ^^^^
However, I'm trying to apply to a entire tile layer and the effect is...right not quite.
As you can see, it seems to be applying the effect to each tile chunk separately, instead of the whole layer.
Here's the code for reference. This is the step event of a controller object:
GML:
var lay_id = layer_get_id("Tiles");
layer_script_begin(lay_id, scr_tile_wave_fx);
layer_script_end(lay_id, scr_tile_shader_reset);
That script, scr_tile_wave_fx, goes as follows:
GML:
if event_type == ev_draw
{
if event_number == 0
{
//Create event:
uTime = floor(shader_get_uniform(shd_wave, "Time"));
uTexel = floor(shader_get_uniform(shd_wave, "Texel"));
//Draw event:
shader_set(shd_wave);
shader_set_uniform_f(uTime, current_time);
shader_set_uniform_f(uTexel, 0.0025, 0.005);
}
}
And if really curious, here's the fragment shader I picked up from nacho_chicken for the wave effect:
Code:
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform float Time;
uniform vec2 Texel;
//Modify the following three consts to change the wave effect to your liking
const float xSpeed = 0.005;
const float xFreq = 175.0;
const float xSize = 1.0;
void main()
{
float xWave = sin(Time*xSpeed + v_vTexcoord.y*xFreq) * (xSize*Texel.x);
gl_FragColor = v_vColour * texture2D( gm_BaseTexture, v_vTexcoord + vec2(xWave, 0.0));
}
So, any ideas how to get this shader to apply to the tile layer as a whole and not each separate tile cell?