Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

[ComputeShader]Fails to compile...

Discussion in 'Shaders' started by HellSinker, Jun 1, 2016.

  1. HellSinker

    HellSinker

    Joined:
    Apr 18, 2013
    Posts:
    65
    Code (CSharp):
    1. #pragma kernel CSMain
    2.  
    3. RWTexture2D<float4> Result;
    4. Texture2D<float4> Gradient; SamplerState samplerGradient;
    5. Texture2D<float4> Noise; SamplerState samplerNoise;
    6. float Intensity;
    7. float2 GradientOffset;
    8. float2 NoiseOffset;
    9.  
    10. [numthreads(8,8,1)]
    11. void CSMain (uint3 dtid : SV_DispatchThreadID)
    12. {
    13.     Result[dtid.xy] = tex2D(samplerGradient, dtid.xy + GradientOffset.xy) + tex2D(samplerNoise, dtid.xy + NoiseOffset.xy)*Intensity;
    14. }
    15.  
    Very unhelpfully I get this message....

    cannot map expression to cs_5_0 instruction set

    Now I have no idea?!?
     
  2. gorbit99

    gorbit99

    Joined:
    Jul 14, 2015
    Posts:
    1,350
    This is a shader-themed question, which is under the graphics forum
     
  3. HellSinker

    HellSinker

    Joined:
    Apr 18, 2013
    Posts:
    65
    sorry...
     
  4. gorbit99

    gorbit99

    Joined:
    Jul 14, 2015
    Posts:
    1,350
    No problem, but you should check the forum description next time, just to make sure. This post might be moved by a moderator though
     
  5. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    :)
     
    gorbit99 likes this.
  6. gorbit99

    gorbit99

    Joined:
    Jul 14, 2015
    Posts:
    1,350
    Like that, exactly, thank you @hippocoder for giving an example