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

Position of Sprite in Shader

RujiK

Member
Is it possible to get a sprite's world-position inside of the fragment shader without passing a uniform?

v_vPosition/in_Position would be great except that it changes on a per-pixel basis. Meaning the v_vPosition at the bottom left of the sprite is different from the top right. I am trying to figure out how to find a single position for the whole sprite.

It doesn't even need to be very accurate. I just need a position-ish number that will stay the same for the whole sprite

Thanks for your help!
 
Do you mean when using draw_sprite functions or instance sprites? If so, the only thing I can think of is to encode the sprites position somehow into the image_blend or colour argument variables.

If you are drawing sprites using a vertex buffer, then you can add a custom vertex attribute to carry the sprite's position.
 
Top