我们知道compute shader的代码如下,我们Result使用RenderTexture类型接收数据
// 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
RWTexture2D<float4> Result;
[numthreads(8,8,1)]
void CSMain (uint3 id : SV_DispatchThreadID)
{
// TODO: insert actual code here!
Result[id.xy] = float4(id.x & id.y, (id.x & 15)/15.0, (id.y & 15)/15.0, 0.0);
}
首选我们需要创建一个RenderTexture
RenderTexture rt = new RenderTexture(_colorTexSize.Width, _colorTexSize.Height, 0, RenderTextureFormat.ARGB32);
rt.enableRandomWrite = true;

最低0.47元/天 解锁文章
1318

被折叠的 条评论
为什么被折叠?



