Skip to content

Instantly share code, notes, and snippets.

@zyouyowa
Created December 5, 2018 13:47
Show Gist options
  • Save zyouyowa/b8ef6d2c8ce4e8c014d04a3c0cde17f5 to your computer and use it in GitHub Desktop.
Save zyouyowa/b8ef6d2c8ce4e8c014d04a3c0cde17f5 to your computer and use it in GitHub Desktop.
using UnityEngine;
using UnityEngine.UI;
public class ImageProcesser : MonoBehaviour {
public ComputeShader shader;
public RawImage srcImg;
public RawImage dstImg;
void Start () {
int w = srcImg.texture.width;
int h = srcImg.texture.height;
var rTex = new RenderTexture(w, h, 0, RenderTextureFormat.ARGBFloat);
rTex.enableRandomWrite = true;
rTex.Create();
dstImg.texture = rTex;
shader.SetTexture(0, "srcTex", srcImg.texture);
shader.SetTexture(0, "dstTex", rTex);
shader.Dispatch(0, w / 32, h / 32, 1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment