Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for secondary textures #12

Open
tullrich opened this issue Oct 21, 2020 · 1 comment
Open

Support for secondary textures #12

tullrich opened this issue Oct 21, 2020 · 1 comment

Comments

@tullrich
Copy link
Contributor

tullrich commented Oct 21, 2020

Later version of unity now provide a method of associating secondary textures with a sprite atlas. This can be used for normal maps, emissive maps, or even arbitrarily named texture bindings in a Shader Graph. More info can be found here.

I'm interested in adding support for these to MetaSprite, but I have a few questions regarding how to best do so.

I think adding a @secondary("binding name") meta directive would be a good approach. Each of these layers could written as a separate texture asset and then associated with the main atlas as a secondary texture with the provided binding name.

A few questions though:

  1. Would it be best to provide two directives @secondary("Name") and @secondary-target("Name", "binding name") similar to sub images so that multiple layers could be combined into one secondary atlas? Was that the motivation behind using two in the case of sub images (I don't use this feature)?
  2. I imagine it would be necessary to support secondary textures on sub images as well. What would be a good syntax for this?
  3. MetaSprite will need to write secondary textures as separate assets. I see that sub-images already require this functionality and that I should be able to reuse part of that atlas serialization code. Is this correct? The sprite packing in the secondary texture needs to be exactly the same as the primary atlas. Is that possible?

Finally, thanks for the great importer!

@WeAthFoLD
Copy link
Owner

Hi, sorry for the delayed replay. I forgot to check GitHub past few months 😿

If we define main image / sub image created using @sub and @subTarget as image, then each image can have multiple secondary textures. It seems that the appropriate syntax can be:

@secondary("image name", "secondary texture name")

in which image name denotes sub image target, secondary texture name denotes the following 'Name' setting:

I don't see the need for two meta directives.

There should be a special value for image name to denote the main image. Maybe something like "_main"?

Above answers question 1 and 2. For question 3: Yes atlas generator code is reused now in creating main and sub images. To support this functionality, atlas info for one image will be reused for subsequent generation of secondary texture, which is another problem to tackle.

I wonder if you have investigated further on the feature and do you still need it? I may find some time to implement it myself, or give you necessary assistance if you want to do it yourself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants