• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Beginner Problem on Shaders

N

Neihra

Guest
Hey all !

I'm quite new about using shaders and i know that my problem is really simple but i can't find how to use my shader... I think that tere is something i didn't understand.

Here is my shader:



I can apply it to the application_surface:





And it gives me that:



But when i try to apply only on the liquid (the linked sprite is the liquid (or potion as you want)):



And it gives me that:





Any idea? :)
 
B

basement ape

Guest
You'll probably get more help if you post the code as text and not images. Otherwise people will have to type it out themselves just to be able to test it :eek:
 
N

Neihra

Guest
I think i'm tired x)

Shader:

Code:
varying vec2 v_vTexcoord;
varying vec4 v_vColour;

varying vec2 fragCoord;

uniform vec3      iResolution;           // viewport resolution (in pixels)
uniform float     iTime;                 // shader playback time (in seconds)

void main()
{

vec2 uv = fragCoord.xy / iResolution.xy;

float w = (0.5 - (uv.x)) * (iResolution.x / iResolution.y);
    float h = 0.5 - uv.y;
float distanceFromCenter = sqrt(w * w + h * h);

float sinArg = distanceFromCenter * 100.0 - iTime * 10.0;
float slope = cos(sinArg) ;
vec4 colors = texture2D(gm_BaseTexture, uv + normalize(vec2(w, h)) * slope * 0.02);

gl_FragColor = colors;

}

Create event:

Code:
application_surface_draw_enable(false);

u_resolution = shader_get_uniform(sha_test, "iResolution");

u_time = shader_get_uniform(sha_test, "iTime");

sec = 0;

Step event:

Code:
sec += 1/60;
Post Draw event:

Code:
shader_set(sha_test);

shader_set_uniform_f(u_resolution, room_width, room_height);

shader_set_uniform_f(u_time, sec);

draw_self();

shader_reset();
 
Top