#pragma kernel CSMain
float Offx0,Offy0,Offx1,Offy1,Offx2,Offy2,Offx3,Offy3;// Off0 = Red, Off1 = Green, Off2 = Blue, Off3 = Alpha
sampler2D Noise;// The Read Texture...
RWTexture2D<float4> Result;// The output texture
[numthreads(8,8,1)]//Thread info
void CSMain (uint3 id : SV_DispatchThreadID)
{
float r,g,b,a;
float4 c0,c1,c2,c3;
float2 o0,o1,o2,o3;
o0=o1=o2=o3=id.xy;// Get the thread coords
o0.x+=Offx0;// Add the offsets...
o0.y+=Offy0;
o1.x+=Offx1;
o1.y+=Offy1;
o2.x+=Offx2;
o2.y+=Offy2;
o3.x+=Offx3;
o3.y+=Offy3;
c0=tex2D(Noise,o0);// Get the color info at the specified locations...
c1=tex2D(Noise,o1);
c2=tex2D(Noise,o2);
c3=tex2D(Noise,o3);
r=c0.r;// multiply all red
r*=c1.r;
r*=c2.r;
r*=c3.r;
g=c0.g;// multiply all green
g*=c1.g;
g*=c2.g;
g*=c3.g;
b=c0.b;// multiply all blue
b*=c1.b;
b*=c2.b;
b*=c3.b;
a=c0.a;//multiply all alpha
a*=c1.a;
a*=c2.a;
a*=c3.a;
Result [ id.xy ] = float4 ( r + g + b + a , 0 , 0 , 0 );// return total of color info in grey-scale red channel...
}
As I posted this in the wrong section and am cross posting this question as directed - I refer you to X=1 ok, but X=A compile fails... - Unity Engine - Unity Discussions for more information…