Jump to content

how to use #if preprocessor in shader?


photo

Recommended Posts

Posted

porting FXAA 3 into unigine won't be possible if there is no #if preprocessor support.

I've tried with ##if ... ##endif but in fact all code blocks in ##if will be compiled into shader.

 

Is there a way to use #if preprocessor in unigine's shader?

Posted

Sure, have a look into existing shaders e.g. for mesh materials. There are tons of #if defs

Posted

:( I don't mean how to use #ifdef or #ifndef, I'm how to use #if AA > 3 or #if AA=3

Posted

#if defs do not support expressions up to my knowledge, just simple symbol defines. For different states you have to define multiple symbols eqivalent to your expression. For your use case have a look into material definition and fragment shader code for mesh_terrain_base as this material supports varying count of detail materials which should also require multi-symbol #if def constructs in the relevant shaders

Posted

Using expressions is standard feature in all shader language, with expressions support in #if will be more easy to port Fxaa shader

Posted

#if should work in shaders, though it would be slow.

Posted

"#if" preprocessor directive for shaders and scripts is ready.

Posted

Thanks ,this will make fxaa shader more efficient, with this, we can do more.

 

Can't wait to get the new sdk :)

×
×
  • Create New...