private static Texture2D MergeShadowAndBody(Studio studio, Texture2D shadowTexture, Texture2D bodyTexture) { if (shadowTexture.width != bodyTexture.width || shadowTexture.height != bodyTexture.height) { Debug.LogError("shadowTexture.width != bodyTexture.width || shadowTexture.height != bodyTexture.height"); return(bodyTexture); } Color[] bodyPixels = bodyTexture.GetPixels(); Color[] shadowPixels = shadowTexture.GetPixels(); for (int i = 0; i < shadowTexture.width * shadowTexture.height; i++) { Color bodyPixel = bodyPixels[i]; if (bodyPixel == Color.clear) { continue; } Color shadowPixel = shadowPixels[i]; Color resultPixel = (shadowPixel == Color.clear ? bodyPixel : BlendingHelper.BlendTwoColors(bodyPixel, shadowPixel, BlendFactor.One, BlendFactor.OneMinusSrcAlpha)); shadowPixels[i] = resultPixel; } shadowTexture.SetPixels(shadowPixels); shadowTexture.Apply(); return(shadowTexture); }
private static void ApplyVariation(VariationProperty variation, ref Texture2D outTex) { Color[] outPixels = outTex.GetPixels(); for (int i = 0; i < outTex.width * outTex.height; i++) { Color pixel = outPixels[i]; if (pixel.a <= 0f) { continue; } Color outPixel = BlendingHelper.BlendTwoColors(variation.color, pixel, variation.colorBlendFactor, variation.imageBlendFactor); outPixels[i] = outPixel; } outTex.SetPixels(outPixels); outTex.Apply(); }