initial commit

This commit is contained in:
2025-05-01 23:03:47 +02:00
commit a23fbff52a
200 changed files with 434542 additions and 0 deletions

BIN
ScopEngine/Assets/Images/splashscreen.bmp git.filemode.normal_file

Binary file not shown.

After

Width:  |  Height:  |  Size: 256 KiB

28
ScopEngine/Assets/Shaders/2DFragment.nzsl git.filemode.normal_file
View File

@@ -0,0 +1,28 @@
[nzsl_version("1.0")]
module;
struct VertOut
{
[location(0)] color: vec4[f32],
[location(1)] uv: vec2[f32]
}
struct FragOut
{
[location(0)] color: vec4[f32]
}
external
{
[set(1), binding(0)] u_texture: sampler2D[f32]
}
[entry(frag)]
fn main(input: VertOut) -> FragOut
{
let output: FragOut;
output.color = input.color * u_texture.Sample(input.uv);
if(output.color.w == 0.0)
discard;
return output;
}

45
ScopEngine/Assets/Shaders/2DVertex.nzsl git.filemode.normal_file
View File

@@ -0,0 +1,45 @@
[nzsl_version("1.0")]
module;
struct VertIn
{
[location(0)] pos: vec4[f32],
[location(1)] color: vec4[f32], // unused
[location(2)] normal: vec4[f32], // unused
[location(3)] uv: vec2[f32]
}
struct VertOut
{
[location(0)] color: vec4[f32],
[location(1)] uv: vec2[f32],
[builtin(position)] pos: vec4[f32]
}
struct ViewerData
{
projection_matrix: mat4[f32]
}
struct SpriteData
{
color: vec4[f32],
position: vec2[f32]
}
external
{
[set(0), binding(0)] viewer_data: uniform[ViewerData],
model : push_constant[SpriteData]
}
[entry(vert)]
fn main(input: VertIn) -> VertOut
{
input.uv.x *= -1.0;
let output: VertOut;
output.uv = input.uv;
output.color = model.color;
output.pos = viewer_data.projection_matrix * vec4[f32](input.pos.xy + model.position, 0.0, 1.0);
return output;
}

View File

@@ -0,0 +1,60 @@
[nzsl_version("1.0")]
module;
struct VertOut
{
[location(0)] color : vec4[f32],
[location(1)] uv : vec2[f32],
[location(2)] norm : vec4[f32],
[location(3)] norm_mat : mat4[f32],
[builtin(position)] pos: vec4[f32]
}
struct FragmentData
{
dissolve_texture_factor: f32,
dissolve_black_white_colors_factor: f32,
dissolve_normals_colors_factor: f32,
}
struct FragOut
{
[location(0)] color: vec4[f32]
}
external
{
[set(1), binding(0)] u_albedo: sampler2D[f32],
[set(1), binding(1)] u_fragment_data: uniform[FragmentData],
}
fn Mixf32(a: f32, b: f32, t: f32) -> f32
{
return a + (b - a) * t;
}
fn MixVec4f32(a: vec4[f32], b: vec4[f32], t: f32) -> vec4[f32]
{
return vec4[f32](
Mixf32(a.x, b.x, t),
Mixf32(a.y, b.y, t),
Mixf32(a.z, b.z, t),
Mixf32(a.w, b.w, t)
);
}
[entry(frag)]
fn main(input: VertOut) -> FragOut
{
let texture_color = u_albedo.Sample(input.uv);
let grey_scale_value: f32 = 0.3 * input.color.r + 0.59 * input.color.g + 0.11 * input.color.b;
let grey_scale = vec4[f32](grey_scale_value, grey_scale_value, grey_scale_value, 1.0);
input.color = MixVec4f32(input.color, grey_scale, u_fragment_data.dissolve_black_white_colors_factor);
input.color = MixVec4f32(input.color, abs(input.norm), u_fragment_data.dissolve_normals_colors_factor);
let output: FragOut;
output.color = MixVec4f32(input.color, texture_color, u_fragment_data.dissolve_texture_factor);
return output;
}

View File

