hey guys,I dont know if this belongs over here, but I ran into a problem while trying to optimize my code by writing a simple compute shader:
I was writing a compute shade(a quite simple one) but every time I pass a float to my compute shader it gets rounded to the first decimal digit, what am I doing wrong... (So 0.1123 becomes 0.1)
I set my float the following way:
shader.SetFloat("frequency", frequency);
The way I defined my compute shader looks like this:
#pragma kernel calcFreq
float frequency;
RWStructuredBuffer debugBuffer;
[numthreads(32,1,1)]
void calcFreq(uint3 id : SV_DispatchThreadID)
{
debugBuffer[id.x]=frequency
}
I then try to get the value by getting the data from the buffer. The buffer is defined like this:
ComputeBuffer debugBuffer = new ComputeBuffer(1, sizeof(float));
shader.SetBuffer(kernel, "debugBuffer", debugBuffer);
shaderDensity.Dispatch(kernel,1, 1, 1);
float freq;
debugBuffer.GetData(freq);
I tried searching this online, but did not find anything or anyone with this problem and would really appreciate some help ^^"
↧