|
| 1 | +'scopeName': 'source.shaderlab' |
| 2 | +'name': 'ShaderLab' |
| 3 | +'fileTypes': [ |
| 4 | + 'shader' |
| 5 | +] |
| 6 | +'patterns': [ |
| 7 | + { # Numbers |
| 8 | + 'match': '\\b([0-9]+\\.?[0-9]*)\\b' |
| 9 | + 'name': 'constant.numeric.shaderlab' |
| 10 | + } |
| 11 | + { # ShaderLab classes |
| 12 | + 'match': '\\b(Shader|Properties|Category|SubShader|Tags|Pass)\\b' |
| 13 | + 'name': 'support.class.shaderlab' |
| 14 | + } |
| 15 | + { # Cg shader section |
| 16 | + 'match': '\\b(CGPROGRAM|ENDCG)\\b' |
| 17 | + 'name': 'support.class.shaderlab' |
| 18 | + } |
| 19 | + { # Dependency and fallback |
| 20 | + 'match': '\\b(Dependency|Fallback)\\b' |
| 21 | + 'name': 'support.variable.shaderlab' |
| 22 | + } |
| 23 | + { # Property keywords |
| 24 | + 'match': '^\\s*\\[(HideInInspector)\\]' |
| 25 | + 'name': 'keyword.shaderlab' |
| 26 | + } |
| 27 | + { # Property variables |
| 28 | + 'match': '\\b(_\\w+)\\b' |
| 29 | + 'name': 'support.variable.input.shaderlab' |
| 30 | + } |
| 31 | + { # Surface shader input structure |
| 32 | + 'match': '\\b(uv(2)*_\\w+|viewDir|COLOR|screenPos|worldPos|worldRefl|worldNormal|worldRefl|worldNormal)\\b' |
| 33 | + 'name': 'support.variable.input.shaderlab' |
| 34 | + } |
| 35 | + { # Surface shader output structure |
| 36 | + 'match': '\\b(Albedo|Normal|Emission|Specular|Gloss|Alpha)\\b' |
| 37 | + 'name': 'support.variable.output.shaderlab' |
| 38 | + } |
| 39 | + { # Data structures in UnityCG.cginc |
| 40 | + 'match': '\\b(appdata_(base|tan|full|img)|SurfaceOutput)\\b' |
| 41 | + 'name': 'support.variable.structure.shaderlab' |
| 42 | + } |
| 43 | + { # Transformation variables |
| 44 | + 'match': '\\b(UNITY_MATRIX_(MVP|MV|V|P|VP|T_MV|IT_MV|TEXTURE0|TEXTURE1|TEXTURE2|TEXTURE3)|_Object2World|_World2Object|_WorldSpaceCameraPos|unity_Scale)\\b' |
| 45 | + 'name': 'support.variable.transformation.shaderlab' |
| 46 | + } |
| 47 | + { # Lighting variables |
| 48 | + 'match': '\\b(_ModelLightColor[0-9]|_SpecularLightColor[0-9]|_ObjectSpaceLightPos|_Light2World|_World2Light|_Object2Light)\\b' |
| 49 | + 'name': 'support.variable.lighting.shaderlab' |
| 50 | + } |
| 51 | + { # Various variables |
| 52 | + 'match': '\\b(_Time|_SinTime|_CosTime|unity_DeltaTime|_ProjectionParams|_ScreenParams)\\b' |
| 53 | + 'name': 'support.variable.other.shaderlab' |
| 54 | + } |
| 55 | + { |
| 56 | + 'include': '#comments' |
| 57 | + } |
| 58 | + { |
| 59 | + 'include': '#strings' |
| 60 | + } |
| 61 | + { |
| 62 | + 'include': '#functions' |
| 63 | + } |
| 64 | + { |
| 65 | + 'include': '#cg' |
| 66 | + } |
| 67 | +] |
| 68 | +'repository': |
| 69 | + 'comments': |
| 70 | + 'patterns': [ |
| 71 | + { # Comment line |
| 72 | + 'begin': '//' |
| 73 | + 'end': '$' |
| 74 | + 'name': 'comment.line.double-slash.shaderlab' |
| 75 | + } |
| 76 | + { # Comment block |
| 77 | + 'begin': '/\\*' |
| 78 | + 'end': '\\*/' |
| 79 | + 'name': 'comment.line.block.shaderlab' |
| 80 | + } |
| 81 | + ] |
| 82 | + 'strings': |
| 83 | + 'patterns': [ |
| 84 | + { # Double quoted string |
| 85 | + 'begin': '"' |
| 86 | + 'end': '"' |
| 87 | + 'name': 'string.quoted.double.shaderlab' |
| 88 | + } |
| 89 | + ] |
| 90 | + 'functions': |
| 91 | + 'patterns': [ |
| 92 | + { # Any function (copied from the languages-c package) |
| 93 | + 'match': '(?x) (?: (?= \\s ) (?:(?<=else|new|return) | (?<!\\w)) (\\s+))?\n\t\t\t(\\b \n\t\t\t\t(?!(while|for|do|if|else|switch|catch|enumerate|return|sizeof|[cr]?iterate)\\s*\\()(?:(?!NS)[A-Za-z_][A-Za-z0-9_]*+\\b | :: )++ # actual name\n\t\t\t)\n\t\t\t \\s*(\\()' |
| 94 | + 'captures': |
| 95 | + '1': |
| 96 | + 'name': 'punctuation.whitespace.function-call.leading.shaderlab' |
| 97 | + '2': |
| 98 | + 'name': 'support.function.any-method.shaderlab' |
| 99 | + '3': |
| 100 | + 'name': 'punctuation.definition.parameters.shaderlab' |
| 101 | + 'name': 'meta.function-call.shaderlab' |
| 102 | + } |
| 103 | + ] |
| 104 | + 'cg': |
| 105 | + 'patterns': [ |
| 106 | + { # Preprocessors |
| 107 | + 'match': '^\\s*#\\s*(define|defined|elif|else|if|ifdef|ifndef|line|pragma|undef)\\b' |
| 108 | + 'name': 'keyword.control.shaderlab' |
| 109 | + } |
| 110 | + { # Swizzle operator |
| 111 | + 'match': '\\.([rgba]{1,4}|[xyzw]{1,4})\\b' |
| 112 | + 'name': 'keyword.operator.shaderlab' |
| 113 | + } |
| 114 | + { # Declarations and declaration specifiers |
| 115 | + 'match': '\\b(const|extern|in|inline|inout|static|out|uniform|varying|profile name)\\b' |
| 116 | + 'name': 'storage.modifier.shaderlab' |
| 117 | + } |
| 118 | + { # Data types |
| 119 | + 'match': '\\b(void|struct|typedef|signed|unsigned|double([1-4])*(x[1-4])*|float([1-4])*(x[1-4])*|half([1-4])*(x[1-4])*|fixed([1-4])*(x[1-4])*|long([1-4])*(x[1-4])*|int([1-4])*(x[1-4])*|short([1-4])*(x[1-4])*|char([1-4])*(x[1-4])*|bool([1-4])*(x[1-4])*|sampler([1-3]D|RECT|CUBE)*)\\b' |
| 120 | + 'name': 'storage.type.shaderlab' |
| 121 | + } |
| 122 | + ] |
0 commit comments