Hi, I am trying to write a template shader for my custom hlms which will have multiple "sections". Basically I want to write couple of pieces and based on the Renderable's properties, only once piece will be inserted to the shader:
Code: Select all
@piece(PropertyA) @insertpiece(ShaderA) @end
@piece(PropertyB) @insertpiece(ShaderB) @end
@piece(PropertyC) @insertpiece(ShaderC) @end
@piece(!PropertyA && !PropertyB && !PropertyC) @insertpiece(DefaultShader) @end
This of course work, but I would like to write last part in more general way that if I insert new PropertyD, that I don't have to update the condition there. Something like this (but it doesn't work):
Code: Select all
@piece(PropertyA) @insertpiece(ShaderA) @set(ShaderSet, 1) @end
@piece(PropertyB) @insertpiece(ShaderB) @set(ShaderSet, 1) @end
@piece(PropertyC) @insertpiece(ShaderC) @set(ShaderSet, 1) @end
@piece(!ShaderSet) @insertpiece(DefaultShader) @end
From what I read in the documentation for HLMS I think I understand why it is not working - the @set is evaluated after the pieces are inserted, which is just too late. I tried it also with @pset, but this one is evaluated before any piece is inserted. Is there something more dynamic? There was description of something similar and recommended that it is possible to use HLSL/GLSL preprocessor macros with their own cons and pros. I would like to stick purely to HLMS preprocessing so if there is nothing else what I can do, I will stick to my original template code (with last part naming all properties).