PluginProbe
Code Block Pro – Beautiful Syntax Highlighting / 1.28.0
Code Block Pro – Beautiful Syntax Highlighting v1.28.0
1.27.1 1.27.2 1.27.3 1.27.4 1.27.5 1.27.6 1.27.7 1.28.0 1.3.0 1.4.0 1.5.0 1.5.1 1.5.2 1.6.0 1.7.0 1.8.0 1.9.0 1.9.1 1.9.2 1.9.3 trunk 1.1.0 1.10.0 1.11.0 1.11.1 All 63 releases
code-block-pro / build / shiki / samples / gdshader.sample

gdshader.sample in Code Block Pro – Beautiful Syntax Highlighting 1.28.0, at build/shiki/samples/gdshader.sample

97 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 shader_type spatial;
2 render_mode wireframe;
3
4 const lowp vec3 v[1] = lowp vec3[1] ( vec3(0, 0, 1) );
5
6 void fn() {
7 // The required amount of scalars
8 vec4 a0 = vec4(0.0, 1.0, 2.0, 3.0);
9 // Complementary vectors and/or scalars
10 vec4 a1 = vec4(vec2(0.0, 1.0), vec2(2.0, 3.0));
11 vec4 a2 = vec4(vec3(0.0, 1.0, 2.0), 3.0);
12 // A single scalar for the whole vector
13 vec4 a3 = vec4(0.0);
14
15 mat2 m2 = mat2(vec2(1.0, 0.0), vec2(0.0, 1.0));
16 mat3 m3 = mat3(vec3(1.0, 0.0, 0.0), vec3(0.0, 1.0, 0.0), vec3(0.0, 0.0, 1.0));
17 mat4 identity = mat4(1.0);
18
19 mat3 basis = mat3(identity);
20 mat4 m4 = mat4(basis);
21 mat2 m2a = mat2(m4);
22
23 vec4 a = vec4(0.0, 1.0, 2.0, 3.0);
24 vec3 b = a.rgb; // Creates a vec3 with vec4 components.
25 vec3 b1 = a.ggg; // Also valid; creates a vec3 and fills it with a single vec4 component.
26 vec3 b2 = a.bgr; // "b" will be vec3(2.0, 1.0, 0.0).
27 vec3 b3 = a.xyz; // Also rgba, xyzw are equivalent.
28 vec3 b4 = a.stp; // And stpq (for texture coordinates).
29 b.bgr = a.rgb; // Valid assignment. "b"'s "blue" component will be "a"'s "red" and vice versa.
30
31 lowp vec4 v0 = vec4(0.0, 1.0, 2.0, 3.0); // low precision, usually 8 bits per component mapped to 0-1
32 mediump vec4 v1 = vec4(0.0, 1.0, 2.0, 3.0); // medium precision, usually 16 bits or half float
33 highp vec4 v2 = vec4(0.0, 1.0, 2.0, 3.0); // high precision, uses full float or integer range (default)
34
35 const vec2 aa = vec2(0.0, 1.0);
36 vec2 bb;
37 bb = aa; // valid
38
39 const vec2 V1 = vec2(1, 1), V2 = vec2(2, 2);
40
41 float fa = 1.0;
42 float fb = 1.0f;
43 float fc = 1e-1;
44
45 uint ua = 1u;
46 uint ub = uint(1);
47
48 bool cond = false;
49 // `if` and `else`.
50 if (cond) {
51 } else {
52 }
53 // Ternary operator.
54 // This is an expression that behaves like `if`/`else` and returns the value.
55 // If `cond` evaluates to `true`, `result` will be `9`.
56 // Otherwise, `result` will be `5`.
57 int i, result = cond ? 9 : 5;
58 // `switch`.
59 switch (i) { // `i` should be a signed integer expression.
60 case -1:
61 break;
62 case 0:
63 return; // `break` or `return` to avoid running the next `case`.
64 case 1: // Fallthrough (no `break` or `return`): will run the next `case`.
65 case 2:
66 break;
67 //...
68 default: // Only run if no `case` above matches. Optional.
69 break;
70 }
71 // `for` loop. Best used when the number of elements to iterate on
72 // is known in advance.
73 for (int i = 0; i < 10; i++) {
74 }
75 // `while` loop. Best used when the number of elements to iterate on
76 // is not known in advance.
77 while (cond) {
78 }
79 // `do while`. Like `while`, but always runs at least once even if `cond`
80 // never evaluates to `true`.
81 do {
82 } while (cond);
83 }
84
85 const float PI_ = 3.14159265358979323846;
86
87 struct PointLight {
88 vec3 position;
89 vec3 color;
90 float intensity;
91 };
92
93 struct Scene {
94 PointLight lights[2];
95 };
96
97 // from https://github.com/godotengine/godot-vscode-plugin/blob/cdc550a412dfffd26dfe7351e429b73c819d68d0/syntaxes/examples/example2.gdshader