Page 1 of 1
[2.1] comment out a part of HLMS shader
Posted: Sun Apr 24, 2016 2:18 pm
by hyyou
HLMS's preprocessor ignores syntax of C comment, such as in PixelShader_ps.glsl
In the above code, Ogre's HLMS will still insert a piece. (notice the slashes //)
The technique to comment out some lines for debugging purpose is currently unusable.
It would be useful if you can add this feature - make HLMS recognize C-comment syntax and skip them.

Re: [2.1] comment out a part of HLMS shader
Posted: Sun Apr 24, 2016 3:04 pm
by xrgo
Yes I agree, what I do is to rename "some_piece" to "some_pieceASDF" which I am sure it doesn't exist
Re: [2.1] comment out a part of HLMS shader
Posted: Sun Apr 24, 2016 7:12 pm
by dark_sylinc
From the manual:
The preprocessor was written with speed and simplicity in mind. It does not implement an AST or anything fancy. This is very important to account while writing templates because there will be cases when using the preprocessor may feel counter-intuitive or frustrating.
I wanted to use Lua or Python as a means of concatenating the string that would become the shader (e.g. executing PbsTemplate.lua / PbsTemplate.py which spit outs shader code); but that would've added a huge dependency, bloated our code, and have slow shader generation.
The parser is actually extremely simple and extremely dumb. So C-like parsing is nowhere near close. I did recall writing functionality for the Hlms to remove lines containing three slashes e.g.:
Code: Select all
///This whole line will not be included
But I don't know what the hell happened with it (may be it got shelved in Mercurial and then lost?).
The rationale behind it was that 2 slashes = comments useful in the generated output; 3 slashes = comments that only make sense on the template.
Like xrgo, I usually rename the pieces or the properties to something I'm sure doesn't exist, or if it's a property I can also add "&& false" which doesn't exist and if it were, it would be set to 0 (unless someone writes @pset( false, 1 ) which is the equivalent of doing #define false 1 in C/C++ just to screw with everyone)