Ehrm, I just realize you need to update the textures dynamicly (do you?) so using readpixelfast like this would be too slow.
I take it you are rendering the shadow caster from the lights viewpoint, with the background white and the caster black and this forces you to use blendmode 2? In this case I'd suggest to simply swap the colors and use mode 1. EntityColor m,0,0,0 won't work for the shadow caster, but you may paintmesh it with a brush that is made of a white texture with fx 1 etc. Then use the black color for the background instead.
All you need to do is to store the old brush(es), using GetSurfaceBrush(mesh). Although the command is creating a copy of the original brush, I think the original brush will be removed as soon as you are painting the meshes with an other brush. So don't worry too much about ram.
I take it you are rendering the shadow caster from the lights viewpoint, with the background white and the caster black and this forces you to use blendmode 2? In this case I'd suggest to simply swap the colors and use mode 1. EntityColor m,0,0,0 won't work for the shadow caster, but you may paintmesh it with a brush that is made of a white texture with fx 1 etc. Then use the black color for the background instead.
All you need to do is to store the old brush(es), using GetSurfaceBrush(mesh). Although the command is creating a copy of the original brush, I think the original brush will be removed as soon as you are painting the meshes with an other brush. So don't worry too much about ram.