Search Unity

Compute Shader SamplerState

Discussion in 'Shaders' started by jesta, Nov 21, 2012.

  1. jesta

    jesta

    Joined:
    Jun 19, 2010
    Posts:
    294
    Is it possible to define SamplerStates in compute shaders? I'm trying to follow some tutorials and they make heavy use of it. Since compute shaders are written in HLSL, I thought it would work but I get the following error:

    "Unrecognized sampler 'mySamplerName' - does not match any texture and is not a built-in name"

    Any ideas how to solve this?
     
  2. stektpotet

    stektpotet

    Joined:
    Nov 10, 2013
    Posts:
    1
    Veeeeeeery late response to this, I stumbled across this post looking for answers to another issue regarding sampler states. But I do know the solution for this issue. so in case anyone else stumbles across this and need the answer, I'll share:

    It appears unity has a requirement set on samplerstates in computeshaders. it's not part of the regular HLSL spec, but Unity REQUIRES that a samplerstate follows the naming convention samplerTEXTURENAME for the texture you intend to use the sampler on. e.g.
    Code (CSharp):
    1. Texture2D<float4> MyTexture;
    2. SamplerState samplerMyTexture
    3. {
    4. //STUFF
    5. };