I am writing a 2D data visualization program.
Problem #1. I have a lot of sprites with special shaders. These sprites are divided into groups and rendered to different render textures separately. When one group is being rendered, the others should be invisible. Because groups interfere with each other if rendered together. The problem is, I don't know the exact number of groups beforehand. If I use a lot of cameras with different layers, I may run out of layers. Is there a better way other than culling masks?
Then problem #2. Finally I need to blend all these render textures together to get the final result (just adding them together). It seems not right to write a shader with 10+ texture inputs, and still the number of textures are unknown beforehand. So what I should do for this step?
Problem #1:
Option one: You can use one layer but several cameras with different positions, so that each camera sees only its own sprite group.
Option two: You can use one camera and layer but turn the sprite groups on and off depending on what needs to be rendered. You can call Camera.Render, then change active group and render texture, call Camera.Render again and so on.