Remove assets from repository and download them using xmake
This commit is contained in:
69
assets/shaders/bloom_bright.nzsl
Normal file
69
assets/shaders/bloom_bright.nzsl
Normal file
@@ -0,0 +1,69 @@
|
||||
[nzsl_version("1.0")]
|
||||
module;
|
||||
|
||||
import Engine.ViewerData;
|
||||
|
||||
external
|
||||
{
|
||||
[set(0), binding(0)] viewerData: uniform[ViewerData],
|
||||
[set(0), binding(1)] colorTexture: sampler2D[f32],
|
||||
}
|
||||
|
||||
struct FragIn
|
||||
{
|
||||
[builtin(fragcoord)] fragcoord: vec4[f32],
|
||||
[location(0)] uv: vec2[f32]
|
||||
}
|
||||
|
||||
struct FragOut
|
||||
{
|
||||
[location(0)] color: vec4[f32]
|
||||
}
|
||||
|
||||
struct VertIn
|
||||
{
|
||||
[location(0)] pos: vec2[f32],
|
||||
[location(1)] uv: vec2[f32]
|
||||
}
|
||||
|
||||
struct VertOut
|
||||
{
|
||||
[builtin(position)] position: vec4[f32],
|
||||
[location(0)] uv: vec2[f32]
|
||||
}
|
||||
|
||||
[entry(frag)]
|
||||
fn main(input: FragIn) -> FragOut
|
||||
{
|
||||
/*let BrightLuminance = 0.8;
|
||||
let BrightMiddleGrey = 0.5;
|
||||
let BrightThreshold = 0.7;
|
||||
|
||||
let color = colorTexture.Sample(input.uv).rgb;
|
||||
color *= BrightMiddleGrey / BrightLuminance;
|
||||
color *= vec3[f32](1.0, 1.0, 1.0) + (color / (BrightThreshold*BrightThreshold));
|
||||
color -= vec3[f32](0.5, 0.5, 0.5);
|
||||
color /= vec3[f32](1.0, 1.0, 1.0) + color;*/
|
||||
|
||||
let output: FragOut;
|
||||
//output.color = vec4[f32](max(color, vec3[f32](0.0, 0.0, 0.0)), 1.0);
|
||||
|
||||
let color = colorTexture.Sample(input.uv).rgb;
|
||||
let brightness = dot(color, vec3[f32](0.2126, 0.7152, 0.0722));
|
||||
if (brightness > 1.0)
|
||||
output.color = vec4[f32](color, 1.0);
|
||||
else
|
||||
output.color = vec4[f32](0.0, 0.0, 0.0, 1.0);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
[entry(vert)]
|
||||
fn main(input: VertIn) -> VertOut
|
||||
{
|
||||
let output: VertOut;
|
||||
output.position = vec4[f32](input.pos, 0.0, 1.0);
|
||||
output.uv = input.uv;
|
||||
|
||||
return output;
|
||||
}
|
||||
52
assets/shaders/bloom_final.nzsl
Normal file
52
assets/shaders/bloom_final.nzsl
Normal file
@@ -0,0 +1,52 @@
|
||||
[nzsl_version("1.0")]
|
||||
module;
|
||||
|
||||
import Engine.ViewerData;
|
||||
|
||||
external
|
||||
{
|
||||
[set(0), binding(0)] viewerData: uniform[ViewerData],
|
||||
//[set(0), binding(1)] colorTexture: sampler2D[f32],
|
||||
[set(0), binding(2)] bloomTexture: sampler2D[f32],
|
||||
}
|
||||
|
||||
struct FragIn
|
||||
{
|
||||
[location(0)] uv: vec2[f32]
|
||||
}
|
||||
|
||||
struct FragOut
|
||||
{
|
||||
[location(0)] color: vec4[f32]
|
||||
}
|
||||
|
||||
struct VertIn
|
||||
{
|
||||
[location(0)] pos: vec2[f32],
|
||||
[location(1)] uv: vec2[f32],
|
||||
}
|
||||
|
||||
struct VertOut
|
||||
{
|
||||
[location(0)] uv: vec2[f32],
|
||||
[builtin(position)] position: vec4[f32]
|
||||
}
|
||||
|
||||
[entry(frag)]
|
||||
fn main(input: FragIn) -> FragOut
|
||||
{
|
||||
let output: FragOut;
|
||||
output.color = /*colorTexture.Sample(fragcoord) + */bloomTexture.Sample(input.uv);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
[entry(vert)]
|
||||
fn main(input: VertIn) -> VertOut
|
||||
{
|
||||
let output: VertOut;
|
||||
output.position = vec4[f32](input.pos, 0.0, 1.0);
|
||||
output.uv = input.uv;
|
||||
|
||||
return output;
|
||||
}
|
||||
63
assets/shaders/deferred_frag.nzsl
Normal file
63
assets/shaders/deferred_frag.nzsl
Normal file
@@ -0,0 +1,63 @@
|
||||
[nzsl_version("1.0")]
|
||||
module;
|
||||
|
||||
import Engine.InstanceData;
|
||||
import Engine.ViewerData;
|
||||
|
||||
option HasDiffuseTexture: bool = false;
|
||||
option HasAlphaTexture: bool = false;
|
||||
option AlphaTest: bool = false;
|
||||
|
||||
[layout(std140)]
|
||||
struct BasicSettings
|
||||
{
|
||||
AlphaThreshold: f32,
|
||||
DiffuseColor: vec4[f32]
|
||||
}
|
||||
|
||||
external
|
||||
{
|
||||
[binding(0)] settings: uniform[BasicSettings],
|
||||
[binding(1)] MaterialDiffuseMap: sampler2D[f32],
|
||||
[binding(2)] MaterialAlphaMap: sampler2D[f32],
|
||||
[binding(3)] TextureOverlay: sampler2D[f32],
|
||||
[binding(4)] instanceData: uniform[InstanceData],
|
||||
[binding(5)] viewerData: uniform[ViewerData],
|
||||
}
|
||||
|
||||
struct InputData
|
||||
{
|
||||
[location(0)] normal: vec3[f32],
|
||||
[location(1)] uv: vec2[f32],
|
||||
[location(2)] pos: vec3[f32]
|
||||
}
|
||||
|
||||
struct OutputData
|
||||
{
|
||||
[location(0)] diffuseMap: vec4[f32],
|
||||
[location(1)] normalMap: vec4[f32],
|
||||
[location(2)] positionMap: vec4[f32]
|
||||
}
|
||||
|
||||
[entry(frag)]
|
||||
fn main(input: InputData) -> OutputData
|
||||
{
|
||||
let diffuseColor = settings.DiffuseColor;
|
||||
const if (HasDiffuseTexture)
|
||||
diffuseColor *= MaterialDiffuseMap.Sample(input.uv);
|
||||
|
||||
const if (HasAlphaTexture)
|
||||
diffuseColor.w *= MaterialAlphaMap.Sample(input.uv).x;
|
||||
|
||||
const if (AlphaTest)
|
||||
{
|
||||
if (diffuseColor.w < settings.AlphaThreshold)
|
||||
discard;
|
||||
}
|
||||
|
||||
let output: OutputData;
|
||||
output.diffuseMap = diffuseColor;
|
||||
output.normalMap = vec4[f32]((vec3[f32](1.0, 1.0, 1.0) + input.normal) * 0.5, 1.0);
|
||||
output.positionMap = vec4[f32](input.pos, 1.0);
|
||||
return output;
|
||||
}
|
||||
47
assets/shaders/deferred_vert.nzsl
Normal file
47
assets/shaders/deferred_vert.nzsl
Normal file
@@ -0,0 +1,47 @@
|
||||
[nzsl_version("1.0")]
|
||||
module;
|
||||
|
||||
import Engine.InstanceData;
|
||||
import Engine.ViewerData;
|
||||
|
||||
[layout(std140)]
|
||||
struct BasicSettings
|
||||
{
|
||||
AlphaThreshold: f32,
|
||||
DiffuseColor: vec4[f32]
|
||||
}
|
||||
|
||||
external
|
||||
{
|
||||
[binding(0)] settings: uniform[BasicSettings],
|
||||
[binding(4)] instanceData: uniform[InstanceData],
|
||||
[binding(5)] viewerData: uniform[ViewerData],
|
||||
}
|
||||
|
||||
struct InputData
|
||||
{
|
||||
[location(0)] pos: vec3[f32],
|
||||
[location(1)] normal: vec3[f32],
|
||||
[location(2)] uv: vec2[f32]
|
||||
}
|
||||
|
||||
struct OutputData
|
||||
{
|
||||
[location(0)] normal: vec3[f32],
|
||||
[location(1)] uv: vec2[f32],
|
||||
[location(2)] pos: vec3[f32],
|
||||
[builtin(position)] position: vec4[f32]
|
||||
}
|
||||
|
||||
[entry(vert)]
|
||||
fn main(input: InputData) -> OutputData
|
||||
{
|
||||
let worldPos = instanceData.worldMatrix * vec4[f32](input.pos, 1.0);
|
||||
|
||||
let output: OutputData;
|
||||
output.uv = input.uv;
|
||||
output.normal = input.normal;
|
||||
output.pos = worldPos.xyz;
|
||||
output.position = viewerData.viewProjMatrix * instanceData.worldMatrix * vec4[f32](input.pos, 1.0);
|
||||
return output;
|
||||
}
|
||||
49
assets/shaders/gamma.nzsl
Normal file
49
assets/shaders/gamma.nzsl
Normal file
@@ -0,0 +1,49 @@
|
||||
[nzsl_version("1.0")]
|
||||
module;
|
||||
|
||||
external
|
||||
{
|
||||
[binding(0)] colorTexture: sampler2D[f32]
|
||||
}
|
||||
|
||||
struct FragIn
|
||||
{
|
||||
[location(0)] uv: vec2[f32]
|
||||
}
|
||||
|
||||
struct FragOut
|
||||
{
|
||||
[location(0)] color: vec4[f32]
|
||||
}
|
||||
|
||||
struct VertIn
|
||||
{
|
||||
[location(0)] pos: vec2[f32],
|
||||
[location(1)] uv: vec2[f32]
|
||||
}
|
||||
|
||||
struct VertOut
|
||||
{
|
||||
[location(0)] vertUV: vec2[f32],
|
||||
[builtin(position)] position: vec4[f32]
|
||||
}
|
||||
|
||||
[entry(frag)]
|
||||
fn main(input: FragIn) -> FragOut
|
||||
{
|
||||
let gamma = 2.2;
|
||||
|
||||
let output: FragOut;
|
||||
output.color = colorTexture.Sample(input.uv);
|
||||
//output.color = pow(colorTexture.Sample(input.uv), vec4[f32](1.0 / gamma, 1.0 / gamma, 1.0 / gamma, 1.0));
|
||||
return output;
|
||||
}
|
||||
|
||||
[entry(vert)]
|
||||
fn main(input: VertIn) -> VertOut
|
||||
{
|
||||
let output: VertOut;
|
||||
output.position = vec4[f32](input.pos, 0.0, 1.0);
|
||||
output.vertUV = input.uv;
|
||||
return output;
|
||||
}
|
||||
69
assets/shaders/gaussian_blur.nzsl
Normal file
69
assets/shaders/gaussian_blur.nzsl
Normal file
@@ -0,0 +1,69 @@
|
||||
[nzsl_version("1.0")]
|
||||
module;
|
||||
|
||||
import Engine.ViewerData;
|
||||
|
||||
[layout(std140)]
|
||||
struct BlurData
|
||||
{
|
||||
direction: vec2[f32],
|
||||
sizeFactor: f32
|
||||
}
|
||||
|
||||
external
|
||||
{
|
||||
[set(0), binding(0)] viewerData: uniform[ViewerData],
|
||||
[set(0), binding(1)] colorTexture: sampler2D[f32],
|
||||
[set(0), binding(2)] blurData: uniform[BlurData]
|
||||
}
|
||||
|
||||
struct FragIn
|
||||
{
|
||||
[location(0)] uv: vec2[f32]
|
||||
}
|
||||
|
||||
struct FragOut
|
||||
{
|
||||
[location(0)] color: vec4[f32]
|
||||
}
|
||||
|
||||
struct VertIn
|
||||
{
|
||||
[location(0)] pos: vec2[f32],
|
||||
[location(1)] uv: vec2[f32],
|
||||
}
|
||||
|
||||
struct VertOut
|
||||
{
|
||||
[location(0)] uv: vec2[f32],
|
||||
[builtin(position)] position: vec4[f32]
|
||||
}
|
||||
|
||||
[entry(frag)]
|
||||
fn main(input: FragIn) -> FragOut
|
||||
{
|
||||
let invTargetSize = viewerData.invRenderTargetSize * blurData.sizeFactor;
|
||||
|
||||
let color = colorTexture.Sample(input.uv).rgb * 0.2270270270;
|
||||
|
||||
color += colorTexture.Sample(input.uv + blurData.direction * 1.3846153846 * invTargetSize).rgb * 0.3162162162;
|
||||
color += colorTexture.Sample(input.uv - blurData.direction * 1.3846153846 * invTargetSize).rgb * 0.3162162162;
|
||||
|
||||
color += colorTexture.Sample(input.uv + blurData.direction * 3.2307692308 * invTargetSize).rgb * 0.0702702703;
|
||||
color += colorTexture.Sample(input.uv - blurData.direction * 3.2307692308 * invTargetSize).rgb * 0.0702702703;
|
||||
|
||||
let output: FragOut;
|
||||
output.color = vec4[f32](color, 1.0);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
[entry(vert)]
|
||||
fn main(input: VertIn) -> VertOut
|
||||
{
|
||||
let output: VertOut;
|
||||
output.position = vec4[f32](input.pos, 0.0, 1.0);
|
||||
output.uv = input.uv;
|
||||
|
||||
return output;
|
||||
}
|
||||
83
assets/shaders/god_rays.nzsl
Normal file
83
assets/shaders/god_rays.nzsl
Normal file
@@ -0,0 +1,83 @@
|
||||
[nzsl_version("1.0")]
|
||||
module;
|
||||
|
||||
import Engine.ViewerData;
|
||||
|
||||
[layout(std140)]
|
||||
struct Settings
|
||||
{
|
||||
exposure: f32,
|
||||
decay: f32,
|
||||
density: f32,
|
||||
weight: f32,
|
||||
lightPosition: vec2[f32], //< TODO: Switch to world position
|
||||
}
|
||||
|
||||
const SampleCount: i32 = 200;
|
||||
|
||||
external
|
||||
{
|
||||
[set(0), binding(0)] viewerData: uniform[ViewerData],
|
||||
[set(0), binding(1)] settings: uniform[Settings],
|
||||
[set(0), binding(2)] occluderTexture: sampler2D[f32]
|
||||
}
|
||||
|
||||
struct FragIn
|
||||
{
|
||||
[location(0)] uv: vec2[f32]
|
||||
}
|
||||
|
||||
struct FragOut
|
||||
{
|
||||
[location(0)] color: vec4[f32]
|
||||
}
|
||||
|
||||
struct VertIn
|
||||
{
|
||||
[location(0)] pos: vec2[f32],
|
||||
[location(1)] uv: vec2[f32]
|
||||
}
|
||||
|
||||
struct VertOut
|
||||
{
|
||||
[builtin(position)] position: vec4[f32],
|
||||
[location(0)] uv: vec2[f32]
|
||||
}
|
||||
|
||||
[entry(frag)]
|
||||
fn main(input: FragIn) -> FragOut
|
||||
{
|
||||
let deltaUV = input.uv - settings.lightPosition;
|
||||
deltaUV *= 1.0 / f32(SampleCount) * settings.density;
|
||||
let illuminationDecay = 1.0;
|
||||
|
||||
let uv = input.uv;
|
||||
|
||||
let outputColor = vec4[f32](0.0, 0.0, 0.0, 1.0);
|
||||
|
||||
for i in 0 -> SampleCount
|
||||
{
|
||||
uv -= deltaUV;
|
||||
let sample = occluderTexture.Sample(uv);
|
||||
|
||||
sample *= illuminationDecay * settings.weight;
|
||||
outputColor += sample;
|
||||
|
||||
illuminationDecay *= settings.decay;
|
||||
}
|
||||
|
||||
let output: FragOut;
|
||||
output.color = outputColor;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
[entry(vert)]
|
||||
fn main(input: VertIn) -> VertOut
|
||||
{
|
||||
let output: VertOut;
|
||||
output.position = vec4[f32](input.pos, 0.0, 1.0);
|
||||
output.uv = input.uv;
|
||||
|
||||
return output;
|
||||
}
|
||||
105
assets/shaders/lighting.nzsl
Normal file
105
assets/shaders/lighting.nzsl
Normal file
@@ -0,0 +1,105 @@
|
||||
[nzsl_version("1.0")]
|
||||
module;
|
||||
|
||||
import Engine.ViewerData;
|
||||
|
||||
[layout(std140)]
|
||||
struct PointLight
|
||||
{
|
||||
color: vec3[f32],
|
||||
position: vec3[f32],
|
||||
|
||||
radius: f32,
|
||||
invRadius: f32,
|
||||
}
|
||||
|
||||
[layout(std140)]
|
||||
struct SpotLight
|
||||
{
|
||||
transformMatrix: mat4[f32],
|
||||
|
||||
color: vec3[f32],
|
||||
position: vec3[f32],
|
||||
direction: vec3[f32],
|
||||
|
||||
radius: f32,
|
||||
invRadius: f32,
|
||||
|
||||
innerAngle: f32,
|
||||
outerAngle: f32
|
||||
}
|
||||
|
||||
[set(0)]
|
||||
external
|
||||
{
|
||||
[binding(0)] viewerData: uniform[ViewerData],
|
||||
[binding(1)] colorTexture: sampler2D[f32],
|
||||
[binding(2)] normalTexture: sampler2D[f32],
|
||||
[binding(3)] positionTexture: sampler2D[f32],
|
||||
}
|
||||
|
||||
[set(1)]
|
||||
external
|
||||
{
|
||||
[binding(0)] lightParameters: uniform[SpotLight],
|
||||
}
|
||||
|
||||
struct FragIn
|
||||
{
|
||||
[builtin(fragcoord)] fragcoord: vec4[f32]
|
||||
}
|
||||
|
||||
struct FragOut
|
||||
{
|
||||
[location(0)] color: vec4[f32]
|
||||
}
|
||||
|
||||
struct VertIn
|
||||
{
|
||||
[location(0)] pos: vec3[f32]
|
||||
}
|
||||
|
||||
struct VertOut
|
||||
{
|
||||
[builtin(position)] position: vec4[f32]
|
||||
}
|
||||
|
||||
[entry(frag)]
|
||||
fn main(input: FragIn) -> FragOut
|
||||
{
|
||||
let fragcoord = input.fragcoord.xy * viewerData.invRenderTargetSize;
|
||||
let normal = normalTexture.Sample(fragcoord).xyz * 2.0 - vec3[f32](1.0, 1.0, 1.0);
|
||||
let position = positionTexture.Sample(fragcoord).xyz;
|
||||
|
||||
let attenuation = compute_attenuation(position, normal);
|
||||
|
||||
let output: FragOut;
|
||||
output.color = vec4[f32](lightParameters.color, 1.0) * attenuation * colorTexture.Sample(fragcoord);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
[entry(vert)]
|
||||
fn main(input: VertIn) -> VertOut
|
||||
{
|
||||
let output: VertOut;
|
||||
output.position = viewerData.projectionMatrix * viewerData.viewMatrix * lightParameters.transformMatrix * vec4[f32](input.pos, 1.0);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
fn compute_attenuation(worldPos: vec3[f32], normal: vec3[f32]) -> f32
|
||||
{
|
||||
let distance = length(lightParameters.position - worldPos);
|
||||
|
||||
let posToLight = (lightParameters.position - worldPos) / distance;
|
||||
let lambert = dot(normal, posToLight);
|
||||
|
||||
let curAngle = dot(lightParameters.direction, -posToLight);
|
||||
let innerMinusOuterAngle = lightParameters.innerAngle - lightParameters.outerAngle;
|
||||
|
||||
let attenuation = max(1.0 - distance * lightParameters.invRadius, 0.0);
|
||||
attenuation = attenuation * lambert * max((curAngle - lightParameters.outerAngle) / innerMinusOuterAngle, 0.0);
|
||||
|
||||
return attenuation;
|
||||
}
|
||||
52
assets/shaders/skybox.nzsl
Normal file
52
assets/shaders/skybox.nzsl
Normal file
@@ -0,0 +1,52 @@
|
||||
[nzsl_version("1.0")]
|
||||
module;
|
||||
|
||||
import Engine.ViewerData;
|
||||
|
||||
external
|
||||
{
|
||||
[binding(0)] viewerData: uniform[ViewerData],
|
||||
[binding(1)] skybox: samplerCube[f32]
|
||||
}
|
||||
|
||||
struct VertOut
|
||||
{
|
||||
[location(0)] uvw: vec3[f32],
|
||||
[builtin(position)] position: vec4[f32]
|
||||
}
|
||||
|
||||
struct FragOut
|
||||
{
|
||||
[location(0)] color: vec4[f32],
|
||||
[builtin(fragdepth)] depth: 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;
|
||||
}
|
||||
|
||||
struct VertIn
|
||||
{
|
||||
[location(0)] position: vec3[f32]
|
||||
}
|
||||
|
||||
[entry(vert)]
|
||||
fn main(input: VertIn) -> VertOut
|
||||
{
|
||||
// Set translation part to zero
|
||||
let rotationMat = viewerData.viewMatrix;
|
||||
rotationMat[3].xyz = vec3[f32](0.0, 0.0, 0.0);
|
||||
|
||||
let output: VertOut;
|
||||
output.position = viewerData.projectionMatrix * rotationMat * vec4[f32](input.position, 1.0);
|
||||
output.uvw = input.position.xyz;
|
||||
|
||||
return output;
|
||||
}
|
||||
58
assets/shaders/tone_mapping.nzsl
Normal file
58
assets/shaders/tone_mapping.nzsl
Normal file
@@ -0,0 +1,58 @@
|
||||
[nzsl_version("1.0")]
|
||||
module;
|
||||
|
||||
import Engine.ViewerData;
|
||||
|
||||
external
|
||||
{
|
||||
[set(0), binding(0)] viewerData: uniform[ViewerData],
|
||||
[set(0), binding(1)] inputTexture: sampler2D[f32]
|
||||
}
|
||||
|
||||
struct FragIn
|
||||
{
|
||||
[location(0)] uv: vec2[f32],
|
||||
}
|
||||
|
||||
struct FragOut
|
||||
{
|
||||
[location(0)] color: vec4[f32]
|
||||
}
|
||||
|
||||
struct VertIn
|
||||
{
|
||||
[location(0)] pos: vec2[f32],
|
||||
[location(1)] uv: vec2[f32],
|
||||
}
|
||||
|
||||
struct VertOut
|
||||
{
|
||||
[location(0)] uv: vec2[f32],
|
||||
[builtin(position)] position: vec4[f32]
|
||||
}
|
||||
|
||||
[entry(frag)]
|
||||
fn main(input: FragIn) -> FragOut
|
||||
{
|
||||
let exposure = 0.8;
|
||||
|
||||
let hdrColor = inputTexture.Sample(input.uv).rgb;
|
||||
|
||||
// reinhard tone mapping
|
||||
let mapped = vec3[f32](1.0, 1.0, 1.0) - exp(-hdrColor * exposure);
|
||||
|
||||
let output: FragOut;
|
||||
output.color = vec4[f32](mapped, 1.0);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
[entry(vert)]
|
||||
fn main(input: VertIn) -> VertOut
|
||||
{
|
||||
let output: VertOut;
|
||||
output.position = vec4[f32](input.pos, 0.0, 1.0);
|
||||
output.uv = input.uv;
|
||||
|
||||
return output;
|
||||
}
|
||||
Reference in New Issue
Block a user