1 回答

TA貢獻1803條經(jīng)驗 獲得超3個贊
我重新考慮并解決了我自己的問題。答案分為兩部分:我奇怪地組合了 x 和 y 坐標(id.x 和 id.y),并且我使用了錯誤的輸入語義。(SV_GroupThreadID 而不是 SV_DispatchThreadID)
所以這是解決方案。我還翻轉(zhuǎn)了 y 軸以符合我的直覺。
// Each #kernel tells which function to compile; you can have many kernels
#pragma kernel CSMain
// Create a RenderTexture with enableRandomWrite flag and set it
// with cs.SetTexture
Texture2D<float4> InputTexture;
RWBuffer<float> OutputBuffer;
[numthreads(8, 8, 1)]
void CSMain(uint3 id : SV_DispatchThreadID)
{
uint w, h;
InputTexture.GetDimensions(w, h);
OutputBuffer[id.x + id.y * w] = InputTexture[float2(id.x, h - 1 - id.y)].r;
}
- 1 回答
- 0 關(guān)注
- 239 瀏覽
添加回答
舉報