title: How to get the room (or screen) coordinates from inside a Gamemaker Studio 2 shader?
body: <p>I'm mostly new to writing shaders, and this might not be a great place to start, but I'm trying to make a shader to make an object "sparkle." I won't get into the specifics on how it's supposed to look, but to make it I need a value that changes with the object's position in the room (or on the screen, as the camera is fixed). I've tried v_vTexcoord, in_Position, gl_Position, and others without the intended result. If I've used them wrong or missed something, I wouldn't be surprised, but any advice is helpful.</p>
  
  <p>I don't think they'll be helpful but here's my vertex shader:</p>
  
  <pre><code>//it's mostly the same as the default
  // 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;
  varying vec3 v_inpos;
  
  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;
      v_inpos = /*this is the variable that i'd like to set to the x,y*/;
  }
  
  </code></pre>
  
  <p>and my fragment shader:</p>
  
  <pre><code>//
  //
  //
  varying vec2 v_vTexcoord; //x is &lt;1, &gt;.5
  varying vec4 v_vColour;
  varying vec3 v_inpos;
  uniform float pixelH; //unused, but left in for accuracy
  uniform float pixelW; //see above
  
  void main() //WHEN AN ERROR HAPPENS, THE SHADER JUST WON'T DO ANYTHING AT ALL.
  {
      vec2 offset = vec2 (pixelW, pixelH);
      gl_FragColor = v_vColour * texture2D( gm_BaseTexture, v_vTexcoord );
  
      /* i am planning on just testing different math until something works, but i can't
      vec3 test = vec3 (v_inpos.x, v_inpos.x, v_inpos.x); //find the values i need to test it
      test.x = mod(test.x,.08);
      test.x = test.x - 4;
      test.x = abs(test.x);
  
  
      while (test.x &gt; 1.0){
          test.x = test.x/10;
      }
      test = vec3 (test.x, test.x, test.x);
      gl_FragColor.a = test.x;
      */
      //everything above doesn't cause an error when uncommented, i think
  
      //if (v_inpos.x == 0.0){gl_FragColor.rgb = vec3 (1,0,0);}
      //if (v_inpos.x &gt; 1)  {gl_FragColor.rgb = vec3 (0,1,0);}
      //if (v_inpos.x &lt; 1)  {gl_FragColor.rgb = vec3 (0,0,1);}
  }
  </code></pre>
  
  <p>if this question doesn't make sense, i'll try to clarify any other questions in the comments.</p>