but due to this custom hair that I am using, the alpha that is on the hair texture is punching small holes through all underlying geo and showing up transparent. There are 2 hair layers (with alphas) sorted by transparency queues and using multiple passes with a zwrite off the first pass (sorry for the shaderlab speak in here). This transparency of course does not show up in the game/player, or even when the PNG Texture2D is set to RGB24. I am storing the original capture into RenderTexture.GetTemporary and doing the ReadPixels from there.
Could this be something with the Zbuffer or alphaclipping when doing the ReadPixels? (Is there a way to test the pixels for color and alpha during the reading or encoding?)
Not sure I understand the problem. If you use RGB24 texture format which you encode into PNG, you will get no transparencies.
Or is is that you do want transparencies, but some of the alpha channel in the screen contains unexpected alpha values? In that case, you’d have to use a shader that does not write that unwanted alpha. That is, when you’re using custom shader, it’s up to the shader to control what it writes into the alpha channel.
I’m having this issue too, same situation. Can anyone provide an example of the shader to use here? Currently we are using the Transparent/Cutout/Soft Edge Unlit and it looks great in game and in the scene camera view, but as soon as we save it to a render texture and encode it to png, we have the same punchthrough problem in the hair. (But we do want transparency around the model, i.e. transparent background)
Same problem here (late to the party) :
The Camera Preview displays a good looking texture whereas the image generated by RenderTexture has holes where the foreground is transparent.