void Start() { Camera.onPreRender += onPreRender; input = new Texture2D(width, height); Color[] colorArray = new Color[width * height]; for (int i = 0; i < colorArray.Length; ++i) { colorArray[i] = Random.Range(0f, 1f) > 0.5f ? Color.white : Color.black; } input.SetPixels(colorArray); input.Apply(); if (material) { material.mainTexture = input; } frameBuffer = new FrameBuffer(); frameBuffer.Create(width, height); output = frameBuffer.Get(); frameBuffer.Swap(); Graphics.Blit(input, frameBuffer.Get()); }
protected override void OnInitialize() { base.OnInitialize(); color = TestColor; fbo = FrameBuffer.Create(GL, 500, 500); }
void Start() { mesh = GetComponent <MeshFilter>().sharedMesh; resolution = (int)GetNearestPowerOfTwo(Mathf.Sqrt(mesh.vertices.Length)); texture = new Texture2D(resolution, resolution, TextureFormat.RGBAFloat, false); texture.filterMode = FilterMode.Point; colorArray = new Color[resolution * resolution]; Print(); frameBuffer = new FrameBuffer(); frameBuffer.Create(resolution, resolution); Graphics.Blit(texture, frameBuffer.Get()); frameBuffer.Swap(); Graphics.Blit(texture, frameBuffer.Get()); Shader.SetGlobalTexture(uniformName, frameBuffer.Get()); Shader.SetGlobalTexture("_VertexTexture", texture); Shader.SetGlobalFloat("_Resolution", resolution); render = GetComponent <Renderer>(); }