I am trying to do something like
while (currentLayerDepth < currentDepth)
{
currentUV -= step;
currentDepth = tex2D(_HeightTex,currentUV).a;
currentLayerDepth += eachLayer;
}
It logged a error 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)
So now I have two choices, one is to add [unroll(100)] to limit loop times and the other is using tex2Dlod instead of tex2D.
I'm curious why this happened?
Besides, why tex2Dlod can be used in a loop?