Refactor material system (#382)
This commit is contained in:
@@ -5,6 +5,10 @@ import InstanceData from Engine.InstanceData;
|
||||
import SkeletalData from Engine.SkeletalData;
|
||||
import ViewerData from Engine.ViewerData;
|
||||
|
||||
// Pass-specific options
|
||||
option DepthPass: bool = false;
|
||||
|
||||
// Material options
|
||||
option HasBaseColorTexture: bool = false;
|
||||
option HasAlphaTexture: bool = false;
|
||||
option AlphaTest: bool = false;
|
||||
@@ -16,34 +20,43 @@ option BillboardColorLocation: i32 = -1;
|
||||
option BillboardSizeRotLocation: i32 = -1;
|
||||
|
||||
// Vertex declaration related options
|
||||
option ColorLocation: i32 = -1;
|
||||
option PosLocation: i32;
|
||||
option UvLocation: i32 = -1;
|
||||
option VertexColorLoc: i32 = -1;
|
||||
option VertexPositionLoc: i32;
|
||||
option VertexUvLoc: i32 = -1;
|
||||
|
||||
option JointIndicesLocation: i32 = -1;
|
||||
option JointWeightsLocation: i32 = -1;
|
||||
option VertexJointIndicesLoc: i32 = -1;
|
||||
option VertexJointWeightsLoc: i32 = -1;
|
||||
|
||||
const HasVertexColor = (ColorLocation >= 0);
|
||||
const HasVertexColor = (VertexColorLoc >= 0);
|
||||
const HasColor = (HasVertexColor || Billboard);
|
||||
const HasUV = (UvLocation >= 0);
|
||||
const HasSkinning = (JointIndicesLocation >= 0 && JointWeightsLocation >= 0);
|
||||
const HasUV = (VertexUvLoc >= 0);
|
||||
const HasSkinning = (VertexJointIndicesLoc >= 0 && VertexJointWeightsLoc >= 0);
|
||||
|
||||
[layout(std140)]
|
||||
struct MaterialSettings
|
||||
{
|
||||
[tag("AlphaTestThreshold")]
|
||||
AlphaThreshold: f32,
|
||||
|
||||
[tag("BaseColor")]
|
||||
BaseColor: vec4[f32]
|
||||
}
|
||||
|
||||
[tag("Material")]
|
||||
external
|
||||
{
|
||||
[binding(0)] settings: uniform[MaterialSettings],
|
||||
[binding(1)] MaterialBaseColorMap: sampler2D[f32],
|
||||
[binding(2)] MaterialAlphaMap: sampler2D[f32],
|
||||
[binding(3)] TextureOverlay: sampler2D[f32],
|
||||
[binding(4)] instanceData: uniform[InstanceData],
|
||||
[binding(5)] viewerData: uniform[ViewerData],
|
||||
[binding(6)] skeletalData: uniform[SkeletalData]
|
||||
[tag("Settings"), binding(0)] settings: uniform[MaterialSettings],
|
||||
[tag("BaseColorMap"), binding(1)] MaterialBaseColorMap: sampler2D[f32],
|
||||
[tag("AlphaMap"), binding(2)] MaterialAlphaMap: sampler2D[f32],
|
||||
}
|
||||
|
||||
[tag("Engine")]
|
||||
external
|
||||
{
|
||||
[tag("TextureOverlay"), binding(3)] TextureOverlay: sampler2D[f32],
|
||||
[tag("InstanceData"), binding(4)] instanceData: uniform[InstanceData],
|
||||
[tag("ViewerData"), binding(5)] viewerData: uniform[ViewerData],
|
||||
[tag("SkeletalData"), binding(6)] skeletalData: uniform[SkeletalData]
|
||||
}
|
||||
|
||||
// Fragment stage
|
||||
@@ -58,7 +71,7 @@ struct FragOut
|
||||
[location(0)] RenderTarget0: vec4[f32]
|
||||
}
|
||||
|
||||
[entry(frag)]
|
||||
[entry(frag), cond(!DepthPass || AlphaTest)]
|
||||
fn main(input: FragIn) -> FragOut
|
||||
{
|
||||
let color = settings.BaseColor;
|
||||
@@ -86,22 +99,26 @@ fn main(input: FragIn) -> FragOut
|
||||
return output;
|
||||
}
|
||||
|
||||
// Dummy fragment shader (TODO: Add a way to delete stage?)
|
||||
[entry(frag), cond(DepthPass && !AlphaTest)]
|
||||
fn main() {}
|
||||
|
||||
// Vertex stage
|
||||
struct VertIn
|
||||
{
|
||||
[location(PosLocation)]
|
||||
[location(VertexPositionLoc)]
|
||||
pos: vec3[f32],
|
||||
|
||||
[cond(HasVertexColor), location(ColorLocation)]
|
||||
[cond(HasVertexColor), location(VertexColorLoc)]
|
||||
color: vec4[f32],
|
||||
|
||||
[cond(HasUV), location(UvLocation)]
|
||||
[cond(HasUV), location(VertexUvLoc)]
|
||||
uv: vec2[f32],
|
||||
|
||||
[cond(HasSkinning), location(JointIndicesLocation)]
|
||||
[cond(HasSkinning), location(VertexJointIndicesLoc)]
|
||||
jointIndices: vec4[i32],
|
||||
|
||||
[cond(HasSkinning), location(JointWeightsLocation)]
|
||||
[cond(HasSkinning), location(VertexJointWeightsLoc)]
|
||||
jointWeights: vec4[f32],
|
||||
|
||||
[cond(Billboard), location(BillboardCenterLocation)]
|
||||
|
||||
@@ -1,117 +0,0 @@
|
||||
[nzsl_version("1.0")]
|
||||
module DepthMaterial;
|
||||
|
||||
import InstanceData from Engine.InstanceData;
|
||||
import SkeletalData from Engine.SkeletalData;
|
||||
import ViewerData from Engine.ViewerData;
|
||||
|
||||
option HasBaseColorTexture: bool = false;
|
||||
option HasAlphaTexture: bool = false;
|
||||
option AlphaTest: bool = false;
|
||||
|
||||
option PosLocation: i32;
|
||||
option UvLocation: i32 = -1;
|
||||
option JointIndicesLocation: i32 = -1;
|
||||
option JointWeightsLocation: i32 = -1;
|
||||
|
||||
const HasUV = AlphaTest && (HasBaseColorTexture || HasAlphaTexture);
|
||||
const HasSkinning = (JointIndicesLocation >= 0 && JointWeightsLocation >= 0);
|
||||
|
||||
[layout(std140)]
|
||||
struct BasicSettings
|
||||
{
|
||||
AlphaThreshold: f32,
|
||||
BaseColor: vec4[f32]
|
||||
}
|
||||
|
||||
external
|
||||
{
|
||||
[binding(0)] settings: uniform[BasicSettings],
|
||||
[binding(1)] MaterialBaseColorMap: sampler2D[f32],
|
||||
[binding(2)] MaterialAlphaMap: sampler2D[f32],
|
||||
[binding(3)] TextureOverlay: sampler2D[f32],
|
||||
[binding(4)] instanceData: uniform[InstanceData],
|
||||
[binding(5)] viewerData: uniform[ViewerData],
|
||||
[binding(6)] skeletalData: uniform[SkeletalData]
|
||||
}
|
||||
|
||||
// Fragment stage
|
||||
struct FragIn
|
||||
{
|
||||
[location(0), cond(HasUV)] uv: vec2[f32]
|
||||
}
|
||||
|
||||
[entry(frag), cond(AlphaTest)]
|
||||
fn main(input: FragIn)
|
||||
{
|
||||
let alpha = settings.BaseColor.a;
|
||||
|
||||
const if (HasUV)
|
||||
alpha *= TextureOverlay.Sample(input.uv).a;
|
||||
|
||||
const if (HasBaseColorTexture)
|
||||
alpha *= MaterialBaseColorMap.Sample(input.uv).a;
|
||||
|
||||
const if (HasAlphaTexture)
|
||||
alpha *= MaterialAlphaMap.Sample(input.uv).x;
|
||||
|
||||
if (alpha < settings.AlphaThreshold)
|
||||
discard;
|
||||
}
|
||||
|
||||
// Dummy fragment shader (TODO: Add a way to delete stage?)
|
||||
[entry(frag), cond(!AlphaTest)]
|
||||
fn main() {}
|
||||
|
||||
// Vertex stage
|
||||
struct VertIn
|
||||
{
|
||||
[location(PosLocation)] pos: vec3[f32],
|
||||
|
||||
[cond(HasUV), location(UvLocation)]
|
||||
uv: vec2[f32],
|
||||
|
||||
[cond(HasSkinning), location(JointIndicesLocation)]
|
||||
jointIndices: vec4[i32],
|
||||
|
||||
[cond(HasSkinning), location(JointWeightsLocation)]
|
||||
jointWeights: vec4[f32],
|
||||
}
|
||||
|
||||
struct VertOut
|
||||
{
|
||||
[location(0), cond(HasUV)] uv: vec2[f32],
|
||||
[builtin(position)] position: vec4[f32]
|
||||
}
|
||||
|
||||
[entry(vert)]
|
||||
fn main(input: VertIn) -> VertOut
|
||||
{
|
||||
let pos: vec3[f32];
|
||||
const if (HasSkinning)
|
||||
{
|
||||
pos = vec3[f32](0.0, 0.0, 0.0);
|
||||
|
||||
[unroll]
|
||||
for i in 0 -> 4
|
||||
{
|
||||
let jointIndex = input.jointIndices[i];
|
||||
let jointWeight = input.jointWeights[i];
|
||||
|
||||
let jointMatrix = skeletalData.JointMatrices[jointIndex];
|
||||
pos += (jointMatrix * vec4[f32](input.pos, 1.0)).xyz * jointWeight;
|
||||
}
|
||||
}
|
||||
else
|
||||
pos = input.pos;
|
||||
|
||||
let worldPosition = instanceData.worldMatrix * vec4[f32](pos, 1.0);
|
||||
|
||||
let output: VertOut;
|
||||
output.position = viewerData.viewProjMatrix * worldPosition;
|
||||
|
||||
const if (HasUV)
|
||||
output.uv = input.uv;
|
||||
|
||||
return output;
|
||||
}
|
||||
@@ -6,6 +6,9 @@ import LightData from Engine.LightData;
|
||||
import SkeletalData from Engine.SkeletalData;
|
||||
import ViewerData from Engine.ViewerData;
|
||||
|
||||
// Pass-specific options
|
||||
option DepthPass: bool = false;
|
||||
|
||||
// Basic material options
|
||||
option HasBaseColorTexture: bool = false;
|
||||
option HasAlphaTexture: bool = false;
|
||||
@@ -24,30 +27,39 @@ option BillboardColorLocation: i32 = -1;
|
||||
option BillboardSizeRotLocation: i32 = -1;
|
||||
|
||||
// Vertex declaration related options
|
||||
option ColorLocation: i32 = -1;
|
||||
option NormalLocation: i32 = -1;
|
||||
option PosLocation: i32;
|
||||
option TangentLocation: i32 = -1;
|
||||
option UvLocation: i32 = -1;
|
||||
option VertexColorLoc: i32 = -1;
|
||||
option VertexNormalLoc: i32 = -1;
|
||||
option VertexPositionLoc: i32;
|
||||
option VertexTangentLoc: i32 = -1;
|
||||
option VertexUvLoc: i32 = -1;
|
||||
|
||||
const HasNormal = (NormalLocation >= 0);
|
||||
const HasVertexColor = (ColorLocation >= 0);
|
||||
const HasNormal = (VertexNormalLoc >= 0);
|
||||
const HasVertexColor = (VertexColorLoc >= 0);
|
||||
const HasColor = (HasVertexColor || Billboard);
|
||||
const HasTangent = (TangentLocation >= 0);
|
||||
const HasUV = (UvLocation >= 0);
|
||||
const HasNormalMapping = HasNormalTexture && HasNormal && HasTangent;
|
||||
const HasTangent = (VertexTangentLoc >= 0);
|
||||
const HasUV = (VertexUvLoc >= 0);
|
||||
const HasNormalMapping = HasNormalTexture && HasNormal && HasTangent && !DepthPass;
|
||||
|
||||
|
||||
[layout(std140)]
|
||||
struct MaterialSettings
|
||||
{
|
||||
// BasicSettings
|
||||
// Basic settings
|
||||
[tag("AlphaTestThreshold")]
|
||||
AlphaThreshold: f32,
|
||||
|
||||
[tag("BaseColor")]
|
||||
BaseColor: vec4[f32],
|
||||
|
||||
// PhongSettings
|
||||
AmbientColor: vec3[f32],
|
||||
SpecularColor: vec3[f32],
|
||||
Shininess: f32,
|
||||
// Phong settings
|
||||
[tag("AmbientColor")]
|
||||
AmbientColor: vec4[f32], //< TODO: Switch to vec3[f32]
|
||||
|
||||
[tag("SpecularColor")]
|
||||
SpecularColor: vec4[f32], //< TODO: Switch to vec3[f32
|
||||
|
||||
[tag("Shininess")]
|
||||
Shininess: f32
|
||||
}
|
||||
|
||||
// TODO: Add enums
|
||||
@@ -55,20 +67,26 @@ const DirectionalLight = 0;
|
||||
const PointLight = 1;
|
||||
const SpotLight = 2;
|
||||
|
||||
[tag("Material")]
|
||||
external
|
||||
{
|
||||
[binding(0)] settings: uniform[MaterialSettings],
|
||||
[binding(1)] MaterialBaseColorMap: sampler2D[f32],
|
||||
[binding(2)] MaterialAlphaMap: sampler2D[f32],
|
||||
[binding(3)] TextureOverlay: sampler2D[f32],
|
||||
[binding(4)] instanceData: uniform[InstanceData],
|
||||
[binding(5)] viewerData: uniform[ViewerData],
|
||||
[binding(6)] skeletalData: uniform[SkeletalData],
|
||||
[binding(7)] lightData: uniform[LightData],
|
||||
[binding(8)] MaterialEmissiveMap: sampler2D[f32],
|
||||
[binding(9)] MaterialHeightMap: sampler2D[f32],
|
||||
[binding(10)] MaterialNormalMap: sampler2D[f32],
|
||||
[binding(11)] MaterialSpecularMap: sampler2D[f32],
|
||||
[tag("Settings"), binding(0)] settings: uniform[MaterialSettings],
|
||||
[tag("BaseColorMap"), binding(1)] MaterialBaseColorMap: sampler2D[f32],
|
||||
[tag("AlphaMap"), binding(2)] MaterialAlphaMap: sampler2D[f32],
|
||||
[tag("EmissiveMap"), binding(3)] MaterialEmissiveMap: sampler2D[f32],
|
||||
[tag("HeightMap"), binding(4)] MaterialHeightMap: sampler2D[f32],
|
||||
[tag("NormalMap"), binding(5)] MaterialNormalMap: sampler2D[f32],
|
||||
[tag("SpecularMap"), binding(6)] MaterialSpecularMap: sampler2D[f32],
|
||||
}
|
||||
|
||||
[tag("Engine")]
|
||||
external
|
||||
{
|
||||
[tag("TextureOverlay"), binding(7)] TextureOverlay: sampler2D[f32],
|
||||
[tag("InstanceData"), binding(8)] instanceData: uniform[InstanceData],
|
||||
[tag("ViewerData"), binding(9)] viewerData: uniform[ViewerData],
|
||||
[tag("SkeletalData"), binding(10)] skeletalData: uniform[SkeletalData],
|
||||
[tag("LightData"), binding(11)] lightData: uniform[LightData]
|
||||
}
|
||||
|
||||
struct VertToFrag
|
||||
@@ -87,7 +105,7 @@ struct FragOut
|
||||
[location(0)] RenderTarget0: vec4[f32]
|
||||
}
|
||||
|
||||
[entry(frag)]
|
||||
[entry(frag), cond(!DepthPass || AlphaTest)]
|
||||
fn main(input: VertToFrag) -> FragOut
|
||||
{
|
||||
let color = settings.BaseColor;
|
||||
@@ -110,7 +128,7 @@ fn main(input: VertToFrag) -> FragOut
|
||||
discard;
|
||||
}
|
||||
|
||||
const if (HasNormal)
|
||||
const if (HasNormal && !DepthPass)
|
||||
{
|
||||
let lightAmbient = vec3[f32](0.0, 0.0, 0.0);
|
||||
let lightDiffuse = vec3[f32](0.0, 0.0, 0.0);
|
||||
@@ -143,7 +161,7 @@ fn main(input: VertToFrag) -> FragOut
|
||||
{
|
||||
let lightDir = light.parameter1.xyz;
|
||||
|
||||
lightAmbient += light.color.rgb * lightAmbientFactor * settings.AmbientColor;
|
||||
lightAmbient += light.color.rgb * lightAmbientFactor * settings.AmbientColor.rgb;
|
||||
|
||||
let lambert = max(dot(normal, -lightDir), 0.0);
|
||||
|
||||
@@ -166,7 +184,7 @@ fn main(input: VertToFrag) -> FragOut
|
||||
|
||||
let attenuationFactor = max(1.0 - dist * lightInvRadius, 0.0);
|
||||
|
||||
lightAmbient += attenuationFactor * light.color.rgb * lightAmbientFactor * settings.AmbientColor;
|
||||
lightAmbient += attenuationFactor * light.color.rgb * lightAmbientFactor * settings.AmbientColor.rgb;
|
||||
|
||||
let lambert = max(dot(normal, -lightToPosNorm), 0.0);
|
||||
|
||||
@@ -196,7 +214,7 @@ fn main(input: VertToFrag) -> FragOut
|
||||
let attenuationFactor = max(1.0 - dist * lightInvRadius, 0.0);
|
||||
attenuationFactor *= max((curAngle - lightOuterAngle) / innerMinusOuterAngle, 0.0);
|
||||
|
||||
lightAmbient += attenuationFactor * light.color.rgb * lightAmbientFactor * settings.AmbientColor;
|
||||
lightAmbient += attenuationFactor * light.color.rgb * lightAmbientFactor * settings.AmbientColor.rgb;
|
||||
|
||||
let lambert = max(dot(normal, -lightToPosNorm), 0.0);
|
||||
|
||||
@@ -210,7 +228,7 @@ fn main(input: VertToFrag) -> FragOut
|
||||
}
|
||||
}
|
||||
|
||||
lightSpecular *= settings.SpecularColor;
|
||||
lightSpecular *= settings.SpecularColor.rgb;
|
||||
|
||||
const if (HasSpecularTexture)
|
||||
lightSpecular *= MaterialSpecularMap.Sample(input.uv).rgb;
|
||||
@@ -229,22 +247,27 @@ fn main(input: VertToFrag) -> FragOut
|
||||
}
|
||||
}
|
||||
|
||||
// Dummy fragment shader (TODO: Add a way to delete stage?)
|
||||
[entry(frag), cond(DepthPass && !AlphaTest)]
|
||||
fn main() {}
|
||||
|
||||
|
||||
// Vertex stage
|
||||
struct VertIn
|
||||
{
|
||||
[location(PosLocation)]
|
||||
[location(VertexPositionLoc)]
|
||||
pos: vec3[f32],
|
||||
|
||||
[cond(HasVertexColor), location(ColorLocation)]
|
||||
[cond(HasVertexColor), location(VertexColorLoc)]
|
||||
color: vec4[f32],
|
||||
|
||||
[cond(HasUV), location(UvLocation)]
|
||||
[cond(HasUV), location(VertexUvLoc)]
|
||||
uv: vec2[f32],
|
||||
|
||||
[cond(HasNormal), location(NormalLocation)]
|
||||
[cond(HasNormal), location(VertexNormalLoc)]
|
||||
normal: vec3[f32],
|
||||
|
||||
[cond(HasTangent), location(TangentLocation)]
|
||||
[cond(HasTangent), location(VertexTangentLoc)]
|
||||
tangent: vec3[f32],
|
||||
|
||||
[cond(Billboard), location(BillboardCenterLocation)]
|
||||
|
||||
@@ -6,6 +6,9 @@ import LightData from Engine.LightData;
|
||||
import SkeletalData from Engine.SkeletalData;
|
||||
import ViewerData from Engine.ViewerData;
|
||||
|
||||
// Pass-specific options
|
||||
option DepthPass: bool = false;
|
||||
|
||||
// Basic material options
|
||||
option HasBaseColorTexture: bool = false;
|
||||
option HasAlphaTexture: bool = false;
|
||||
@@ -26,30 +29,28 @@ option BillboardColorLocation: i32 = -1;
|
||||
option BillboardSizeRotLocation: i32 = -1;
|
||||
|
||||
// Vertex declaration related options
|
||||
option ColorLocation: i32 = -1;
|
||||
option NormalLocation: i32 = -1;
|
||||
option PosLocation: i32;
|
||||
option TangentLocation: i32 = -1;
|
||||
option UvLocation: i32 = -1;
|
||||
option VertexColorLoc: i32 = -1;
|
||||
option VertexNormalLoc: i32 = -1;
|
||||
option VertexPositionLoc: i32;
|
||||
option VertexTangentLoc: i32 = -1;
|
||||
option VertexUvLoc: i32 = -1;
|
||||
|
||||
const HasNormal = (NormalLocation >= 0);
|
||||
const HasVertexColor = (ColorLocation >= 0);
|
||||
const HasNormal = (VertexNormalLoc >= 0);
|
||||
const HasVertexColor = (VertexColorLoc >= 0);
|
||||
const HasColor = (HasVertexColor || Billboard);
|
||||
const HasTangent = (TangentLocation >= 0);
|
||||
const HasUV = (UvLocation >= 0);
|
||||
const HasNormalMapping = HasNormalTexture && HasNormal && HasTangent;
|
||||
const HasTangent = (VertexTangentLoc >= 0);
|
||||
const HasUV = (VertexUvLoc >= 0);
|
||||
const HasNormalMapping = HasNormalTexture && HasNormal && HasTangent && !DepthPass;
|
||||
|
||||
[layout(std140)]
|
||||
struct MaterialSettings
|
||||
{
|
||||
// BasicSettings
|
||||
// Basic settings
|
||||
[tag("AlphaTestThreshold")]
|
||||
AlphaThreshold: f32,
|
||||
BaseColor: vec4[f32],
|
||||
|
||||
// PhongSettings
|
||||
AmbientColor: vec3[f32],
|
||||
SpecularColor: vec3[f32],
|
||||
Shininess: f32,
|
||||
[tag("BaseColor")]
|
||||
BaseColor: vec4[f32],
|
||||
}
|
||||
|
||||
// TODO: Add enums
|
||||
@@ -57,22 +58,28 @@ const DirectionalLight = 0;
|
||||
const PointLight = 1;
|
||||
const SpotLight = 2;
|
||||
|
||||
[tag("Material")]
|
||||
external
|
||||
{
|
||||
[binding(0)] settings: uniform[MaterialSettings],
|
||||
[binding(1)] MaterialBaseColorMap: sampler2D[f32],
|
||||
[binding(2)] MaterialAlphaMap: sampler2D[f32],
|
||||
[binding(3)] TextureOverlay: sampler2D[f32],
|
||||
[binding(4)] instanceData: uniform[InstanceData],
|
||||
[binding(5)] viewerData: uniform[ViewerData],
|
||||
[binding(6)] skeletalData: uniform[SkeletalData],
|
||||
[binding(7)] lightData: uniform[LightData],
|
||||
[binding(8)] MaterialEmissiveMap: sampler2D[f32],
|
||||
[binding(9)] MaterialHeightMap: sampler2D[f32],
|
||||
[binding(10)] MaterialMetallicMap: sampler2D[f32],
|
||||
[binding(11)] MaterialNormalMap: sampler2D[f32],
|
||||
[binding(12)] MaterialRoughnessMap: sampler2D[f32],
|
||||
[binding(13)] MaterialSpecularMap: sampler2D[f32],
|
||||
[tag("Settings"), binding(0)] settings: uniform[MaterialSettings],
|
||||
[tag("BaseColorMap"), binding(1)] MaterialBaseColorMap: sampler2D[f32],
|
||||
[tag("AlphaMap"), binding(2)] MaterialAlphaMap: sampler2D[f32],
|
||||
[tag("EmissiveMap"), binding(3)] MaterialEmissiveMap: sampler2D[f32],
|
||||
[tag("HeightMap"), binding(4)] MaterialHeightMap: sampler2D[f32],
|
||||
[tag("MetallicMap"), binding(5)] MaterialMetallicMap: sampler2D[f32],
|
||||
[tag("NormalMap"), binding(6)] MaterialNormalMap: sampler2D[f32],
|
||||
[tag("RoughnessMap"), binding(7)] MaterialRoughnessMap: sampler2D[f32],
|
||||
[tag("SpecularMap"), binding(8)] MaterialSpecularMap: sampler2D[f32],
|
||||
}
|
||||
|
||||
[tag("Engine")]
|
||||
external
|
||||
{
|
||||
[tag("TextureOverlay"), binding(9)] TextureOverlay: sampler2D[f32],
|
||||
[tag("InstanceData"), binding(10)] instanceData: uniform[InstanceData],
|
||||
[tag("ViewerData"), binding(11)] viewerData: uniform[ViewerData],
|
||||
[tag("SkeletalData"), binding(12)] skeletalData: uniform[SkeletalData],
|
||||
[tag("LightData"), binding(13)] lightData: uniform[LightData]
|
||||
}
|
||||
|
||||
struct VertToFrag
|
||||
@@ -94,7 +101,7 @@ struct FragOut
|
||||
[location(0)] RenderTarget0: vec4[f32]
|
||||
}
|
||||
|
||||
[entry(frag)]
|
||||
[entry(frag), cond(!DepthPass || AlphaTest)]
|
||||
fn main(input: VertToFrag) -> FragOut
|
||||
{
|
||||
let color = settings.BaseColor;
|
||||
@@ -117,7 +124,7 @@ fn main(input: VertToFrag) -> FragOut
|
||||
discard;
|
||||
}
|
||||
|
||||
const if (HasNormal)
|
||||
const if (HasNormal && !DepthPass)
|
||||
{
|
||||
let lightRadiance = vec3[f32](0.0, 0.0, 0.0);
|
||||
|
||||
@@ -229,22 +236,26 @@ fn main(input: VertToFrag) -> FragOut
|
||||
}
|
||||
}
|
||||
|
||||
// Dummy fragment shader (TODO: Add a way to delete stage?)
|
||||
[entry(frag), cond(DepthPass && !AlphaTest)]
|
||||
fn main() {}
|
||||
|
||||
// Vertex stage
|
||||
struct VertIn
|
||||
{
|
||||
[location(PosLocation)]
|
||||
[location(VertexPositionLoc)]
|
||||
pos: vec3[f32],
|
||||
|
||||
[cond(HasVertexColor), location(ColorLocation)]
|
||||
[cond(HasVertexColor), location(VertexColorLoc)]
|
||||
color: vec4[f32],
|
||||
|
||||
[cond(HasUV), location(UvLocation)]
|
||||
[cond(HasUV), location(VertexUvLoc)]
|
||||
uv: vec2[f32],
|
||||
|
||||
[cond(HasNormal), location(NormalLocation)]
|
||||
[cond(HasNormal), location(VertexNormalLoc)]
|
||||
normal: vec3[f32],
|
||||
|
||||
[cond(HasTangent), location(TangentLocation)]
|
||||
[cond(HasTangent), location(VertexTangentLoc)]
|
||||
tangent: vec3[f32],
|
||||
|
||||
[cond(Billboard), location(BillboardCenterLocation)]
|
||||
|
||||
Reference in New Issue
Block a user