- Home /
Setpixels leads to a blank texture?
Hello!
I am trying to multiply two textures together and output the result on to a plane for testing purposes. The textures are read/write enabled. The issue is that although I receive no errors in the console the output texture is always blank. I have tried to just get the pixels from one of the input textures and then set them to the output without altering them in any way but I still end up with the same error.
Code posted below;
using UnityEngine;
using System.Collections;
public class TextureBlend : MonoBehaviour {
public Texture2D noise1;
public Texture2D noise2;
public GameObject target_Object;
Color[] _noise_Array1;
Color[] _noise_Array2;
Color[] _output_Array;
Texture2D output_Texture;
// Use this for initialization
void Start () {
output_Texture = new Texture2D (256, 256);
_noise_Array1 = noise1.GetPixels();
_noise_Array2 = noise2.GetPixels();
for (int i = 0; i < (256*256); i++) {
_noise_Array1[i] *= _noise_Array2[i];
}
_output_Array = _noise_Array1;
output_Texture.SetPixels (_output_Array);
target_Object.renderer.material.mainTexture = output_Texture;
}
}
Any ideas?
Comment
Answer by GameVortex · Feb 12, 2014 at 03:09 PM
Remember to use **Texture2D.Apply** to actually apply the SetPixels changes.
I actually realized my mistake shortly after posting but couldn't edit it. Thanks for the reply however.
Your answer
![](https://koobas.hobune.stream/wayback/20220613133307im_/https://answers.unity.com/themes/thub/images/avi.jpg)