Handle shader options of any type

This commit is contained in:
Jérôme Leclercq
2021-09-03 19:33:41 +02:00
parent 2f9e495739
commit 02a12d9328
38 changed files with 236 additions and 1118 deletions

View File

@@ -1,6 +1,6 @@
option HAS_DIFFUSE_TEXTURE: bool;
option HAS_ALPHA_TEXTURE: bool;
option ALPHA_TEST: bool;
option HasDiffuseTexture: bool = false;
option HasAlphaTexture: bool = false;
option AlphaTest: bool = false;
[layout(std140)]
struct BasicSettings
@@ -57,15 +57,15 @@ struct OutputData
fn main(input: InputData) -> OutputData
{
let diffuseColor = settings.DiffuseColor;
const if (HAS_DIFFUSE_TEXTURE)
const if (HasDiffuseTexture)
// TODO: diffuseColor *= MaterialDiffuseMap.Sample(input.uv)
diffuseColor = diffuseColor * MaterialDiffuseMap.Sample(input.uv);
const if (HAS_ALPHA_TEXTURE)
const if (HasAlphaTexture)
// TODO: diffuseColor.w *= MaterialAlphaMap.Sample(input.uv)).x
diffuseColor = vec4<f32>(diffuseColor.x, diffuseColor.y, diffuseColor.z, (MaterialAlphaMap.Sample(input.uv)).x * diffuseColor.w);
const if (ALPHA_TEST)
const if (AlphaTest)
{
if (diffuseColor.w < settings.AlphaThreshold)
discard;