currently working on translating scalefx to slang. I’m really missing the vector functionality of operators. ok, so (x <= y) can be replaced by lessThanEqual(x,y) and (a ? b : c) by using mix(c,b,a). but what about logical operators on vectors? in cg I could combine two bool4 vectors a,b like this a || b, which would do component-wise or operations. I haven’t found an equivalent function for that in GLSL. I guess you have to write it down for every component seperately? this would make an already complex code very convoluted. hope there is another solution.
edit:
well I found one way to do it, maybe there is a more elegant one. here is the function in cg:
bool clear(float2 crn, float4 ort){
return all(crn.xyxy <= THR || crn.xyxy <= ort || crn.xyxy <= ort.wxyz);
}
and in slang:
bool clear(vec2 crn, vec4 ort){
return all(bvec4(step(crn.xyxy, vec4(THR)) + step(crn.xyxy, ort) + step(crn.xyxy, ort.wxyz)));
}
where I used that you can calculate x <= y with step(x,y).
maybe I should get rid of boolean values altogether and just operate with numerical values:
float clear(vec2 crn, vec4 ort){
vec4 res = step(crn.xyxy, vec4(THR)) + step(crn.xyxy, ort) + step(crn.xyxy, ort.wxyz);
return min(res.x * res.y * res.z * res.w, 1);
}
any thoughts?