racz16 / WebGL-GLSL-Editor

WebGL GLSL shader editor extension for Visual Studio Code.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feature]: Can you specify a variable name to set the function "webgl-glsl-editor.diagnostics" to false

Lehamber opened this issue · comments

Feature details

I am using threejs for project development. When using ShaderMaterial, it is added to the shader code by default at compile time ”attribute vec3 position; uniform mat4 projectionMatrix; uniform mat4 viewMatrix;”Such variable definition.
So I can use these variables when writing shader code without declaring them, but since these variables are not defined in the current documentation "WebGL-GLSL-Editor" will check for errors as follows
image

If I declare these variables in the file again, although "WebGL-GLSL-Editor" will not check for errors, it will report "variable repeated declaration" when shader is compiled. Is there any way to solve this problem, such as support for specifying variable names to prevent error checking.☺️

Yes, there is a feature, called Code injection in the extension. If you go to Settings, you can turn on Code injection, and you can also specify the source code you want to inject. Then the extension will inject the specified lines to the beginning of all shaders. By default the injected source code is Shadertoy-specific, but of course, you can change it to whatever you need. This way not only the compiler won't give you error messages, but all the other features, like code completion, hovering over variables, etc. will work with the injected code as well.
image

Additionally, you can turn off Diagnostics (errors and warnings), but hopefully, you won't need this.

@racz16 Thank you very much. I'm sorry I didn't read the document properly.