Add missing resources and update .gitignore
This commit is contained in:
parent
ccccbfe0ad
commit
c963a3064b
|
|
@ -1,5 +1,6 @@
|
|||
# xmake-related files
|
||||
.xmake/*
|
||||
.vs/*
|
||||
.vscode/*
|
||||
CMakeLists.txt
|
||||
Makefile
|
||||
|
|
@ -8,6 +9,7 @@ vsxmake*/*
|
|||
|
||||
# Nazara binaries
|
||||
bin/*
|
||||
!bin/resources/*
|
||||
|
||||
# Build files
|
||||
build/*
|
||||
|
|
|
|||
|
|
@ -0,0 +1,73 @@
|
|||
option HAS_DIFFUSE_TEXTURE: bool;
|
||||
option HAS_ALPHA_TEXTURE: bool;
|
||||
option ALPHA_TEST: bool;
|
||||
|
||||
[layout(std140)]
|
||||
struct BasicSettings
|
||||
{
|
||||
AlphaThreshold: f32,
|
||||
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(5)] viewerData: uniform<ViewerData>,
|
||||
[binding(4)] instanceData: uniform<InstanceData>,
|
||||
[binding(3)] settings: uniform<BasicSettings>,
|
||||
[binding(0)] MaterialAlphaMap: sampler2D<f32>,
|
||||
[binding(1)] MaterialDiffuseMap: sampler2D<f32>,
|
||||
[binding(2)] TextureOverlay: sampler2D<f32>
|
||||
}
|
||||
|
||||
struct InputData
|
||||
{
|
||||
[location(0)] vertNormal: vec3<f32>,
|
||||
[location(1)] vertUV: vec2<f32>,
|
||||
[location(2)] vertPos: 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 output: OutputData;
|
||||
|
||||
let textureColor = select_opt(HAS_DIFFUSE_TEXTURE, MaterialDiffuseMap.Sample(input.vertUV) * settings.DiffuseColor, settings.DiffuseColor);
|
||||
let alpha = select_opt(HAS_ALPHA_TEXTURE, MaterialAlphaMap.Sample(input.vertUV).x * textureColor.w, 1.0);
|
||||
/*if ((select_opt(ALPHA_TEST, var0.w < settings.AlphaThreshold, false)) == (true))
|
||||
{
|
||||
discard;
|
||||
}*/
|
||||
|
||||
output.diffuseMap = textureColor;
|
||||
output.normalMap = vec4<f32>((vec3<f32>(1.0, 1.0, 1.0) + input.vertNormal) * 0.5, 1.0);
|
||||
output.positionMap = vec4<f32>(input.vertPos, 1.0);
|
||||
return output;
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
[layout(std140)]
|
||||
struct BasicSettings
|
||||
{
|
||||
AlphaThreshold: f32,
|
||||
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(5)] viewerData: uniform<ViewerData>,
|
||||
[binding(4)] instanceData: uniform<InstanceData>,
|
||||
[binding(3)] settings: uniform<BasicSettings>
|
||||
}
|
||||
|
||||
struct InputData
|
||||
{
|
||||
[location(0)] inPos: vec3<f32>,
|
||||
[location(1)] inNormals: vec3<f32>,
|
||||
[location(2)] inTexCoord: vec2<f32>
|
||||
}
|
||||
|
||||
struct OutputData
|
||||
{
|
||||
[location(0)] vertNormal: vec3<f32>,
|
||||
[location(1)] vertUV: vec2<f32>,
|
||||
[location(2)] vertPos: vec3<f32>,
|
||||
[builtin(position)] position: vec4<f32>
|
||||
}
|
||||
|
||||
[entry(vert)]
|
||||
fn main(input: InputData) -> OutputData
|
||||
{
|
||||
let worldPos = instanceData.worldMatrix * vec4<f32>(input.inPos, 1.0);
|
||||
|
||||
let output: OutputData;
|
||||
output.vertUV = input.inTexCoord;
|
||||
output.vertNormal = input.inNormals;
|
||||
output.vertPos = worldPos.xyz;
|
||||
output.position = viewerData.projectionMatrix * viewerData.viewMatrix * instanceData.worldMatrix * vec4<f32>(input.inPos, 1.0);
|
||||
return output;
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,35 @@
|
|||
[layout(std140)]
|
||||
struct PointLight
|
||||
{
|
||||
color: vec3<f32>,
|
||||
position: vec3<f32>,
|
||||
|
||||
constant: f32,
|
||||
linear: f32,
|
||||
quadratic: f32,
|
||||
}
|
||||
|
||||
external
|
||||
{
|
||||
[binding(0)] colorTexture: sampler2D<f32>,
|
||||
[binding(1)] normalTexture: sampler2D<f32>,
|
||||
[binding(2)] positionTexture: sampler2D<f32>,
|
||||
[binding(3)] lightParameters: uniform<PointLight>
|
||||
}
|
||||
|
||||
[entry(frag)]
|
||||
fn main(input: VertOut) -> FragOut
|
||||
{
|
||||
let normal = normalTexture.Sample(input.uv).xyz * 2.0 - vec3<f32>(1.0, 1.0, 1.0);
|
||||
let position = positionTexture.Sample(input.uv).xyz;
|
||||
|
||||
let distance = length(lightParameters.position - position);
|
||||
let lightDir = (lightParameters.position - position) / distance;
|
||||
let lightFactor = dot(normal, lightDir);
|
||||
let attenuation = 1.0 / (lightParameters.constant + lightParameters.linear * distance + lightParameters.quadratic * (distance * distance));
|
||||
|
||||
let output: FragOut;
|
||||
output.color = vec4<f32>(lightParameters.color, 1.0) * lightFactor * attenuation * colorTexture.Sample(input.uv);
|
||||
|
||||
return output;
|
||||
}
|
||||
Loading…
Reference in New Issue