using System; using UnityEngine; namespace Funique { [Obsolete("This will delete after 1.2")] public class GPU_Texture2D { public Texture texture; public int inWidth; public int inHeight; public int outWidth; public int outHeight; private ComputeShader comShader; private RenderTexture inRTexture; private RenderTexture outRTexture; public GPU_Texture2D(ComputeShader shader, int width, int height) { inWidth = width; inHeight = height; outWidth = (int)((float)(width * 3) / 4f); outHeight = (int)((float)(height * 4) / 3f); comShader = shader; inRTexture = new RenderTexture(width, height, 24); inRTexture.enableRandomWrite = true; inRTexture.Create(); outRTexture = new RenderTexture(outWidth, outHeight, 24); outRTexture.enableRandomWrite = true; outRTexture.Create(); } public void GPU_Apply() { Graphics.Blit(texture, inRTexture); int kernelIndex = comShader.FindKernel("CSMain"); int num = Mathf.Max(inWidth, inHeight, outWidth, outHeight); comShader.SetInt("inWidth", inWidth); comShader.SetInt("inHeight", inHeight); comShader.SetInt("outWidth", outWidth); comShader.SetInt("outHeight", outHeight); comShader.SetTexture(kernelIndex, "inRTexture", inRTexture); comShader.SetTexture(kernelIndex, "outRTexture", outRTexture); comShader.Dispatch(kernelIndex, num / 8, num / 8, 1); texture = outRTexture; RenderTexture.active = null; } } }