I’m trying to sample a 3D noise texture that I generate elsewhere and pass to my ComputeShader. However, when compiling the following, all I get is “Shader error in ‘DensityGenerator.compute’: cannot map expression to cs_5_0 instruction set at DensityGenerator.compute(14) (on d3d11)”.
I really haven’t got a clue where to start with this. It looks right and the only way to get it to compile is to comment out line 14 (noiseVol.Sample(), specifically).
What obvious bug have I missed?
#pragma kernel Density
Texture3D<float4> noiseVol;
SamplerState samplerNoiseVol;
RWStructuredBuffer<float> voxels;
[numthreads(32,32,1)]
void Density (uint3 threadId : SV_DispatchThreadID, uint3 groupId : SV_GroupID)
{
int size = 32;
int3 voxPos = threadId; // Just rename this for the sake of clarity
float density = 0;//-voxPos.y;
density += noiseVol.Sample(samplerNoiseVol, voxPos, 0).z;
voxels[voxPos.x + voxPos.y*size + voxPos.z*size*size] = density;
}