i'm writing glsl shader using #if preprocessor directive, i'm getting error incorrect preprocessor directive.
here's code below (just relevant part):
#define thre 20 float s = get_sample_data(sampling_pos); #if s > thre vec4 val = texture(transfer_texture, vec2(s, s)); #endif
preprocessing 1 of compilation's steps, occurs before runtime. transform source based on # lines finds. doesn't have clue variable, runtime concepts. @ time, variable has no values, , preprocessor don't know them.
knowing that, trivial can't use variable value in preprocessor directive.
you can compare #defined value literal constant :
#define thre 12 #if thre > 15 float x = 1.; #else float x = -1.; #endif in glsl, still can use conditionnal structure, 'regular' if.
if(s>thre){ // }else{ // else }
Comments
Post a Comment