@@ -0,0 +1,80 @@
[nzsl_version("1.0")]
module;
struct VertOut
{
[location(0)] color: vec4[f32],
[location(1)] uv: vec2[f32],
[location(2)] norm: vec4[f32],
[location(3)] transformed_norm: vec3[f32],
[location(4)] frag_position: vec4[f32],
[location(5)] camera_position: vec3[f32],
[builtin(position)] pos: vec4[f32]
}
struct FragmentData
{
dissolve_texture_factor: f32,
dissolve_black_white_colors_factor: f32,
dissolve_normals_colors_factor: f32,
}
struct FragOut
{
[location(0)] color: vec4[f32]
}
external
{
[set(1), binding(0)] u_albedo: sampler2D[f32],
[set(1), binding(1)] u_fragment_data: uniform[FragmentData],
}
fn Mixf32(a: f32, b: f32, t: f32) -> f32
{
return a + (b - a) * t;
}
fn MixVec4f32(a: vec4[f32], b: vec4[f32], t: f32) -> vec4[f32]
{
return vec4[f32](
Mixf32(a.x, b.x, t),
Mixf32(a.y, b.y, t),
Mixf32(a.z, b.z, t),
Mixf32(a.w, b.w, t)
);
}
[entry(frag)]
fn main(input: VertOut) -> FragOut
{
if(input.color.a == 0.0)
discard;
const ambient = vec3[f32](0.1, 0.1, 0.1);
const directional_color = vec3[f32](5.0, 5.0, 5.0);
const specular_strength = 0.5;
let directional_vector = normalize(vec3[f32](0.85, 0.8, 0.75));
let directional: f32 = max(dot(input.transformed_norm.xyz, directional_vector), 0.0);
let view_dir: vec3[f32] = normalize(input.camera_position - input.frag_position.xyz);
let reflect_dir: vec3[f32] = reflect(-directional_vector, input.norm.xyz);
let spec: f32 = pow(max(dot(view_dir, reflect_dir), 0.0), 128.0);
let specular: vec3[f32] = specular_strength * spec * directional_color;
let lighting: vec3[f32] = ambient + (directional_color * directional) + specular;
let grey_scale_value: f32 = 0.3 * input.color.r + 0.59 * input.color.g + 0.11 * input.color.b;
let grey_scale = vec4[f32](grey_scale_value, grey_scale_value, grey_scale_value, 1.0);
input.color = MixVec4f32(input.color, grey_scale, u_fragment_data.dissolve_black_white_colors_factor);
input.color = MixVec4f32(input.color, abs(input.norm), u_fragment_data.dissolve_normals_colors_factor);
let texture_color = u_albedo.Sample(input.uv) * u_fragment_data.dissolve_texture_factor;
let final_color = MixVec4f32(input.color, texture_color, u_fragment_data.dissolve_texture_factor);
let output: FragOut;
output.color = MixVec4f32(final_color, final_color * vec4[f32](lighting, 1.0), u_fragment_data.dissolve_texture_factor);
return output;
}

49
ScopEngine/Assets/Shaders/ForwardVertex.nzsl git.filemode.normal_file
View File

@@ -0,0 +1,49 @@
[nzsl_version("1.0")]
module;
import ViewerData from ScopEngine.ViewerData;
struct VertIn
{
[location(0)] pos: vec4[f32],
[location(1)] color: vec4[f32],
[location(2)] normal: vec4[f32],
[location(3)] uv: vec2[f32]
}
struct VertOut
{
[location(0)] color: vec4[f32],
[location(1)] uv: vec2[f32],
[location(2)] norm: vec4[f32],
[location(3)] transformed_norm: vec3[f32],
[location(4)] frag_position: vec4[f32],
[location(5)] camera_position: vec3[f32],
[builtin(position)] pos: vec4[f32]
}
struct ModelData
{
matrix: mat4[f32],
normal: mat4[f32],
}
external
{
[set(0), binding(0)] viewer_data: uniform[ViewerData],
model: push_constant[ModelData]
}
[entry(vert)]
fn main(input: VertIn) -> VertOut
{
let output: VertOut;
output.color = input.color;
output.uv = input.uv;
output.norm = normalize(input.normal);
output.transformed_norm = mat3[f32](model.normal) * output.norm.xyz;
output.frag_position = model.matrix * input.pos;
output.camera_position = viewer_data.camera_position;
output.pos = viewer_data.view_proj_matrix * output.frag_position;
return output;
}

View File

