Hi! Recently I have been playing around with graphics programming in unity and while attempting to create a c# script to generate a LUT unity crashes everytime I hit play ONLY when the script is enabled. I'm sure its down to dodgy programming as my c# is a bit meh. Heres the code:
using UnityEngine;
using System.Collections;
public class GenerateBeckmann : MonoBehaviour {
public int size = 64;
private Material currentMaterial;
public Texture2D generatedTex;
float PHBeckmann(float ndoth,float m){
float alpha = Mathf.Acos (ndoth);
float ta = Mathf.Tan(alpha);
float val = 1f/(m*m*Mathf.Pow(ndoth,4f)) * Mathf.Exp(-(ta * ta) / (m * m));
return val;
}
private Texture2D Beckmann(){
Texture2D beckmann = new Texture2D(size,size,TextureFormat.ARGB32,false);
for(int i=0;i
↧