Skip to content

Commit 9df1df8

Browse files
committed
Update shaders to NZSL 1.1
1 parent 78a181a commit 9df1df8

5 files changed

Lines changed: 57 additions & 49 deletions

File tree

assets/shaders/BlockPBR.nzsl

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[nzsl_version("1.0")]
1+
[nzsl_version("1.1")]
22
module TSOM.BlockPBR;
33

44
import InstanceData from Engine.InstanceData;
@@ -28,31 +28,33 @@ option HasNormalTexture: bool = false;
2828
option HasRoughnessTexture: bool = false;
2929
option HasSpecularTexture: bool = false;
3030

31+
const InvalidLoc = u32.Max;
32+
3133
// Billboard related options
3234
option Billboard: bool = false;
33-
option BillboardCenterLocation: i32 = -1;
34-
option BillboardColorLocation: i32 = -1;
35-
option BillboardSizeRotLocation: i32 = -1;
35+
option BillboardCenterLocation: u32 = InvalidLoc;
36+
option BillboardColorLocation: u32 = InvalidLoc;
37+
option BillboardSizeRotLocation: u32 = InvalidLoc;
3638

3739
// Vertex declaration related options
38-
option VertexColorLoc: i32 = -1;
39-
option VertexNormalLoc: i32 = -1;
40-
option VertexPositionLoc: i32;
41-
option VertexTangentLoc: i32 = -1;
42-
option VertexUvLoc: i32 = -1;
40+
option VertexColorLoc: u32 = InvalidLoc;
41+
option VertexNormalLoc: u32 = InvalidLoc;
42+
option VertexPositionLoc: u32 = InvalidLoc;
43+
option VertexTangentLoc: u32 = InvalidLoc;
44+
option VertexUvLoc: u32 = InvalidLoc;
4345

44-
option VertexJointIndicesLoc: i32 = -1;
45-
option VertexJointWeightsLoc: i32 = -1;
46+
option VertexJointIndicesLoc: u32 = InvalidLoc;
47+
option VertexJointWeightsLoc: u32 = InvalidLoc;
4648

47-
option MaxLightCount: u32 = u32(3); //< FIXME: Fix integral value types
49+
option MaxLightCount: u32 = 3;
4850

49-
const HasNormal = (VertexNormalLoc >= 0);
50-
const HasVertexColor = (VertexColorLoc >= 0);
51+
const HasNormal = (VertexNormalLoc != InvalidLoc);
52+
const HasVertexColor = (VertexColorLoc != InvalidLoc);
5153
const HasColor = (HasVertexColor || Billboard);
52-
const HasTangent = (VertexTangentLoc >= 0);
53-
const HasUV = (VertexUvLoc >= 0);
54+
const HasTangent = (VertexTangentLoc != InvalidLoc);
55+
const HasUV = (VertexUvLoc != InvalidLoc);
5456
const HasNormalMapping = HasNormalTexture && HasNormal && HasTangent && !DepthPass;
55-
const HasSkinning = (VertexJointIndicesLoc >= 0 && VertexJointWeightsLoc >= 0);
57+
const HasSkinning = (VertexJointIndicesLoc != InvalidLoc && VertexJointWeightsLoc != InvalidLoc);
5658

5759
[layout(std140)]
5860
struct MaterialSettings

assets/shaders/Logo.nzsl

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[nzsl_version("1.0")]
1+
[nzsl_version("1.1")]
22
module TSOM.Logo;
33

44
import InstanceData from Engine.InstanceData;
@@ -9,22 +9,24 @@ option HasBaseColorTexture: bool = false;
99
option HasAlphaTexture: bool = false;
1010
option AlphaTest: bool = false;
1111

12+
const InvalidLoc = u32.Max;
13+
1214
// Vertex declaration related options
13-
option VertexColorLoc: i32 = -1;
14-
option VertexNormalLoc: i32 = -1;
15-
option VertexPositionLoc: i32 = -1;
16-
option VertexSizeRotLocation: i32 = -1;
17-
option VertexUvLoc: i32 = -1;
15+
option VertexColorLoc: u32 = InvalidLoc;
16+
option VertexNormalLoc: u32 = InvalidLoc;
17+
option VertexPositionLoc: u32 = InvalidLoc;
18+
option VertexSizeRotLocation: u32 = InvalidLoc;
19+
option VertexUvLoc: u32 = InvalidLoc;
1820

19-
option VertexJointIndicesLoc: i32 = -1;
20-
option VertexJointWeightsLoc: i32 = -1;
21+
option VertexJointIndicesLoc: u32 = InvalidLoc;
22+
option VertexJointWeightsLoc: u32 = InvalidLoc;
2123

