Closed repalash closed 4 years ago
IntelliJ (and relatd IDEs) support this through language injection.
Thanks, it works. Is there any way to define a rule that does this automatically? Also doing this in files with just a shader chunk, it shows a lot of errors. like this: https://github.com/mrdoob/three.js/blob/master/src/renderers/shaders/ShaderChunk/alphamap_fragment.glsl.js
Is there any way to define a rule that does this automatically?
See the linked help article, it showcases a few ways to do it (comments, annotations).
There is currently no plan to support shader fragments, maybe in the future. I don't quite see the usefulness of splitting code into chunks and then putting them behind ifdefs, like in the example, but the feature is implementable.
A lot of javascript webGL projects use .glsl.js files for keeping shader code. I have been working with three.js, which has a common practice of embedding shaders as strings in files. Some examples: Simple vertex shader: https://github.com/mrdoob/three.js/blob/master/src/renderers/shaders/ShaderLib/background_vert.glsl.js
Examples of full shaders: https://github.com/mrdoob/three.js/tree/master/src/renderers/shaders/ShaderLib Example of shader chunks which can be included in other shaders: https://github.com/mrdoob/three.js/tree/master/src/renderers/shaders/ShaderChunk
If I mark .glsl.js as shader files in Webstorm remove the
export default /* glsl */
line at the top and bottom of Full shaders, it works alright, but for shader chunks, it still doesn't. Some kind of support for ad-hoc shader chunks would be really helpful.