X=1 ok, but X=A compile fails...

Hello, I am trying to compile something and its not playing fair…

If I put X=0, X=1, or X=2 it works fine…

but if I try X=A, X=B, or X=C I get this error…

cannot map expression to cs_5_0 instruction set

I am able to show the source if required…

Right now however I’m trying to understand why I can assign a constant to a variable, but not a variable to a variable…

As requested…

#pragma kernel CSMain

float2 Off0,Off1,Off2,Off3;
sampler2D Noise;

RWTexture2D<float4> Result;

[numthreads(8,8,1)]
void CSMain (uint3 id : SV_DispatchThreadID)
{
    float2 o0=id.xy;
    float2 o1=id.xy;
    float2 o2=id.xy;
    float2 o3=id.xy;

    o0+=Off0;
    o1+=Off1;
    o2+=Off2;
    o3+=Off3;

    float4 c0=tex2D(Noise,o0);
    float4 c1=tex2D(Noise,o1);
    float4 c2=tex2D(Noise,o2);
    float4 c3=tex2D(Noise,o3);

    float r=c0.r;
    r*=c1.r;
    r*=c2.r;
    r*=c3.r;
    float g=c0.g;
    g*=c1.g;
    g*=c2.g;
    g*=c3.g;
    float b=c0.b;
    b*=c1.b;
    b*=c2.b;
    b*=c3.b;
    float a=c0.a;
    a*=c1.a;
    a*=c2.a;
    a*=c3.a;

    float4 rslt = float4 ( r + g + b + a , 0 , 0 , 0 );

    Result [ id.xy ] = rslt ;

}

The problem is with the last line - by making it a constant float4(0,0,0,0) the code works fine…

… such as …

    Result [ id.xy ] = float4 ( 0,0,0,0 );

Please show your code.

I updated my original post…

Is this shader code?

You should try posting it in the shader section under graphics

it is a compute shader, perhaps it is in the wrong place - its not easy to determine…

#pragma kernel CSMain

float Offx0,Offy0,Offx1,Offy1,Offx2,Offy2,Offx3,Offy3;
sampler2D Noise;

RWTexture2D<float4> Result;

[numthreads(8,8,1)]
void CSMain (uint3 id : SV_DispatchThreadID)
{
    float r,g,b,a;
    float4 c0,c1,c2,c3;
    float2 o0,o1,o2,o3;

    o0=id.xy;
    o1=id.xy;
    o2=id.xy;
    o3=id.xy;

    o0.x+=Offx0;
    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);
    c1=tex2D(Noise,o1);
    c2=tex2D(Noise,o2);
    c3=tex2D(Noise,o3);

    r=c0.r;
    r*=c1.r;
    r*=c2.r;
    r*=c3.r;
    g=c0.g;
    g*=c1.g;
    g*=c2.g;
    g*=c3.g;
    b=c0.b;
    b*=c1.b;
    b*=c2.b;
    b*=c3.b;
    a=c0.a;
    a*=c1.a;
    a*=c2.a;
    a*=c3.a;

    Result [ id.xy ] = float4 ( r + g + b + a , 0 , 0 , 0 );

}

Still not compiling, same error, and I’m pretty much out of ideas…

You will want to post this in the Shaders sub-forum: link.

thanks… :wink:

@Mods/Admin : Please lock this thread if you get the chance…