Skip to content

Commit 77b830c

Browse files
committed
Proper hlsl syntax hightlighting
1 parent eda3687 commit 77b830c

File tree

3 files changed

+43
-3
lines changed

3 files changed

+43
-3
lines changed

content/blog/custom_dithering_cc_unity.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ truncate_summary = false
2222

2323
Very short blog post on how I implemented a dithering and color compression effect in Unity using its new ``Render Graph API``.
2424
The color compression part is implemented using a simple bit shifting (by getting rid of the first ``n`` bits of the r,g,b values). This is pretty simple and straightforward
25-
The dithering however, was a bit more involved. I tried commenting what each part of the code does (at least in the shader part, the c# side is pretty straight forward)
25+
The dithering however, was a bit more involved. I tried commenting what each part of the code does (at least in the shader part, the c# side is pretty straight forward).
2626

2727
```cs
2828
using UnityEngine;
@@ -105,7 +105,7 @@ public class DitherColorCompressionRenderFeature : ScriptableRendererFeature {
105105
}
106106
```
107107

108-
```glsl
108+
```hlsl
109109
#pragma kernel CSMain
110110
111111
// Properties!!

content/blog/impostor_system.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ for (int i = 0; i < prop.variants.Count; i++) {
125125

126126
## Shader
127127
The unity shader code that handles outputting a passthrogh fullscreen unshaded image based on the required texture type (either diffuse, normals, mask)
128-
```glsl
128+
```hlsl
129129
float3 color = float3(0, 0, 0);
130130
131131
NormalData normalData;

syntaxes/hlsl.sublime-syntax

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Generated by gpt kek
2+
%YAML 1.2
3+
---
4+
name: HLSL
5+
file_extensions:
6+
- hlsl
7+
- fx
8+
- fxh
9+
- hlsli
10+
scope: source.hlsl
11+
contexts:
12+
main:
13+
- match: '\b(float|float[1-4]|int|int[1-4]|bool|bool[1-4]|void|half|half[1-4]|double|double[1-4]|uint|uint[1-4]|dword)\b'
14+
scope: storage.type.hlsl
15+
- match: '\b(Texture[1-3]D|TextureCube|SamplerState|Buffer|StructuredBuffer|RWTexture[1-2]D|RWBuffer)\b'
16+
scope: support.type.hlsl
17+
- match: '\b(for|while|if|else|switch|case|default|do|break|return|continue)\b'
18+
scope: keyword.control.hlsl
19+
- match: '\b(static|const|inline|uniform|volatile|groupshared)\b'
20+
scope: storage.modifier.hlsl
21+
- match: '\b(lerp|saturate|mul|dot|cross|normalize|length|InterlockedAdd|InterlockedAnd|InterlockedExchange|InterlockedCompareExchange|InterlockedMax|InterlockedMin|InterlockedOr|InterlockedXor)\b'
22+
scope: support.function.hlsl
23+
- match: '\b(sampler|sampler1D|sampler2D|sampler3D|samplerCUBE)\b'
24+
scope: storage.type.sampler.hlsl
25+
- match: '\b(\d+\.\d*|\.\d+|\d+)\b'
26+
scope: constant.numeric.hlsl
27+
- match: '\b(true|false)\b'
28+
scope: constant.language.hlsl
29+
- match: '(//.*)$'
30+
scope: comment.line.double-slash.hlsl
31+
- match: '/\*'
32+
push: block_comment
33+
- match: '\b(numthreads)\s*\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*\)'
34+
scope: keyword.directive.hlsl
35+
- match: '#\s*(pragma|include)\b'
36+
scope: keyword.directive.hlsl
37+
block_comment:
38+
- meta_scope: comment.block.hlsl
39+
- match: '\*/'
40+
pop: true

0 commit comments

Comments
 (0)