I want the water to be transparent so I can see any sprites under it with the shader too. When I try to just assign the shader to that part of a surface I get a crash
The Xwave in the shader is multiplied by v_vTexcoord.y for that effect, so instead try multiplying it with (1.0 - v_vTexcoord.y). That should invert the value and the effect.
I'm getting a error when trying to get the x of the texel uniform, the compile error tab says it's because I'm referring to 'x' but it's just exactly of you written it in the video. I removed the x and in works fine but I'm confused about it
Thanks for this tutorial. I tried this on my android phone but the shader stops running after 65 secs. Tested a few times. However in windows it works well and the shader runs all the time. Anyone knows why this restriction on android phone? I am wondering if this is "android only" problem.
Greetings, I had the same problem, I got some help from Russel at YoYo. "Hi, Our QA team have reviewed your attached project and ask that you add 'precision highp float;' to the top of your SH_Water.fsh. At present you are passing 'current_time' in as a float and that is overflowing a medium precision float that is used by default on Android. " SH_Water.fsh. // // Simple passthrough fragment shader // precision highp float; varying vec2 v_vTexcoord; varying vec4 v_vColour;
Hey, I made a new video about shaders, especially for beginners. Watch it here: ruclips.net/video/mVao4aP0Hg0/видео.html Hope that helps you understand how shaders work!
Man, your tutorials are the best on youtube please never stop!!!
Really good tutorial, now understand alot more about shaders!
by me its not moving why?
I want the water to be transparent so I can see any sprites under it with the shader too.
When I try to just assign the shader to that part of a surface I get a crash
Is there a way for me to apply the shader to the background layer only
Well, you have to find a way to draw it manually and apply the shader to that draw call. Also make sure to pass in any necessary uniforms.
Lets say I wanted my water effect to be more intense at the top of the screen instead of the bottom, is there an easy way to do that?
The Xwave in the shader is multiplied by v_vTexcoord.y for that effect, so instead try multiplying it with (1.0 - v_vTexcoord.y). That should invert the value and the effect.
Thank you! I was able to use this on other shaders too, not just water. Very helpful, thanks for the tutorial! :)
Greetings Matharoo, great Tut as usual, can you please tell me how to have the water effect intensity the same from top to bottom?
Thanks.
Paul.
I'm getting a error when trying to get the x of the texel uniform, the compile error tab says it's because I'm referring to 'x' but it's just exactly of you written it in the video. I removed the x and in works fine but I'm confused about it
Same here
I had the uniform as float texel, changed it to vec2 texel and now .x works
Thanks for this tutorial.
I tried this on my android phone but the shader stops running after 65 secs. Tested a few times.
However in windows it works well and the shader runs all the time.
Anyone knows why this restriction on android phone?
I am wondering if this is "android only" problem.
No idea why that would happen... I suggest posting on the GMC forum: forum.yoyogames.com/
Greetings, I had the same problem, I got some help from Russel at YoYo.
"Hi,
Our QA team have reviewed your attached project and ask that you add 'precision highp float;' to the top of your SH_Water.fsh. At present you are passing 'current_time' in as a float and that is overflowing a medium precision float that is used by default on Android. "
SH_Water.fsh.
//
// Simple passthrough fragment shader
//
precision highp float;
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
Hello, I could not understand what you explained in the video because I speak Spanish, can you explain how each line of code works?
Hey, I made a new video about shaders, especially for beginners. Watch it here: ruclips.net/video/mVao4aP0Hg0/видео.html
Hope that helps you understand how shaders work!
can i have the shader code. beacuse i copy it by hand and gives me errors
What is the error?
Thank you so much
It helped a lot! :D
Great tutorial you are truely awesome.
Why can’t you just be able to check a box that says reflect? Why is there so much convoluted coding for a simple reflection?
It Works perfectly in GMS 1.4 , Thanks.
Can you pass me the project... Please? I don't understand why I have some errors.
*VERTEX SHADER*
//
// Simple passthrough vertex shader
//
attribute vec3 in_Position; // (x,y,z)
//attribute vec3 in_Normal; // (x,y,z) unused in this shader.
attribute vec4 in_Colour; // (r,g,b,a)
attribute vec2 in_TextureCoord; // (u,v)
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
void main()
{
vec4 object_space_pos = vec4( in_Position.x, in_Position.y, in_Position.z, 1.0);
gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * object_space_pos;
v_vColour = in_Colour;
v_vTexcoord = in_TextureCoord;
}
*PIXEL SHADER*
//
// Simple passthrough fragment shader
//
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform float Time;
uniform vec2 Texel;
const float Xspeed = 0.01;
const float Xfreq = 20.0;
const float Xsize = 5.0;
const float Yfreq = 100.0;
const float Ysize = 20.0;
void main()
{
//X wave
float Xwave = sin(Time*Xspeed + v_vTexcoord.y*Xfreq) * (Xsize*Texel.x) * v_vTexcoord.y;
float Ywave = sin(Time*Xspeed + v_vTexcoord.y*Yfreq) * (Ysize*Texel.y) * v_vTexcoord.y;
gl_FragColor = v_vColour * texture2D( gm_BaseTexture, v_vTexcoord + vec2(Xwave,Ywave));
}
*CREATE EVENT*
image_speed=0
uniTime = shader_get_uniform(shader_water,"Time");
uniTexel = shader_get_uniform(shader_water,"Texel");
*DRAW EVENT*
shader_set(shader_water)
shader_set_uniform_f(uniTime, current_time)
var tex = sprite_get_texture(sprite_index,image_index)
shader_set_uniform_f(uniTexel,texture_get_texel_width(tex),texture_get_texel_height(tex))
draw_self()
shader_reset()
Thank you.
dnd?
You're so lucky, they don't have laugh reacts on here... We'd smash it.
@@deffyme7357 LOL :D
Please try panjad
Xwave should use cos...
It's a sin wave. We're not dealing with trig here.