Passing atlas tile's coordinates to a shader

Hi all,
I need to use a texture atlas in order to pack all textures and be able to using a single shared material for several object in my scene.
Actually what I’m working on it’s a shader for procedural texturing of building facades.

I successfully create the atlas and passed it to the shader:

this.texturesAtlasDomains = this.atlas.PackTextures(orderedTextureList.ConvertToArray(), 0,ATLAS_WIDTH);
...
this.material.SetTexture("atlas", this.atlas);

That works fine. Now, in order to make my shader works under unity, the coordinate returned from PackTextures should be available inside the shader ( I need to sample the right tile in the fragment shader, for this reason I need the offset of tiles inside the atlas)

Is there anyway to do that? I’m thinking of packing them inside a Texture2D, but I’m having some troubles to make it work. It seems also that I can’t pass an array of float to a shader through a shader lab property, right?

Does anyone has ever done something similar? Can anyone put me in the right direction?

thanks in advance

you can encode them an array of float in a texture ,there are pairs of func in UnityCg.cginc do that work

Thanks for the suggestion. Sorry but I’m not an expert in this field, that’s the first time I do such operations.
Could you kindly provide an example on how I can store properly a Rect (x,y,width,height) inside a texture from C#, and how to decode it from inside a cg shader?

I am a rookie too,:smile: