I want to save the color of every point of one object in the RWTexture3D (UAV Resource) and transfer them to another object in its shader.
I made a test in the two shaders. Both in the fragment shader.
In first shader, I gave
RWTexture3D<float4> gUAVColor; gUAVColor[uint3(0,0,0)] = float4(1.0f,0.0f,0.0f,1.0f);
In second shader:
Texture3D<float4> gVoxelList; float4 output = gVoxelList.SampleLevel(Filter, uint3(0,0,0),0);
The result is correct, I got red as the result.
But when I change the code, the texture cant be sampled correctly.
In first shader, I gave
RWTexture3D<float4> gUAVColor; gUAVColor[uint3(1,0,0)] = float4(1.0f,0.0f,0.0f,1.0f);
In second shader:
Texture3D<float4> gVoxelList; float4 output = gVoxelList.SampleLevel(Filter, uint3(1,0,0),0);
I only changed the pos which save the red color from uint(0,0,0) to uint(1,0,0), but what I got changed to black, which means it's uncorrect.
If I use gVoxelList[uint(1,0,0)].xyz ,it works.
Does anyone have the idea where may be the problem?
Besides, what's the difference between gVoxelList[pos] and gTexture.SampleLevel(Filter, uint3(1,0,0),0); Both the two function backs the color: float4, right?