| 1 | { |
| 2 | "scopeName": "source.shaderlab", |
| 3 | "name": "ShaderLab", |
| 4 | "fileTypes": ["shader"], |
| 5 | "patterns": [ |
| 6 | { |
| 7 | "match": "\\b([0-9]+\\.?[0-9]*)\\b", |
| 8 | "name": "constant.numeric.shaderlab" |
| 9 | }, |
| 10 | { |
| 11 | "match": "\\b(Shader|Properties|Category|SubShader|Tags|Pass)\\b", |
| 12 | "name": "support.class.shaderlab" |
| 13 | }, |
| 14 | { |
| 15 | "match": "\\b(CGPROGRAM|ENDCG)\\b", |
| 16 | "name": "support.class.shaderlab" |
| 17 | }, |
| 18 | { |
| 19 | "match": "\\b(Dependency|Fallback)\\b", |
| 20 | "name": "support.variable.shaderlab" |
| 21 | }, |
| 22 | { |
| 23 | "match": "^\\s*\\[(HideInInspector)\\]", |
| 24 | "name": "keyword.shaderlab" |
| 25 | }, |
| 26 | { |
| 27 | "match": "\\b(_\\w+)\\b", |
| 28 | "name": "support.variable.input.shaderlab" |
| 29 | }, |
| 30 | { |
| 31 | "match": "\\b(uv(2)*_\\w+|viewDir|COLOR|screenPos|worldPos|worldRefl|worldNormal|worldRefl|worldNormal)\\b", |
| 32 | "name": "support.variable.input.shaderlab" |
| 33 | }, |
| 34 | { |
| 35 | "match": "\\b(Albedo|Normal|Emission|Specular|Gloss|Alpha)\\b", |
| 36 | "name": "support.variable.output.shaderlab" |
| 37 | }, |
| 38 | { |
| 39 | "match": "\\b(appdata_(base|tan|full|img)|SurfaceOutput)\\b", |
| 40 | "name": "support.variable.structure.shaderlab" |
| 41 | }, |
| 42 | { |
| 43 | "match": "\\b(UNITY_MATRIX_(MVP|MV|V|P|VP|T_MV|IT_MV|TEXTURE0|TEXTURE1|TEXTURE2|TEXTURE3)|_Object2World|_World2Object|_WorldSpaceCameraPos|unity_Scale)\\b", |
| 44 | "name": "support.variable.transformation.shaderlab" |
| 45 | }, |
| 46 | { |
| 47 | "match": "\\b(_ModelLightColor[0-9]|_SpecularLightColor[0-9]|_ObjectSpaceLightPos|_Light2World|_World2Light|_Object2Light)\\b", |
| 48 | "name": "support.variable.lighting.shaderlab" |
| 49 | }, |
| 50 | { |
| 51 | "match": "\\b(_Time|_SinTime|_CosTime|unity_DeltaTime|_ProjectionParams|_ScreenParams)\\b", |
| 52 | "name": "support.variable.other.shaderlab" |
| 53 | }, |
| 54 | { |
| 55 | "include": "#comments" |
| 56 | }, |
| 57 | { |
| 58 | "include": "#strings" |
| 59 | }, |
| 60 | { |
| 61 | "include": "#functions" |
| 62 | }, |
| 63 | { |
| 64 | "include": "#cg" |
| 65 | } |
| 66 | ], |
| 67 | "repository": { |
| 68 | "comments": { |
| 69 | "patterns": [ |
| 70 | { |
| 71 | "begin": "//", |
| 72 | "end": "$", |
| 73 | "name": "comment.line.double-slash.shaderlab" |
| 74 | }, |
| 75 | { |
| 76 | "begin": "/\\*", |
| 77 | "end": "\\*/", |
| 78 | "name": "comment.line.block.shaderlab" |
| 79 | } |
| 80 | ] |
| 81 | }, |
| 82 | "strings": { |
| 83 | "patterns": [ |
| 84 | { |
| 85 | "begin": "\"", |
| 86 | "end": "\"", |
| 87 | "name": "string.quoted.double.shaderlab" |
| 88 | } |
| 89 | ] |
| 90 | }, |
| 91 | "functions": { |
| 92 | "patterns": [ |
| 93 | { |
| 94 | "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 | :: )++\t\t\t\t # actual name\n\t\t\t)\n\t\t\t \\s*(\\()", |
| 95 | "captures": { |
| 96 | "1": { |
| 97 | "name": "punctuation.whitespace.function-call.leading.shaderlab" |
| 98 | }, |
| 99 | "2": { |
| 100 | "name": "support.function.any-method.shaderlab" |
| 101 | }, |
| 102 | "3": { |
| 103 | "name": "punctuation.definition.parameters.shaderlab" |
| 104 | } |
| 105 | }, |
| 106 | "name": "meta.function-call.shaderlab" |
| 107 | } |
| 108 | ] |
| 109 | }, |
| 110 | "cg": { |
| 111 | "patterns": [ |
| 112 | { |
| 113 | "match": "^\\s*#\\s*(define|defined|elif|else|if|ifdef|ifndef|line|pragma|undef)\\b", |
| 114 | "name": "keyword.control.shaderlab" |
| 115 | }, |
| 116 | { |
| 117 | "match": "\\.([rgba]{1,4}|[xyzw]{1,4})\\b", |
| 118 | "name": "keyword.operator.shaderlab" |
| 119 | }, |
| 120 | { |
| 121 | "match": "\\b(const|extern|in|inline|inout|static|out|uniform|varying|profile name)\\b", |
| 122 | "name": "storage.modifier.shaderlab" |
| 123 | }, |
| 124 | { |
| 125 | "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", |
| 126 | "name": "storage.type.shaderlab" |
| 127 | } |
| 128 | ] |
| 129 | } |
| 130 | } |
| 131 | } |