uoowuo

vTextureCoord breaks, how to reliably get sprite coordinates in GLSL?

Recommended Posts

Hi!

I'm trying to apply one filter to a large number (~256) of small (32x32 px) sprites. Within the filter, I'm using vTextureCoord to get the current sprite's coordinates, to draw borders on it. vTextureCoord breaks, apparently referring to the containing canvas's coordinates instead of the individual sprites' coordinates.

BUT if I apply that same filter twice (two elements in .filters[] array), in one of the copies vTextureCoord actually does point to the sprite coordinates, and borders are drawn correctly. The other copy still points to the canvas coordinates, and the whole thing becomes laggy for some reason, and filters don't get removed when they should, too.

Live version (hover over the individual sprites to apply filter second time): http://uoowuo.github.io/cellulata/ All the sprites are white-tinted because of the first filter invocation, with incorrect vTextureCoord coordinates.

Code:
Shader https://github.com/uoowuo/cellulata/blob/master/src/classes/shaders.js#L48
First filter application https://github.com/uoowuo/cellulata/blob/master/src/classes/cell.js#L42
Second filter application https://github.com/uoowuo/cellulata/blob/master/src/classes/cell.js#L83

Hover is just for the sake of illustration, if I apply filter twice statically to all sprites, the behavior is still the same.

Thanks for your time!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.