Local space and local texcoords for sprite shaders?

Hi.

When you use a fragment shader on a sprite that uses an atlas with multiple images, the value of var_texcoord0 seems to be for the entire atlas, not just the current image on the atlas being used by the sprite. Additionally, when you use a vertex shader on a sprite, position appears to be in world space instead of local space.

I know that one way to get around these limitations is to manually calculate the texcoords for that particular image and hard-code it into the shader (or pass it as a sprite constant), and to constantly pass the world position of the sprite as a sprite constant to subtract from the position variable in the vertex shader. However, these seem to be hacks/workarounds that are far from optimal.

I would like to be able to get the local space and local texcoords for shaders being used on a sprite without having to hard-code values or use sprite constants. As far as I know, shaders in Unity have the ability to pull the object’s world position at will, so I know it’s possible for a feature like this to exist.

1 Like

Not possible, I want it too.

I’d like to be able to build uvs at runtime also.

You should make an issue here with your request also https://github.com/defold/editor2-issues

Correct me if I’m wrong, but I don’t think that’s the right place to open this feature request. This feature request is for the Defold engine, not for the editor.

All feature requests should go there so that they can be tracked regardless if they are for the editor or engine. Maybe the git readme should be changed to clarify this.

Yes, I’m actually going to go through everything tagged as “engine” and make sure these get fed into our internal JIRA for the engine.

Done: https://github.com/defold/editor2-issues/blob/master/README.md

1 Like