Created
April 14, 2017 04:00
-
-
Save RoyLab/3ebdaa3d33172c69b2a423e4f860c911 to your computer and use it in GitHub Desktop.
run compute shader in unity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RenderTexture RunShader() | |
{ | |
int kernelHandle = shader.FindKernel("CSMain"); | |
RenderTexture tex = new RenderTexture(256, 256, 24); | |
tex.enableRandomWrite = true; | |
tex.Create(); | |
shader.SetTexture(kernelHandle, "Result", tex); | |
shader.Dispatch(kernelHandle, 32, 32, 1); | |
return tex; | |
} | |
private void renderWithMesh(RenderTexture source, RenderTexture destination) | |
{ | |
var tmp = RenderTexture.GetTemporary(source.width, source.height, 0, source.format); | |
Graphics.SetRenderTarget(destination); | |
GL.Clear(false, true, new Color(0, 0, 0, 1)); | |
debug.materialDebug.SetPass(0); | |
GL.wireframe = true; | |
GL.PushMatrix(); | |
GL.LoadOrtho(); | |
Graphics.DrawMeshNow(mesh_, Matrix4x4.identity); | |
GL.PopMatrix(); | |
//Graphics.Blit(tmp, destination); | |
RenderTexture.ReleaseTemporary(tmp); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment