Skip to content

celoron/UnityReadbackFromShader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UnityReadbackFromShader

Basic way to read single integer -for now- from CG shaders.

Works by computing in fragment shader and applying that value to framebuffer, then unity can readback from this buffer

Shader

fixed4 frag (v2f i) : SV_Target
{
  return int2Fixed4( Fibonacci(30) );
}

C#

// get result texture see:FramebufferReadback.cs
var tex = GetResultTexture();

// get single pixel
Color c = tex.GetPixel(0, 0);

int fib30 = ReadbackValue(c);

About

Unity Readback From Unlit Shaders

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published