@@ -0,0 +1,15 @@
[nzsl_version("1.0")]
module ScopEngine.ViewerData;
[export]
[layout(std140)]
struct ViewerData
{
projection_matrix: mat4[f32],
inv_projection_matrix: mat4[f32],
view_matrix: mat4[f32],
inv_view_matrix: mat4[f32],
view_proj_matrix: mat4[f32],
inv_view_proj_matrix: mat4[f32],
camera_position: vec3[f32],
}

46
ScopEngine/Assets/Shaders/ScreenFragment.nzsl git.filemode.normal_file
View File

@@ -0,0 +1,46 @@
[nzsl_version("1.0")]
module;
struct VertOut
{
[location(0)] uv: vec2[f32]
}
struct FragOut
{
[location(0)] color: vec4[f32]
}
external
{
[set(0), binding(0)] u_texture: sampler2D[f32]
}
option approximates_rgb: bool = false;
fn LinearTosRGB(color: vec3[f32]) -> vec3[f32]
{
const if(!approximates_rgb)
{
return select(
color > (0.0031308).rrr,
1.055 * pow(color, (1.0 / 2.4).rrr) - (0.055).rrr,
12.92 * color
);
}
else
return pow(color, (1.0 / 2.2).rrr);
}
option gamma_correction: bool = false;
[entry(frag)]
fn main(input: VertOut) -> FragOut
{
let output: FragOut;
const if(gamma_correction)
output.color = vec4[f32](LinearTosRGB(u_texture.Sample(input.uv).xyz), 1.0);
else
output.color = u_texture.Sample(input.uv);
return output;
}

31
ScopEngine/Assets/Shaders/ScreenVertex.nzsl git.filemode.normal_file
View File

@@ -0,0 +1,31 @@
[nzsl_version("1.0")]
module;
struct VertIn
{
[builtin(vertex_index)] vert_index: i32
}
struct VertOut
{
[location(0)] uv: vec2[f32],
[builtin(position)] position: vec4[f32]
}
const vertices = array[vec2[f32]](
vec2[f32](-1.0, -3.0),
vec2[f32](-1.0, 1.0),
vec2[f32]( 3.0, 1.0)
);
[entry(vert)]
fn main(input: VertIn) -> VertOut
{
let position = vertices[input.vert_index];
let output: VertOut;
output.position = vec4[f32](position, 0.0, 1.0);
output.uv = position * 0.5 + vec2[f32](0.5, 0.5);
return output;
}

28
ScopEngine/Assets/Shaders/SkyboxFragment.nzsl git.filemode.normal_file
View File

@@ -0,0 +1,28 @@
[nzsl_version("1.0")]
module;
struct VertOut
{
[location(0)] uvw : vec3[f32]
}
struct FragOut
{
[location(0)] color: vec4[f32],
[builtin(frag_depth)] depth: f32
}
external
{
[set(1), binding(0)] skybox: sampler_cube[f32]
}
[entry(frag)]
[depth_write(greater)]
fn main(input: VertOut) -> FragOut
{
let output: FragOut;
output.color = skybox.Sample(input.uvw);
output.depth = 1.0;
return output;
}

37
ScopEngine/Assets/Shaders/SkyboxVertex.nzsl git.filemode.normal_file
View File

@@ -0,0 +1,37 @@
[nzsl_version("1.0")]
module;
import ViewerData from ScopEngine.ViewerData;
struct VertIn
{
[location(0)] pos: vec4[f32],
[location(1)] color: vec4[f32],
[location(2)] normal: vec4[f32],
[location(3)] uv: vec2[f32]
}
struct VertOut
{
[location(0)] uvw: vec3[f32],
[builtin(position)] pos: vec4[f32]
}
external
{
[set(0), binding(0)] viewer_data: uniform[ViewerData]
}
[entry(vert)]
fn main(input: VertIn) -> VertOut
{
// Set translation part to zero
let rotation_matrix = viewer_data.view_matrix;
rotation_matrix[3].xyz = vec3[f32](0.0, 0.0, 0.0);
let output: VertOut;
output.uvw = input.pos.xyz;
output.uvw.xy *= -1.0;
output.pos = viewer_data.projection_matrix * rotation_matrix * input.pos;
return output;
}

BIN
ScopEngine/Assets/Vendors/nzslc.x86_64 git.filemode.executable_file

Binary file not shown.