Closed
Description
What problem does this solve or what need does it fill?
if we have 3 shader files common.wgsl
, util1.wgsl
, util2.wgsl
, and if both util1.wgsl
and util2.wgsl
includes common.wgsl
, then if the main shader file include both util1.wgsl
and util2.wgsl
, it will cause a problem, because function re-definition (i.e. common.wgsl
imported twice).
What solution would you like?
one solution would be to support #define
in the shader preprocess (i.e. define a label used for #ifdef
#ifndef
). Then we can write an include guard similar to the include file in C.
What alternative(s) have you considered?
there could be several other method,
- have
#import once
declarative indicate this file should only be imported once. - bevy preprocessor automatically remove the duplicate function (however, how to define duplicate function is questionable)
- do nothing, and let user keep track of import and make sure no duplicate imports happen.