我正在尝试做类似的事情
while (currentLayerDepth < currentDepth)
{
currentUV -= step;
currentDepth = tex2D(_HeightTex,currentUV).a;
currentLayerDepth += eachLayer;
}
它记录了一个错误Shader error in 'Unlit/CustomParallax': unable to unroll loop, loop does not appear to terminate in a timely manner (1024 iterations) at line 76 (on metal)
所以现在我有两个选择,一个是添加 [unroll(100)] 以限制循环时间,另一个是使用 tex2Dlod 而不是 tex2D。
我很好奇为什么会这样?
此外,为什么 tex2Dlod 可以循环使用?