[Procedural Textures] Unity Seizes....


I have setup the plane as shown, and when I try the following code:

using UnityEngine;
using System.Collections;

public class MagmaProcedural:MonoBehaviour {
	
	private Vector2 Noise1Rate;
	private Vector2 Noise2Rate;
	private Vector2 Noise3Rate;
	private Vector2 Noise4Rate;
	private const float RateMultiplier=1.0f;
	
	public Texture2D Noise;
	
	private Texture2D Magma;
	private Texture2D Illumination;
	private Vector2 Noise1Offset;
	private Vector2 Noise2Offset;
	private Vector2 Noise3Offset;
	private Vector2 Noise4Offset;
	// Use this for initialization
	void Start () {
		Magma=new Texture2D(2048,2048,TextureFormat.ARGB4444,false);
		Illumination=new Texture2D(2048,2048,TextureFormat.Alpha8,false);
		this.renderer.material.mainTexture=Magma;
		this.renderer.material.SetTexture("_Illumin",Illumination);
		Noise1Rate=new Vector2(0.007f,0.017f);
		Noise2Rate=new Vector2(-0.019f,0.005f);
		Noise3Rate=new Vector2(0.003f,-0.023f);
		Noise4Rate=new Vector2(-0.013f,-0.011f);
	}
	
	// Update is called once per frame
	void Update () {
		float Illum,R,G,B;
		int X,Y;
		for (X=0;X<2048;X++)
			for (Y=0;Y<2048;Y++)
			{
				Illum=Noise.GetPixel(((int)Noise1Offset.x+X)>>3,((int)Noise1Offset.y+Y)>>3).r*
					Noise.GetPixel(((int)Noise2Offset.x+X)>>3,((int)Noise2Offset.y+Y)>>3).g*
					Noise.GetPixel(((int)Noise3Offset.x+X)>>3,((int)Noise3Offset.y+Y)>>3).b*
					Noise.GetPixel(((int)Noise4Offset.x+X)>>3,((int)Noise4Offset.y+Y)>>3).a*4.0f;
				R=G=B=Illum;
				if (R>1.0f)R=1.0f;
				if (Illum>3.0f) R-=Illum-3.0f;
				if (G>2.0f)G=2.0f;
				G-=1.0f;
				if (B>3.0f) B=3.0f;
				B-=2.0f;
				Magma.SetPixel(X,Y,new Color(R,G,B,0.0f));
			}
		Noise1Offset+=Noise1Rate;
		Noise2Offset+=Noise2Rate;
		Noise3Offset+=Noise3Rate;
		Noise4Offset+=Noise4Rate;
	}
}

Unity locks up, I am very new to unity, but an experienced C Sharp coder, could some one please explain to me what I am doing wrong, and how I should fix?

EDIT: I changed the code to:

using UnityEngine;
using System.Collections;

public class MagmaProcedural:MonoBehaviour {
	
	private Vector2 Noise1Rate;
	private Vector2 Noise2Rate;
	private Vector2 Noise3Rate;
	private Vector2 Noise4Rate;
	private const float RateMultiplier=160.0f;
	
	public Texture2D Noise;
	
	private Texture2D Magma;
	private Vector2 Noise1Offset;
	private Vector2 Noise2Offset;
	private Vector2 Noise3Offset;
	private Vector2 Noise4Offset;
	// Use this for initialization
	void Start () {
		Magma=new Texture2D(512,512,TextureFormat.ARGB32,false);
		this.renderer.material.mainTexture=Magma;
		Noise1Rate=new Vector2(0.007f,0.017f);
		Noise2Rate=new Vector2(-0.019f,0.005f);
		Noise3Rate=new Vector2(0.003f,-0.023f);
		Noise4Rate=new Vector2(-0.013f,-0.011f);
	}
	
	// Update is called once per frame
	void Update () {
		float Illum,R,G,B;
		int X,Y;
		for (X=0;X<512;X++)
			for (Y=0;Y<512;Y++)
			{
				Illum=Noise.GetPixel(((int)Noise1Offset.x+X)>>3,((int)Noise1Offset.y+Y)>>3).r+
					Noise.GetPixel(((int)Noise2Offset.x+X)>>3,((int)Noise2Offset.y+Y)>>3).g+
					Noise.GetPixel(((int)Noise3Offset.x+X)>>3,((int)Noise3Offset.y+Y)>>3).b+
					Noise.GetPixel(((int)Noise4Offset.x+X)>>3,((int)Noise4Offset.y+Y)>>3).a;
				R=Mathf.Clamp01(Illum);
				R-=Mathf.Clamp01(Illum-3.0f);
				G=Mathf.Clamp01(Illum-1.0f);
				B=Mathf.Clamp01(Illum-2.0f);
				Magma.SetPixel(X,Y,new Color(R,G,B,0.0f));
			}
		Noise1Offset+=Noise1Rate*RateMultiplier;
		Noise2Offset+=Noise2Rate*RateMultiplier;
		Noise3Offset+=Noise3Rate*RateMultiplier;
		Noise4Offset+=Noise4Rate*RateMultiplier;
	}
}

It no longer seizes, but I get no result =(

The other thing I noticed is that it is very laggy - is there a better way to do this?

Below is what I am trying to make - done in the UDK by Epic, if anyone could suggest how to go about this I would appreciate it…

Is it possible to use the Compute Shader to achieve this?

Are there any good reference materials available on the net in reguards to Compute Shader? Either free or paid for…

This is something you want to do in a shader, a surface shader or pixel shader is what you want.

That will be very slow in Unity, best done in shader indeed.
But you must call Apply after all setpixel calls to actually change th texture - Unity - Scripting API: Texture2D.SetPixel