22-
const HasNormal = (VertexNormalLoc >= 0);
23-
const HasVertexColor = (VertexColorLoc >= 0);
24+
const HasNormal = (VertexNormalLoc != InvalidLoc);
25+
const HasVertexColor = (VertexColorLoc != InvalidLoc);
2426
const HasColor = (HasVertexColor);
25-
const HasVertexUV = (VertexUvLoc >= 0);
27+
const HasVertexUV = (VertexUvLoc != InvalidLoc);
2628
const HasUV = (HasVertexUV);
27-
const HasSkinning = (VertexJointIndicesLoc >= 0 && VertexJointWeightsLoc >= 0);
29+
const HasSkinning = (VertexJointIndicesLoc != InvalidLoc && VertexJointWeightsLoc != InvalidLoc);
2830

2931
[layout(std140)]
3032
struct MaterialSettings

assets/shaders/PlanetAtmosphere.nzsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[nzsl_version("1.0")]
1+
[nzsl_version("1.1")]
22
module TSOM.PlanetAtmosphere;
33

44
import VertexShader from Engine.FullscreenVertex;

assets/shaders/PlayerPBR.nzsl

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[nzsl_version("1.0")]
1+
[nzsl_version("1.1")]
22
module TSOM.PlayerPBR;
33

44
import InstanceData from Engine.InstanceData;
@@ -29,30 +29,32 @@ option HasNormalTexture: bool = false;
2929
option HasRoughnessTexture: bool = false;
3030
option HasSpecularTexture: bool = false;
3131

32+
const InvalidLoc = u32.Max;
33+
3234
// Billboard related options
3335
option Billboard: bool = false;
3436

3537
// Vertex declaration related options
36-
option VertexColorLoc: i32 = -1;
37-
option VertexNormalLoc: i32 = -1;
38-
option VertexPositionLoc: i32 = -1;
39-
option VertexSizeRotLocation: i32 = -1;
40-
option VertexTangentLoc: i32 = -1;
41-
option VertexUvLoc: i32 = -1;
38+
option VertexColorLoc: u32 = InvalidLoc;
39+
option VertexNormalLoc: u32 = InvalidLoc;
40+
option VertexPositionLoc: u32 = InvalidLoc;
41+
option VertexSizeRotLocation: u32 = InvalidLoc;
42+
option VertexTangentLoc: u32 = InvalidLoc;
43+
option VertexUvLoc: u32 = InvalidLoc;
4244

43-
option VertexJointIndicesLoc: i32 = -1;
44-
option VertexJointWeightsLoc: i32 = -1;
45+
option VertexJointIndicesLoc: u32 = InvalidLoc;
46+
option VertexJointWeightsLoc: u32 = InvalidLoc;
4547

46-
option MaxLightCount: u32 = u32(3); //< FIXME: Fix integral value types
48+
option MaxLightCount: u32 = 3;
4749

48-
const HasNormal = (VertexNormalLoc >= 0);
49-
const HasVertexColor = (VertexColorLoc >= 0);
50+
const HasNormal = (VertexNormalLoc != InvalidLoc);
51+
const HasVertexColor = (VertexColorLoc != InvalidLoc);
5052
const HasColor = (HasVertexColor || Billboard);
51-
const HasTangent = (VertexTangentLoc >= 0);
52-
const HasVertexUV = (VertexUvLoc >= 0);
53+
const HasTangent = (VertexTangentLoc != InvalidLoc);
54+
const HasVertexUV = (VertexUvLoc != InvalidLoc);
5355
const HasUV = (HasVertexUV);
5456
const HasNormalMapping = HasNormalTexture && HasNormal && HasTangent && !DepthPass;
55-
const HasSkinning = (VertexJointIndicesLoc >= 0 && VertexJointWeightsLoc >= 0);
57+
const HasSkinning = (VertexJointIndicesLoc != InvalidLoc && VertexJointWeightsLoc != InvalidLoc);
5658

5759
[layout(std140)]
5860
struct MaterialSettings

assets/shaders/SkyboxMaterial.nzsl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
[nzsl_version("1.0")]
1+
[nzsl_version("1.1")]
22
module SkyboxMaterial;
33

44
import ViewerData from Engine.ViewerData;
55

66
// Material options
77
option HasBaseColorTexture: bool = false;
88

9+
const InvalidLoc = u32.Max;
10+
911
// Vertex declaration related options
10-
option VertexColorLoc: i32 = -1;
11-
option VertexPositionLoc: i32;
12+
option VertexColorLoc: u32 = InvalidLoc;
13+
option VertexPositionLoc: u32 = InvalidLoc;
1214

13-
const HasColor = (VertexColorLoc >= 0);
15+
const HasColor = (VertexColorLoc != InvalidLoc);
1416

1517
[layout(std140)]
1618
struct MaterialSettings

0 commit comments

Comments
 (0)