Are textures useable for sprites AND materials?

Hey hey :slight_smile:

We are currently building a customizer. All our characters possible eyes are inside the same texture atlas. This allows us to create sprites and display them in the ui. We then take the texture from the texture atlas in code and pass it to the material of our characters eyes-meshInstance. This way we can use a shader to only render the correct pair of eyes.

But since our asset is a texture atlas and not a texture, I can’t link it to the material in the editor. If I would upload the texture without creating an atlas, I would be missing the possibilities to create sprites. So I was wondering if there was a smart way of having the benefits of both a texture and a texture atlas without uploading the same asset twice?

Thanks

Hmm… you can’t assign in the editor, but you can assign the texture from the texture atlas to a material via code: https://api.playcanvas.com/classes/Engine.TextureAtlas.html#texture

1 Like

Yeah, thats what we are currently doing. I was just wondering if there was a different solution for that, since its nice to be able to set up the material in the editor instead of in a script

Afraid not but is valid request: Be able to use a TextureAtlas for a material texture asset in the Editor · Issue #516 · playcanvas/editor · GitHub

1 Like

Thanks for the feature request. I guess we will work with it the way we did until now and I’ll keep an eye on that issue.

I want to steal this post at once to say how the hell do I upload a texture: v, upload one and convert it to Atlas Texture … :frowning:

Hey, upload a regular image to get a texture asset, then right click and select Create Texture Atlas from the context menu:

image

Another way is to enable this action for all image uploads. Go to your project settings → Asset Tasks and enable Create Atlases:

2 Likes