Understanding GLSL Shaders

The example on that page is expecting "postition" to go from 0 to 1 across the view port going from left to right, and top to bottom.

What you can do is pass a varrying vec2 from the vertex to the fragment shader.

gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * object_space_pos;
pos = gl_Position.xy * vec2(0.5,-0.5) + 0.5;

With an orthographic projection, the extent of the view port will be contained within the values of gl_Position.xy of -1 to 1.

If you want the effect to cover the whole view port, you need to draw something across the whole view port.
 
N

Nyky

Guest
I'm not sure I understand how to implement your solution, I added the code you wrote to the vertex tab in my shader but it didn't change anything, If it helps the size of the object I'm drawing the shader to is w400 pixels, h225 pixels, I've looked over and read on GLSL but gamemaker implementations seem to be slightly different
 
does your image cover trhe whole view port? If not, what you can do instead is pass the texture coordinates from the vertex to fragment shaders. If you mark the sprite "used for 3D" ("separate texture page" in gms2), then the texture coordinates can be used in place of what you are calculating for "position" in your shader.
 
N

Nyky

Guest
it does cover the whole view port, I'm not sure how to pass a variable through from the vertex to the fragment shader
 
N

Nyky

Guest
I found the solution on another forum post, i just ended up overriding gl_FragCoord and found an example of how to pass a variable from vertex to fragment, thank you though
 
C

CreatorAtNight

Guest
Just wanted to say I'm happy to see the cool dogs are finding their way to Game Maker these days! :D Working on some MMO catch I assume? ;P
 
Top