Guys, in Materials documentation there is for Sprites Samplers:
“If you need multiple textures in a shader, you can use render.enable_texture() and set texture samplers manually from your render script.”
If I want to have such second texture available - and I want it to be drew on one texture in form of one tilesource. For example I have one frame/sprite in tilesource as tile 1, and below it I duplicate the same image, but with different colors (e.g. normal map) - this second image is in tile 2. By default I would use this tilesource as Texture for Sprite and a “tile 1” animation from it as Animation Property for Sprite.
Example visualization of such tilesource:
The upper part is tile 1 (with albedo/Diffuse data) and below is corresponding tile 2 (with normal data)
So in such sprite’s fragment program I have Sampler2D, which contains only information about colors (diffuse/albedo) and How could I access second information - normal map, from tile below?
I think I can:
To first render target draw the sprite with usual, default material, that will output color as usual.
To second render target, I will somehow enable other material for such sprite () - this material’s fragment program will instead of drawing usual color, offset the Sampler2D by the height of a tile and take data from row below, namely from normal map and save it as output color, right?
Then I could proceed with magic with such 2 render targets, right?
I intended to put () mark between my understanding, because I’m missing this piece - how can I change material for Sprite in render pipeline? Like I do when I set material for quad? A material from render’s list of Materials?
Will the above still work if I put more frames into tilesource? What when I switch animation to tile next to tile 1 in upper row? If I offset this tile to lookup normal data from a frame that is below, in second row, will it works (or simply speaking, won’t it mess up coords if I move to the right in tileource? )
Or should I totally change approach and make second texture with normal data in somehow different way attached to sprite? Atlas approach? (I don’t want to go with Model approach to which I actually can attach multiple textures)
(I originally posted it on Discord, but I think it’s worth noting on forum, as at some point someone might be at the same stage as me rn )