【发布时间】:2018-04-12 04:54:00
【问题描述】:
GLSL 函数 step 返回一个浮点数(0.0f 或 1.0f)或浮点数向量。有没有办法让它返回一个整数?我正在尝试使用它来抵消索引(不引入if 语句):
const int[8] constIndicies = int[](
0,1,2,3,
1,3,0,2);
...
float ratioEdge = 17.0f;
float myFloatValue = 9.0f;
... constIndicies[4*step(ratioEdge, myFloat)] ...
但是它返回一个浮点数,这是行不通的。并且将其转换为 int 似乎是错误的。
【问题讨论】:
-
GLSL 不是 Java;
new int[]不是合法的 GLSL 语法。