Hi all,
I have an array of MTLTexture, that comes from my Renderer draw method.
When I get MTLTexture, I want to use it as SCNMaterial diffuse.contents in a SCNScene, and after that, export it as CIImage and then to jpeg/png for the web.
In order to easily explain the problem I exported 3 images.
-
Original MTLTexture
-
CIImage from MTLTexture
-
UIImage from CIImage
PROBLEM:
I get different colors, as you can see, for my blue line. The first picture is the line in MTLTexture as I intended it to be, and is generated by the overlapping of a very high number of dots with very low alpha.
In the second and third images for some reason the lines have a low alpha as if the dot blending is not additional.
The alpha channel is calculated in the shader’s fragment function like this:
baseColor.a = color.a / overlapping;
where overlapping means how many blue dots whit same alpha overlap per space unit.
If I set “baseColor.a = 1.0;”, so no alpha channel is intended to use in my texture, then the result is what I expect and MTLTexture CIImage and UIImage coincide.
For any other values of alpha, I get the error described above.
Any ideas on how I can solve this problem?