• 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!

Shaders 2D Vertex (Not Sprite) Shader Translation (x,y)

Status
Not open for further replies.

Edgamer63

Member
Hello, i was wondering how to translate correctly the x,y coordinates of vertex (Not sprite) in a shader...

By now, i've got a working one. But doesn't work when i replace "10. 's" with a uniform float for each value... That makes me a bit angry :c .

Probably a weird bug in my or every GML D: .

GML:
attribute vec2 in_Position;                  // (x,y)
attribute vec4 in_Colour;                    // (r,g,b,a)
attribute vec2 in_TextureCoord;              // (u,v)


varying vec2 v_vTexcoord;
varying vec4 v_vColour;
varying vec2 v_vPostion;

void main(){
    vec2 pos = vec2( in_Position.x, in_Position.y);
    pos.x+=10.;
    pos.y+=10.;
 
 
    gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * vec4(pos.x,pos.y,0.0,1.);
 
    v_vColour = in_Colour;
    v_vTexcoord = in_TextureCoord;
}
Even more weird is why this work and not this one :

GML:
attribute vec2 in_Position;                  // (x,y,z)
attribute vec4 in_Colour;                    // (r,g,b,a)
attribute vec2 in_TextureCoord;              // (u,v)


varying vec2 v_vTexcoord;
varying vec4 v_vColour;
varying vec2 v_vPostion;

void main(){
    vec2 pos = vec2( in_Position.x, in_Position.y);
    vec4 pos2=vec4(pos.x,pos.y,0.0,1.);
  
    gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * pos2;
  
    v_vColour = in_Colour;
    v_vTexcoord = in_TextureCoord;
}
thank you beforehand :D .
 

Azenris

Member
what do you mean by not work.
Are they not in the correct position?
Are they not showing at all?
Are they showing glitchy?
Is the shader not even compiling? Or maybe a runtime error?

When you replace the 10s with uniforms, are you actually sending the uniform variables in correctly
 

Edgamer63

Member
what do you mean by not work.
Are they not in the correct position?
Are they not showing at all?
Are they showing glitchy?
Is the shader not even compiling? Or maybe a runtime error?

When you replace the 10s with uniforms, are you actually sending the uniform variables in correctly
The thing is that i cant add the 10s values with uniform floats, because it glitch or seems to not work.
 
Status
Not open for further replies.
Top