Shader: Add module resolver + use modules for engine shaders

This commit is contained in:
Jérôme Leclercq
2022-03-10 21:00:10 +01:00
parent 98bd04e35a
commit db0c1e6e8c
30 changed files with 737 additions and 106 deletions

View File

@@ -0,0 +1,10 @@
[nzsl_version("1.0")]
module;
[export]
[layout(std140)]
struct InstanceData
{
worldMatrix: mat4[f32],
invWorldMatrix: mat4[f32]
}

View File

@@ -0,0 +1,17 @@
[nzsl_version("1.0")]
module;
[export]
[layout(std140)]
struct ViewerData
{
projectionMatrix: mat4[f32],
invProjectionMatrix: mat4[f32],
viewMatrix: mat4[f32],
invViewMatrix: mat4[f32],
viewProjMatrix: mat4[f32],
invViewProjMatrix: mat4[f32],
renderTargetSize: vec2[f32],
invRenderTargetSize: vec2[f32],
eyePosition: vec3[f32]
}

View File

@@ -1,6 +1,9 @@
[nzsl_version("1.0")]
module;
import Engine/InstanceData;
import Engine/ViewerData;
option HasDiffuseTexture: bool = false;
option HasAlphaTexture: bool = false;
option AlphaTest: bool = false;
@@ -27,27 +30,6 @@ struct MaterialSettings
DiffuseColor: vec4[f32]
}
[layout(std140)]
struct InstanceData
{
worldMatrix: mat4[f32],
invWorldMatrix: mat4[f32]
}
[layout(std140)]
struct ViewerData
{
projectionMatrix: mat4[f32],
invProjectionMatrix: mat4[f32],
viewMatrix: mat4[f32],
invViewMatrix: mat4[f32],
viewProjMatrix: mat4[f32],
invViewProjMatrix: mat4[f32],
renderTargetSize: vec2[f32],
invRenderTargetSize: vec2[f32],
eyePosition: vec3[f32]
}
external
{
[binding(0)] settings: uniform[MaterialSettings],

View File

@@ -1,6 +1,9 @@
[nzsl_version("1.0")]
module;
import Engine/InstanceData;
import Engine/ViewerData;
option HasDiffuseTexture: bool = false;
option HasAlphaTexture: bool = false;
option AlphaTest: bool = false;
@@ -14,27 +17,6 @@ struct BasicSettings
DiffuseColor: vec4[f32]
}
[layout(std140)]
struct InstanceData
{
worldMatrix: mat4[f32],
invWorldMatrix: mat4[f32]
}
[layout(std140)]
struct ViewerData
{
projectionMatrix: mat4[f32],
invProjectionMatrix: mat4[f32],
viewMatrix: mat4[f32],
invViewMatrix: mat4[f32],
viewProjMatrix: mat4[f32],
invViewProjMatrix: mat4[f32],
renderTargetSize: vec2[f32],
invRenderTargetSize: vec2[f32],
eyePosition: vec3[f32]
}
external
{
[binding(0)] settings: uniform[BasicSettings],

View File

@@ -1,6 +1,9 @@
[nzsl_version("1.0")]
module;
import Engine/InstanceData;
import Engine/ViewerData;
// Basic material options
option HasDiffuseTexture: bool = false;
option HasAlphaTexture: bool = false;
@@ -47,13 +50,6 @@ struct MaterialSettings
Shininess: f32,
}
[layout(std140)]
struct InstanceData
{
worldMatrix: mat4[f32],
invWorldMatrix: mat4[f32]
}
// TODO: Add enums
const DirectionalLight = 0;
const PointLight = 1;
@@ -78,20 +74,6 @@ struct LightData
lightCount: u32,
}
[layout(std140)]
struct ViewerData
{
projectionMatrix: mat4[f32],
invProjectionMatrix: mat4[f32],
viewMatrix: mat4[f32],
invViewMatrix: mat4[f32],
viewProjMatrix: mat4[f32],
invViewProjMatrix: mat4[f32],
renderTargetSize: vec2[f32],
invRenderTargetSize: vec2[f32],
eyePosition: vec3[f32]
}
external
{
[binding(0)] settings: uniform[MaterialSettings],