ComputeShader/Assets/Shaders/ColorInverter.compute

18 lines
449 B
Plaintext

// Each #kernel tells which function to compile; you can have many kernels
#pragma kernel cs_main
// Create a RenderTexture with enableRandomWrite flag and set it
// with cs.SetTexture
RWTexture2D<float4> result;
// Input texture
Texture2D<float4> source_texture;
[numthreads(8,8,1)]
void cs_main (uint3 id : SV_DispatchThreadID)
{
float4 color = result[id.xy];
color.rgb = 1 - color.rgb; // invert the color
result[id.xy] = color;
}