|
1 | 1 | # HCSL (Heliodor Custom Shader Language) |
2 | 2 |
|
3 | 3 | ## Overview |
4 | | -Heliodor now supports custom shaders. HCSL (Heliodor Custom Shader Language) is Heliodor's proprietary shader language. |
| 4 | +Heliodor now supports custom shaders. |
| 5 | +HCSL (Heliodor Custom Shader Language) is a shader language unique to Heliodor. |
5 | 6 |
|
6 | 7 | ## Implementation |
7 | 8 |
|
8 | 9 | ### Shader Compilation |
9 | 10 |
|
10 | | -1. Right-click in the Project view and create a ShaderLab by selecting "Create → Shader → UnlitShader", then name it "sample" |
11 | | - |
12 | | -  |
13 | | - |
14 | | -2. Right-click the generated sample shader and create a material from the Material button. Name it "sample" as well |
15 | | - |
16 | | -  |
17 | | - |
18 | | -3. Add a Plane to the Unity scene as a child element of HCSL_Test and place it near WavePlane |
19 | | - |
20 | | -  |
21 | | - |
22 | | -4. Attach the sample material to the Plane. Also, remove the mesh collider as it is not needed |
23 | | - |
24 | | -5. Duplicate WavePlane.hcsl with Ctrl + D and rename it to "sample" |
25 | | - |
26 | | -  |
27 | | - |
28 | | -6. Double-click sample.hcsl to open it in your preferred editor |
29 | | - |
30 | | - !!! note "Note" |
31 | | - Open with Shift JIS encoding |
32 | | - |
33 | | -7. Change the shader name in the hcsl file to "sample" and save |
34 | | - |
35 | | -  |
36 | | - |
37 | | -8. Add the HEOCustomShader component to the Plane via Add Component |
38 | | - |
39 | | -  |
40 | | - |
41 | | -9. Attach the sample material and sample.hcsl |
42 | | - |
43 | | -  |
44 | | - |
45 | | -10. Click the three-dot button on HEOCustomShader and find and press the Compile button |
46 | | - |
47 | | -  |
48 | | - |
49 | | -11. The HCSL will be converted to ShaderLab. If "Success!!" appears in the Unity console, it was successful |
50 | | - |
51 | | -  |
52 | | - |
53 | | -### Using HCSL In-Game |
54 | | - |
55 | | -1. Select HCSL_Test and export HEO via VketCloudSDK → Export Field |
56 | | - |
57 | | -  |
58 | | - |
59 | | -2. Export the HEO to "release/data/Field/HCSL_Test" |
60 | | - |
61 | | -  |
62 | | - |
63 | | -3. Copy the created sample.hcsl to "release/data/Shaders" |
64 | | - |
65 | | -  |
66 | | - |
67 | | -4. Open `release\data\Scene\streamingvideo.json` in a text editor |
68 | | - |
69 | | -  |
70 | | - |
71 | | -5. Find the shaders field and add the path to the sample.hcsl you just added: `"Shaders/sample.hcsl"` |
72 | | - |
73 | | -  |
74 | | - |
75 | | -6. Finally, set up a local server as you did in the preparation phase, enter the game, and verify that the created shader is reflected |
76 | | - |
77 | | -  |
| 11 | +1 Add a Plane to the scene. |
| 12 | + |
| 13 | +  |
| 14 | + |
| 15 | +2 Right-click in the Project View and create an HCSL file via **Create → HCSL File**, then name it `sample`. |
| 16 | + |
| 17 | +  |
| 18 | + |
| 19 | +3 Double-click the generated `sample` HCSL shader to open it in the editor, then paste the following sample shader in its entirety. |
| 20 | + |
| 21 | +``` |
| 22 | +#version 1 |
| 23 | +
|
| 24 | +hcsl "sample" |
| 25 | +{ |
| 26 | + pass Geometry_Opaque |
| 27 | + { |
| 28 | +
|
| 29 | + renderparam |
| 30 | + { |
| 31 | + bool hel_z_write = true; |
| 32 | + int hel_cull_mode = HEL_CULL_BACK; |
| 33 | + } |
| 34 | +
|
| 35 | + attribute |
| 36 | + { |
| 37 | + vec3 _Position : VS_POSITION; |
| 38 | + vec3 _Normal : VS_NORMAL; |
| 39 | + vec2 _TexCoord0 : VS_UV; |
| 40 | + } |
| 41 | +
|
| 42 | + output vertex |
| 43 | + { |
| 44 | + vec4 outPos : VS_OUT_POSITION; |
| 45 | + vec3 WorldNormal; |
| 46 | + vec3 WorldPos; |
| 47 | + vec2 uv; |
| 48 | + } |
| 49 | +
|
| 50 | + uniform vertex |
| 51 | + { |
| 52 | + float _Seed = 1.0; |
| 53 | + float _Size = 0.1; |
| 54 | + } |
| 55 | +
|
| 56 | + shader vertex |
| 57 | + { |
| 58 | + float g_Offset; |
| 59 | + float wave(vec2 st) |
| 60 | + { |
| 61 | + return sin(st.x * 50.0 + HEL_TIME) * 1.5; |
| 62 | + } |
| 63 | + void main() |
| 64 | + { |
| 65 | + g_Offset = 10.0; |
| 66 | + vec4 pos = vec4(_Position, 1.0); |
| 67 | + pos.y += wave(_TexCoord0 * _Size + vec2(_Seed + g_Offset)); |
| 68 | + outPos = HEL_MATRIX_P * HEL_MATRIX_V * HEL_MATRIX_W * pos; |
| 69 | + WorldNormal = (HEL_MATRIX_W * vec4(_Normal, 0.0)).xyz; |
| 70 | + uv = _TexCoord0; |
| 71 | + } |
| 72 | + } |
| 73 | +
|
| 74 | + input fragment |
| 75 | + { |
| 76 | + vec3 WorldNormal; |
| 77 | + vec2 uv; |
| 78 | + } |
| 79 | +
|
| 80 | + output fragment |
| 81 | + { |
| 82 | + vec4 outColor : FS_COLOR; |
| 83 | + } |
| 84 | +
|
| 85 | + uniform fragment |
| 86 | + { |
| 87 | + vec4 _MainColor = vec4(1.0); |
| 88 | + sampler2D _MainTex; |
| 89 | + vec4 _MainTex_ST; |
| 90 | + } |
| 91 | +
|
| 92 | + shader fragment |
| 93 | + { |
| 94 | + void main() |
| 95 | + { |
| 96 | + vec4 col = vec4(1.0, 0.0, 0.0, 1.0); |
| 97 | + outColor = col; |
| 98 | + } |
| 99 | + } |
| 100 | + } |
| 101 | +} |
| 102 | +``` |
| 103 | + |
| 104 | +4 Attach a **VKC Shader** component to the Plane. |
| 105 | + |
| 106 | +  |
| 107 | + |
| 108 | +5 Drag and drop the `sample.hcsl` file you just created into the **HCSL Core** field of the VKC Shader component. |
| 109 | + |
| 110 | +  |
| 111 | + |
| 112 | +6 Click the vertical three-dot menu in the upper-right corner of the VKC Shader component to open the menu, then click **Compile** at the bottom. |
| 113 | + |
| 114 | +  |
| 115 | + |
| 116 | +7 A rippling red Plane effect will now appear. |
| 117 | + |
| 118 | +  |
| 119 | + |
| 120 | +8 Finally, perform a **Build and Run** as usual to confirm that the shader is applied correctly in VketCloud. |
| 121 | + |
| 122 | +  |
0 commit comments