Hi, is it possible to set some properties within the hlms template files to the evaluation of an expression? Let's consider following simple approach:
- in onPreparePassHash I set a property "X" which defines shader behavior for all renderables
- in calculateHashForPreCreate I can override the property by setting "X_override" and "X_renderable"
- in hlms template file I use it as @property((X && !X_override) || X_renderable) .. @end
As I have multiple occurrences of this behavior, I need to repeat always the same expression. Instead of it I would like to do it in hlms template something @pset(useX, (X && !X_override) || X_renderable) and then later on @property(useX) .. @end but as far as I know, the value in @pset must be an integer or directly name of another property.
Note: I am aware, that I can do the evaluation in c++ directly in calculateHashForPreCreate, but I think doing it in the hlms should perform better because the output is cached - base on the set of input properties if there is already parsed shader, it is then used, instead of evaluating the hlms template files. Hence it is better to just set properties in c++ instead of doing some more complex logic with them.
Note2: in current state, I don't have access in calculateHashForPreCreate to the data which are available in onPreparePassHash (good example is SceneManager), so I have to set all the data through properties via setProperty calls and later in calculateHashForPreCreate I could potentially access the values through getProperty and set new properties - at the moment I would like to avoid getProperty calls there.
Note3: I checked the documentation of hlms and imagine that something like this might work:
Code: Select all
@psub(not_X_override, 1, X_override) // missing @pnot so assuming X_override is either 0 or 1, the @psub can calculate the negated value
@pmul(X_and_not_X_override, X, useX, not_X_override) // output is 0 or 1
@padd(useX, X_and_not_X_override, X_renderable) // output is 0, 1 or 2
But the code has 3 lines per a variable which seems just also too much
I would like to have it simple and readable - the code above is impossible to decode at the first look what the author would like to tell with it.
