我在着色器中进行了两个线平面交叉,但是如果光线没有被击中以及哪一条光线的距离最短,我需要考虑。
但是下面的代码会抛出一个错误,它不会给我任何有用的信息(并指出错误的方向)。如果我设置tex并选择N来表示intersection.xy和N,它工作正常(但是当然不会给出我需要的结果)。
我在Unity工作。
float3 selectN;
float2 tex;
if (dist == 0.0) {
selectN = N2;
tex = intersection2.xy;
} else if (dist2 == 0.0) {
selectN = N;
tex = intersection.xy;
} else if (dist < dist2) {
selectN = N;
tex = intersection.xy;
} else {
selectN = N2;
tex = intersection2.xy;
}
答案 0 :(得分:0)
我需要添加#pragma target 3.0,因为我的着色器变得“过于复杂”。