@ -47,13 +47,13 @@ class PbrMetallicRoughnessMaterialDataTest: public TestSuite::Tester {
void texturedExplicitPackedRoughnessMetallicOcclusion ( ) ;
void texturedExplicitPackedOcclusionRoughnessMetallic ( ) ;
void texturedExplicitPackedNormalRoughnessMetallic ( ) ;
void texturedSingleMatrixCoordinates ( ) ;
void texturedSingleMatrixCoordinatesLayer ( ) ;
void invalidTextures ( ) ;
void commonTransformationCoordinatesNoTextures ( ) ;
void commonTransformationCoordinatesOneTexture ( ) ;
void commonTransformationCoordinatesOneDifferentTexture ( ) ;
void commonCoordinatesImplicit ( ) ;
void noCommonTransformationCoordinates ( ) ;
void commonTransformationCoordinatesLayer NoTextures ( ) ;
void commonTransformationCoordinatesLayer OneTexture ( ) ;
void commonTransformationCoordinatesLayer OneDifferentTexture ( ) ;
void commonCoordinatesLayer Implicit ( ) ;
void noCommonTransformationCoordinatesLayer ( ) ;
} ;
const Containers : : StringView PbrMetallicRoughnessTextureData [ ] {
@ -75,17 +75,17 @@ PbrMetallicRoughnessMaterialDataTest::PbrMetallicRoughnessMaterialDataTest() {
& PbrMetallicRoughnessMaterialDataTest : : texturedExplicitPackedRoughnessMetallicOcclusion ,
& PbrMetallicRoughnessMaterialDataTest : : texturedExplicitPackedOcclusionRoughnessMetallic ,
& PbrMetallicRoughnessMaterialDataTest : : texturedExplicitPackedNormalRoughnessMetallic ,
& PbrMetallicRoughnessMaterialDataTest : : texturedSingleMatrixCoordinates ,
& PbrMetallicRoughnessMaterialDataTest : : texturedSingleMatrixCoordinatesLayer ,
& PbrMetallicRoughnessMaterialDataTest : : invalidTextures ,
& PbrMetallicRoughnessMaterialDataTest : : commonTransformationCoordinatesNoTextures } ) ;
& PbrMetallicRoughnessMaterialDataTest : : commonTransformationCoordinatesLayer NoTextures } ) ;
addInstancedTests ( {
& PbrMetallicRoughnessMaterialDataTest : : commonTransformationCoordinatesOneTexture ,
& PbrMetallicRoughnessMaterialDataTest : : commonTransformationCoordinatesOneDifferentTexture ,
& PbrMetallicRoughnessMaterialDataTest : : commonCoordinatesImplicit } ,
& PbrMetallicRoughnessMaterialDataTest : : commonTransformationCoordinatesLayer OneTexture ,
& PbrMetallicRoughnessMaterialDataTest : : commonTransformationCoordinatesLayer OneDifferentTexture ,
& PbrMetallicRoughnessMaterialDataTest : : commonCoordinatesLayer Implicit } ,
Containers : : arraySize ( PbrMetallicRoughnessTextureData ) ) ;
addTests ( { & PbrMetallicRoughnessMaterialDataTest : : noCommonTransformationCoordinates } ) ;
addTests ( { & PbrMetallicRoughnessMaterialDataTest : : noCommonTransformationCoordinatesLayer } ) ;
}
using namespace Math : : Literals ;
@ -109,6 +109,7 @@ void PbrMetallicRoughnessMaterialDataTest::basics() {
CORRADE_VERIFY ( ! data . hasNormalRoughnessMetallicTexture ( ) ) ;
CORRADE_VERIFY ( ! data . hasTextureTransformation ( ) ) ;
CORRADE_VERIFY ( ! data . hasTextureCoordinates ( ) ) ;
CORRADE_VERIFY ( ! data . hasTextureLayer ( ) ) ;
CORRADE_COMPARE ( data . baseColor ( ) , 0xccffbbff _rgbaf ) ;
CORRADE_COMPARE ( data . metalness ( ) , 0.5f ) ;
CORRADE_COMPARE ( data . roughness ( ) , 0.79f ) ;
@ -130,6 +131,7 @@ void PbrMetallicRoughnessMaterialDataTest::defaults() {
CORRADE_VERIFY ( ! data . hasNormalRoughnessMetallicTexture ( ) ) ;
CORRADE_VERIFY ( ! data . hasTextureTransformation ( ) ) ;
CORRADE_VERIFY ( ! data . hasTextureCoordinates ( ) ) ;
CORRADE_VERIFY ( ! data . hasTextureLayer ( ) ) ;
CORRADE_COMPARE ( data . baseColor ( ) , 0xffffffff _rgbaf ) ;
CORRADE_COMPARE ( data . metalness ( ) , 1.0f ) ;
CORRADE_COMPARE ( data . roughness ( ) , 1.0f ) ;
@ -142,30 +144,36 @@ void PbrMetallicRoughnessMaterialDataTest::textured() {
{ MaterialAttribute : : BaseColorTexture , 0u } ,
{ MaterialAttribute : : BaseColorTextureMatrix , Matrix3 : : scaling ( { 0.5f , 1.0f } ) } ,
{ MaterialAttribute : : BaseColorTextureCoordinates , 2u } ,
{ MaterialAttribute : : BaseColorTextureLayer , 8u } ,
{ MaterialAttribute : : Metalness , 0.5f } ,
{ MaterialAttribute : : MetalnessTexture , 1u } ,
{ MaterialAttribute : : MetalnessTextureSwizzle , MaterialTextureSwizzle : : G } ,
{ MaterialAttribute : : MetalnessTextureMatrix , Matrix3 : : scaling ( { 0.5f , 0.5f } ) } ,
{ MaterialAttribute : : MetalnessTextureCoordinates , 3u } ,
{ MaterialAttribute : : MetalnessTextureLayer , 9u } ,
{ MaterialAttribute : : Roughness , 0.79f } ,
{ MaterialAttribute : : RoughnessTexture , 2u } ,
{ MaterialAttribute : : RoughnessTextureSwizzle , MaterialTextureSwizzle : : A } ,
{ MaterialAttribute : : RoughnessTextureMatrix , Matrix3 : : scaling ( { 1.0f , 1.0f } ) } ,
{ MaterialAttribute : : RoughnessTextureCoordinates , 4u } ,
{ MaterialAttribute : : RoughnessTextureLayer , 10u } ,
{ MaterialAttribute : : NormalTexture , 3u } ,
{ MaterialAttribute : : NormalTextureScale , 0.35f } ,
{ MaterialAttribute : : NormalTextureSwizzle , MaterialTextureSwizzle : : BA } ,
{ MaterialAttribute : : NormalTextureMatrix , Matrix3 : : scaling ( { 1.0f , 0.5f } ) } ,
{ MaterialAttribute : : NormalTextureCoordinates , 5u } ,
{ MaterialAttribute : : NormalTextureLayer , 11u } ,
{ MaterialAttribute : : OcclusionTexture , 4u } ,
{ MaterialAttribute : : OcclusionTextureStrength , 0.66f } ,
{ MaterialAttribute : : OcclusionTextureSwizzle , MaterialTextureSwizzle : : B } ,
{ MaterialAttribute : : OcclusionTextureMatrix , Matrix3 : : scaling ( { 1.0f , 0.75f } ) } ,
{ MaterialAttribute : : OcclusionTextureCoordinates , 6u } ,
{ MaterialAttribute : : OcclusionTextureLayer , 12u } ,
{ MaterialAttribute : : EmissiveColor , 0x111111 _rgbf } ,
{ MaterialAttribute : : EmissiveTexture , 5u } ,
{ MaterialAttribute : : EmissiveTextureMatrix , Matrix3 : : scaling ( { 0.75f , 0.5f } ) } ,
{ MaterialAttribute : : EmissiveTextureCoordinates , 7u }
{ MaterialAttribute : : EmissiveTextureCoordinates , 7u } ,
{ MaterialAttribute : : EmissiveTextureLayer , 13u }
} } ;
CORRADE_VERIFY ( data . hasMetalnessTexture ( ) ) ;
@ -176,34 +184,41 @@ void PbrMetallicRoughnessMaterialDataTest::textured() {
CORRADE_VERIFY ( ! data . hasNormalRoughnessMetallicTexture ( ) ) ;
CORRADE_VERIFY ( data . hasTextureTransformation ( ) ) ;
CORRADE_VERIFY ( data . hasTextureCoordinates ( ) ) ;
CORRADE_VERIFY ( data . hasTextureLayer ( ) ) ;
CORRADE_COMPARE ( data . baseColor ( ) , 0xccffbbff _rgbaf ) ;
CORRADE_COMPARE ( data . baseColorTexture ( ) , 0 ) ;
CORRADE_COMPARE ( data . baseColorTextureMatrix ( ) , Matrix3 : : scaling ( { 0.5f , 1.0f } ) ) ;
CORRADE_COMPARE ( data . baseColorTextureCoordinates ( ) , 2 ) ;
CORRADE_COMPARE ( data . baseColorTextureLayer ( ) , 8 ) ;
CORRADE_COMPARE ( data . metalness ( ) , 0.5f ) ;
CORRADE_COMPARE ( data . metalnessTexture ( ) , 1 ) ;
CORRADE_COMPARE ( data . metalnessTextureSwizzle ( ) , MaterialTextureSwizzle : : G ) ;
CORRADE_COMPARE ( data . metalnessTextureMatrix ( ) , Matrix3 : : scaling ( { 0.5f , 0.5f } ) ) ;
CORRADE_COMPARE ( data . metalnessTextureCoordinates ( ) , 3 ) ;
CORRADE_COMPARE ( data . metalnessTextureLayer ( ) , 9 ) ;
CORRADE_COMPARE ( data . roughness ( ) , 0.79f ) ;
CORRADE_COMPARE ( data . roughnessTexture ( ) , 2 ) ;
CORRADE_COMPARE ( data . roughnessTextureSwizzle ( ) , MaterialTextureSwizzle : : A ) ;
CORRADE_COMPARE ( data . roughnessTextureMatrix ( ) , Matrix3 : : scaling ( { 1.0f , 1.0f } ) ) ;
CORRADE_COMPARE ( data . roughnessTextureCoordinates ( ) , 4 ) ;
CORRADE_COMPARE ( data . roughnessTextureLayer ( ) , 10 ) ;
CORRADE_COMPARE ( data . normalTexture ( ) , 3 ) ;
CORRADE_COMPARE ( data . normalTextureScale ( ) , 0.35f ) ;
CORRADE_COMPARE ( data . normalTextureSwizzle ( ) , MaterialTextureSwizzle : : BA ) ;
CORRADE_COMPARE ( data . normalTextureMatrix ( ) , Matrix3 : : scaling ( { 1.0f , 0.5f } ) ) ;
CORRADE_COMPARE ( data . normalTextureCoordinates ( ) , 5 ) ;
CORRADE_COMPARE ( data . normalTextureLayer ( ) , 11 ) ;
CORRADE_COMPARE ( data . occlusionTexture ( ) , 4 ) ;
CORRADE_COMPARE ( data . occlusionTextureStrength ( ) , 0.66f ) ;
CORRADE_COMPARE ( data . occlusionTextureMatrix ( ) , Matrix3 : : scaling ( { 1.0f , 0.75f } ) ) ;
CORRADE_COMPARE ( data . occlusionTextureSwizzle ( ) , MaterialTextureSwizzle : : B ) ;
CORRADE_COMPARE ( data . occlusionTextureCoordinates ( ) , 6 ) ;
CORRADE_COMPARE ( data . occlusionTextureLayer ( ) , 12 ) ;
CORRADE_COMPARE ( data . emissiveColor ( ) , 0x111111 _rgbf ) ;
CORRADE_COMPARE ( data . emissiveTextureMatrix ( ) , Matrix3 : : scaling ( { 0.75f , 0.5f } ) ) ;
CORRADE_COMPARE ( data . emissiveTexture ( ) , 5 ) ;
CORRADE_COMPARE ( data . emissiveTextureCoordinates ( ) , 7 ) ;
CORRADE_COMPARE ( data . emissiveTextureLayer ( ) , 13 ) ;
}
void PbrMetallicRoughnessMaterialDataTest : : texturedDefaults ( ) {
@ -224,37 +239,44 @@ void PbrMetallicRoughnessMaterialDataTest::texturedDefaults() {
CORRADE_VERIFY ( ! data . hasNormalRoughnessMetallicTexture ( ) ) ;
CORRADE_VERIFY ( ! data . hasTextureTransformation ( ) ) ;
CORRADE_VERIFY ( ! data . hasTextureCoordinates ( ) ) ;
CORRADE_VERIFY ( ! data . hasTextureLayer ( ) ) ;
CORRADE_COMPARE ( data . baseColor ( ) , 0xffffffff _rgbaf ) ;
CORRADE_COMPARE ( data . baseColorTexture ( ) , 1 ) ;
CORRADE_COMPARE ( data . baseColorTextureMatrix ( ) , Matrix3 { } ) ;
CORRADE_COMPARE ( data . baseColorTextureCoordinates ( ) , 0 ) ;
CORRADE_COMPARE ( data . baseColorTextureLayer ( ) , 0 ) ;
CORRADE_COMPARE ( data . metalness ( ) , 1.0f ) ;
CORRADE_COMPARE ( data . metalnessTexture ( ) , 2 ) ;
CORRADE_COMPARE ( data . metalnessTextureSwizzle ( ) , MaterialTextureSwizzle : : R ) ;
CORRADE_COMPARE ( data . metalnessTextureMatrix ( ) , Matrix3 { } ) ;
CORRADE_COMPARE ( data . metalnessTextureCoordinates ( ) , 0 ) ;
CORRADE_COMPARE ( data . metalnessTextureLayer ( ) , 0 ) ;
CORRADE_COMPARE ( data . roughness ( ) , 1.0f ) ;
CORRADE_COMPARE ( data . roughnessTexture ( ) , 3 ) ;
CORRADE_COMPARE ( data . roughnessTextureSwizzle ( ) , MaterialTextureSwizzle : : R ) ;
CORRADE_COMPARE ( data . roughnessTextureMatrix ( ) , Matrix3 { } ) ;
CORRADE_COMPARE ( data . roughnessTextureCoordinates ( ) , 0 ) ;
CORRADE_COMPARE ( data . roughnessTextureLayer ( ) , 0 ) ;
CORRADE_COMPARE ( data . normalTexture ( ) , 4 ) ;
CORRADE_COMPARE ( data . normalTextureScale ( ) , 1.0f ) ;
CORRADE_COMPARE ( data . normalTextureSwizzle ( ) , MaterialTextureSwizzle : : RGB ) ;
CORRADE_COMPARE ( data . normalTextureMatrix ( ) , Matrix3 { } ) ;
CORRADE_COMPARE ( data . normalTextureCoordinates ( ) , 0 ) ;
CORRADE_COMPARE ( data . normalTextureLayer ( ) , 0 ) ;
CORRADE_COMPARE ( data . occlusionTexture ( ) , 5 ) ;
CORRADE_COMPARE ( data . occlusionTextureStrength ( ) , 1.0f ) ;
CORRADE_COMPARE ( data . occlusionTextureSwizzle ( ) , MaterialTextureSwizzle : : R ) ;
CORRADE_COMPARE ( data . occlusionTextureMatrix ( ) , Matrix3 { } ) ;
CORRADE_COMPARE ( data . occlusionTextureCoordinates ( ) , 0 ) ;
CORRADE_COMPARE ( data . occlusionTextureLayer ( ) , 0 ) ;
CORRADE_COMPARE ( data . emissiveColor ( ) , 0x000000 _rgbf ) ;
CORRADE_COMPARE ( data . emissiveTexture ( ) , 6 ) ;
CORRADE_COMPARE ( data . emissiveTextureMatrix ( ) , Matrix3 { } ) ;
CORRADE_COMPARE ( data . emissiveTextureCoordinates ( ) , 0 ) ;
CORRADE_COMPARE ( data . emissiveTextureLayer ( ) , 0 ) ;
}
void PbrMetallicRoughnessMaterialDataTest : : texturedSingleMatrixCoordinates ( ) {
void PbrMetallicRoughnessMaterialDataTest : : texturedSingleMatrixCoordinatesLayer ( ) {
PbrMetallicRoughnessMaterialData data { { } , {
{ MaterialAttribute : : BaseColorTexture , 1u } ,
{ MaterialAttribute : : MetalnessTexture , 2u } ,
@ -263,21 +285,28 @@ void PbrMetallicRoughnessMaterialDataTest::texturedSingleMatrixCoordinates() {
{ MaterialAttribute : : OcclusionTexture , 5u } ,
{ MaterialAttribute : : EmissiveTexture , 6u } ,
{ MaterialAttribute : : TextureMatrix , Matrix3 : : scaling ( { 0.5f , 0.5f } ) } ,
{ MaterialAttribute : : TextureCoordinates , 7u }
{ MaterialAttribute : : TextureCoordinates , 7u } ,
{ MaterialAttribute : : TextureLayer , 8u } ,
} } ;
CORRADE_COMPARE ( data . baseColorTextureMatrix ( ) , Matrix3 : : scaling ( { 0.5f , 0.5f } ) ) ;
CORRADE_COMPARE ( data . baseColorTextureCoordinates ( ) , 7 ) ;
CORRADE_COMPARE ( data . baseColorTextureLayer ( ) , 8 ) ;
CORRADE_COMPARE ( data . metalnessTextureMatrix ( ) , Matrix3 : : scaling ( { 0.5f , 0.5f } ) ) ;
CORRADE_COMPARE ( data . metalnessTextureCoordinates ( ) , 7 ) ;
CORRADE_COMPARE ( data . metalnessTextureLayer ( ) , 8 ) ;
CORRADE_COMPARE ( data . roughnessTextureMatrix ( ) , Matrix3 : : scaling ( { 0.5f , 0.5f } ) ) ;
CORRADE_COMPARE ( data . roughnessTextureCoordinates ( ) , 7 ) ;
CORRADE_COMPARE ( data . roughnessTextureLayer ( ) , 8 ) ;
CORRADE_COMPARE ( data . normalTextureMatrix ( ) , Matrix3 : : scaling ( { 0.5f , 0.5f } ) ) ;
CORRADE_COMPARE ( data . normalTextureCoordinates ( ) , 7 ) ;
CORRADE_COMPARE ( data . normalTextureLayer ( ) , 8 ) ;
CORRADE_COMPARE ( data . occlusionTextureMatrix ( ) , Matrix3 : : scaling ( { 0.5f , 0.5f } ) ) ;
CORRADE_COMPARE ( data . occlusionTextureCoordinates ( ) , 7 ) ;
CORRADE_COMPARE ( data . occlusionTextureLayer ( ) , 8 ) ;
CORRADE_COMPARE ( data . emissiveTextureMatrix ( ) , Matrix3 : : scaling ( { 0.5f , 0.5f } ) ) ;
CORRADE_COMPARE ( data . emissiveTextureCoordinates ( ) , 7 ) ;
CORRADE_COMPARE ( data . emissiveTextureLayer ( ) , 8 ) ;
}
void PbrMetallicRoughnessMaterialDataTest : : texturedImplicitPackedMetallicRoughness ( ) {
@ -291,10 +320,12 @@ void PbrMetallicRoughnessMaterialDataTest::texturedImplicitPackedMetallicRoughne
CORRADE_COMPARE ( data . roughnessTextureSwizzle ( ) , MaterialTextureSwizzle : : G ) ;
CORRADE_COMPARE ( data . roughnessTextureMatrix ( ) , Matrix3 { } ) ;
CORRADE_COMPARE ( data . roughnessTextureCoordinates ( ) , 0 ) ;
CORRADE_COMPARE ( data . roughnessTextureLayer ( ) , 0 ) ;
CORRADE_COMPARE ( data . metalnessTexture ( ) , 2 ) ;
CORRADE_COMPARE ( data . metalnessTextureSwizzle ( ) , MaterialTextureSwizzle : : B ) ;
CORRADE_COMPARE ( data . metalnessTextureMatrix ( ) , Matrix3 { } ) ;
CORRADE_COMPARE ( data . metalnessTextureCoordinates ( ) , 0 ) ;
CORRADE_COMPARE ( data . metalnessTextureLayer ( ) , 0 ) ;
/* Explicit parameters for everything, but all the same */
} {
@ -303,19 +334,23 @@ void PbrMetallicRoughnessMaterialDataTest::texturedImplicitPackedMetallicRoughne
{ MaterialAttribute : : RoughnessTextureSwizzle , MaterialTextureSwizzle : : G } ,
{ MaterialAttribute : : RoughnessTextureMatrix , Matrix3 : : scaling ( { 0.5f , 0.5f } ) } ,
{ MaterialAttribute : : RoughnessTextureCoordinates , 3u } ,
{ MaterialAttribute : : RoughnessTextureLayer , 17u } ,
{ MaterialAttribute : : MetalnessTextureMatrix , Matrix3 : : scaling ( { 0.5f , 0.5f } ) } ,
{ MaterialAttribute : : MetalnessTextureSwizzle , MaterialTextureSwizzle : : B } ,
{ MaterialAttribute : : MetalnessTextureCoordinates , 3u }
{ MaterialAttribute : : MetalnessTextureCoordinates , 3u } ,
{ MaterialAttribute : : MetalnessTextureLayer , 17u } ,
} } ;
CORRADE_VERIFY ( data . hasNoneRoughnessMetallicTexture ( ) ) ;
CORRADE_COMPARE ( data . roughnessTexture ( ) , 2 ) ;
CORRADE_COMPARE ( data . roughnessTextureSwizzle ( ) , MaterialTextureSwizzle : : G ) ;
CORRADE_COMPARE ( data . roughnessTextureMatrix ( ) , Matrix3 : : scaling ( { 0.5f , 0.5f } ) ) ;
CORRADE_COMPARE ( data . roughnessTextureCoordinates ( ) , 3 ) ;
CORRADE_COMPARE ( data . roughnessTextureLayer ( ) , 17 ) ;
CORRADE_COMPARE ( data . metalnessTexture ( ) , 2 ) ;
CORRADE_COMPARE ( data . metalnessTextureSwizzle ( ) , MaterialTextureSwizzle : : B ) ;
CORRADE_COMPARE ( data . metalnessTextureMatrix ( ) , Matrix3 : : scaling ( { 0.5f , 0.5f } ) ) ;
CORRADE_COMPARE ( data . metalnessTextureCoordinates ( ) , 3 ) ;
CORRADE_COMPARE ( data . metalnessTextureLayer ( ) , 17 ) ;
/* Swizzle is ignored when the combined texture is specified, so this is
fine */
@ -341,6 +376,14 @@ void PbrMetallicRoughnessMaterialDataTest::texturedImplicitPackedMetallicRoughne
{ MaterialAttribute : : RoughnessTextureCoordinates , 1u } ,
} } ;
CORRADE_VERIFY ( ! data . hasNoneRoughnessMetallicTexture ( ) ) ;
/* Unexpected array texture layer */
} {
PbrMetallicRoughnessMaterialData data { { } , {
{ MaterialAttribute : : NoneRoughnessMetallicTexture , 2u } ,
{ MaterialAttribute : : MetalnessTextureLayer , 1u } ,
} } ;
CORRADE_VERIFY ( ! data . hasNoneRoughnessMetallicTexture ( ) ) ;
}
}
@ -362,10 +405,12 @@ void PbrMetallicRoughnessMaterialDataTest::texturedExplicitPackedMetallicRoughne
{ MaterialAttribute : : RoughnessTextureSwizzle , MaterialTextureSwizzle : : G } ,
{ MaterialAttribute : : RoughnessTextureMatrix , Matrix3 : : scaling ( { 0.5f , 0.5f } ) } ,
{ MaterialAttribute : : RoughnessTextureCoordinates , 3u } ,
{ MaterialAttribute : : RoughnessTextureLayer , 7u } ,
{ MaterialAttribute : : MetalnessTexture , 2u } ,
{ MaterialAttribute : : MetalnessTextureMatrix , Matrix3 : : scaling ( { 0.5f , 0.5f } ) } ,
{ MaterialAttribute : : MetalnessTextureSwizzle , MaterialTextureSwizzle : : B } ,
{ MaterialAttribute : : MetalnessTextureCoordinates , 3u }
{ MaterialAttribute : : MetalnessTextureCoordinates , 3u } ,
{ MaterialAttribute : : MetalnessTextureLayer , 7u }
} } ;
CORRADE_VERIFY ( data . hasNoneRoughnessMetallicTexture ( ) ) ;
@ -418,6 +463,17 @@ void PbrMetallicRoughnessMaterialDataTest::texturedExplicitPackedMetallicRoughne
{ MaterialAttribute : : MetalnessTextureSwizzle , MaterialTextureSwizzle : : B } ,
} } ;
CORRADE_VERIFY ( ! data . hasNoneRoughnessMetallicTexture ( ) ) ;
/* Unexpected array texture layer */
} {
PbrMetallicRoughnessMaterialData data { { } , {
{ MaterialAttribute : : RoughnessTexture , 2u } ,
{ MaterialAttribute : : RoughnessTextureSwizzle , MaterialTextureSwizzle : : G } ,
{ MaterialAttribute : : MetalnessTexture , 2u } ,
{ MaterialAttribute : : MetalnessTextureSwizzle , MaterialTextureSwizzle : : B } ,
{ MaterialAttribute : : MetalnessTextureLayer , 1u } ,
} } ;
CORRADE_VERIFY ( ! data . hasNoneRoughnessMetallicTexture ( ) ) ;
}
}
@ -442,14 +498,17 @@ void PbrMetallicRoughnessMaterialDataTest::texturedExplicitPackedRoughnessMetall
{ MaterialAttribute : : RoughnessTextureSwizzle , MaterialTextureSwizzle : : R } ,
{ MaterialAttribute : : RoughnessTextureMatrix , Matrix3 : : scaling ( { 0.5f , 0.5f } ) } ,
{ MaterialAttribute : : RoughnessTextureCoordinates , 3u } ,
{ MaterialAttribute : : RoughnessTextureLayer , 7u } ,
{ MaterialAttribute : : MetalnessTexture , 2u } ,
{ MaterialAttribute : : MetalnessTextureMatrix , Matrix3 : : scaling ( { 0.5f , 0.5f } ) } ,
{ MaterialAttribute : : MetalnessTextureSwizzle , MaterialTextureSwizzle : : G } ,
{ MaterialAttribute : : MetalnessTextureCoordinates , 3u } ,
{ MaterialAttribute : : MetalnessTextureLayer , 7u } ,
{ MaterialAttribute : : OcclusionTexture , 2u } ,
{ MaterialAttribute : : OcclusionTextureSwizzle , MaterialTextureSwizzle : : B } ,
{ MaterialAttribute : : OcclusionTextureMatrix , Matrix3 : : scaling ( { 0.5f , 0.5f } ) } ,
{ MaterialAttribute : : OcclusionTextureCoordinates , 3u }
{ MaterialAttribute : : OcclusionTextureCoordinates , 3u } ,
{ MaterialAttribute : : OcclusionTextureLayer , 7u } ,
} } ;
CORRADE_VERIFY ( data . hasRoughnessMetallicOcclusionTexture ( ) ) ;
/* This isn't a superset */
@ -506,9 +565,21 @@ void PbrMetallicRoughnessMaterialDataTest::texturedExplicitPackedRoughnessMetall
{ MaterialAttribute : : RoughnessTexture , 2u } ,
{ MaterialAttribute : : MetalnessTexture , 2u } ,
{ MaterialAttribute : : MetalnessTextureSwizzle , MaterialTextureSwizzle : : G } ,
{ MaterialAttribute : : MetalnessTextureCoordinates , 1u } ,
{ MaterialAttribute : : OcclusionTexture , 2u } ,
{ MaterialAttribute : : OcclusionTextureSwizzle , MaterialTextureSwizzle : : B } ,
} } ;
CORRADE_VERIFY ( ! data . hasRoughnessMetallicOcclusionTexture ( ) ) ;
/* Unexpected array texture layer */
} {
PbrMetallicRoughnessMaterialData data { { } , {
{ MaterialAttribute : : RoughnessTexture , 2u } ,
{ MaterialAttribute : : RoughnessTextureLayer , 1u } ,
{ MaterialAttribute : : MetalnessTexture , 2u } ,
{ MaterialAttribute : : MetalnessTextureSwizzle , MaterialTextureSwizzle : : G } ,
{ MaterialAttribute : : OcclusionTexture , 2u } ,
{ MaterialAttribute : : OcclusionTextureSwizzle , MaterialTextureSwizzle : : B } ,
{ MaterialAttribute : : MetalnessTextureCoordinates , 1u } ,
} } ;
CORRADE_VERIFY ( ! data . hasRoughnessMetallicOcclusionTexture ( ) ) ;
}
@ -604,6 +675,18 @@ void PbrMetallicRoughnessMaterialDataTest::texturedExplicitPackedOcclusionRoughn
{ MaterialAttribute : : MetalnessTextureCoordinates , 1u } ,
} } ;
CORRADE_VERIFY ( ! data . hasOcclusionRoughnessMetallicTexture ( ) ) ;
/* Unexpected array texture layer */
} {
PbrMetallicRoughnessMaterialData data { { } , {
{ MaterialAttribute : : OcclusionTexture , 2u } ,
{ MaterialAttribute : : OcclusionTextureLayer , 1u } ,
{ MaterialAttribute : : RoughnessTexture , 2u } ,
{ MaterialAttribute : : RoughnessTextureSwizzle , MaterialTextureSwizzle : : G } ,
{ MaterialAttribute : : MetalnessTexture , 2u } ,
{ MaterialAttribute : : MetalnessTextureSwizzle , MaterialTextureSwizzle : : B } ,
} } ;
CORRADE_VERIFY ( ! data . hasOcclusionRoughnessMetallicTexture ( ) ) ;
}
}
@ -697,6 +780,19 @@ void PbrMetallicRoughnessMaterialDataTest::texturedExplicitPackedNormalRoughness
{ MaterialAttribute : : MetalnessTextureCoordinates , 1u } ,
} } ;
CORRADE_VERIFY ( ! data . hasNormalRoughnessMetallicTexture ( ) ) ;
/* Unexpected array texture layer */
} {
PbrMetallicRoughnessMaterialData data { { } , {
{ MaterialAttribute : : NormalTexture , 2u } ,
{ MaterialAttribute : : NormalTextureSwizzle , MaterialTextureSwizzle : : RG } ,
{ MaterialAttribute : : RoughnessTexture , 2u } ,
{ MaterialAttribute : : RoughnessTextureSwizzle , MaterialTextureSwizzle : : B } ,
{ MaterialAttribute : : RoughnessTextureLayer , 1u } ,
{ MaterialAttribute : : MetalnessTexture , 2u } ,
{ MaterialAttribute : : MetalnessTextureSwizzle , MaterialTextureSwizzle : : A } ,
} } ;
CORRADE_VERIFY ( ! data . hasNormalRoughnessMetallicTexture ( ) ) ;
}
}
@ -712,72 +808,89 @@ void PbrMetallicRoughnessMaterialDataTest::invalidTextures() {
data . baseColorTexture ( ) ;
data . baseColorTextureMatrix ( ) ;
data . baseColorTextureCoordinates ( ) ;
data . baseColorTextureLayer ( ) ;
data . metalnessTexture ( ) ;
data . metalnessTextureSwizzle ( ) ;
data . metalnessTextureMatrix ( ) ;
data . metalnessTextureCoordinates ( ) ;
data . metalnessTextureLayer ( ) ;
data . roughnessTexture ( ) ;
data . roughnessTextureSwizzle ( ) ;
data . roughnessTextureMatrix ( ) ;
data . roughnessTextureCoordinates ( ) ;
data . roughnessTextureLayer ( ) ;
data . normalTexture ( ) ;
data . normalTextureScale ( ) ;
data . normalTextureSwizzle ( ) ;
data . normalTextureMatrix ( ) ;
data . normalTextureCoordinates ( ) ;
data . normalTextureLayer ( ) ;
data . occlusionTexture ( ) ;
data . occlusionTextureStrength ( ) ;
data . occlusionTextureSwizzle ( ) ;
data . occlusionTextureMatrix ( ) ;
data . occlusionTextureCoordinates ( ) ;
data . occlusionTextureLayer ( ) ;
data . emissiveTexture ( ) ;
data . emissiveTextureMatrix ( ) ;
data . emissiveTextureCoordinates ( ) ;
data . emissiveTextureLayer ( ) ;
CORRADE_COMPARE ( out . str ( ) ,
" Trade::MaterialData::attribute(): attribute BaseColorTexture not found in layer 0 \n "
" Trade::PbrMetallicRoughnessMaterialData::baseColorTextureMatrix(): the material doesn't have a base color texture \n "
" Trade::PbrMetallicRoughnessMaterialData::baseColorTextureCoordinates(): the material doesn't have a base color texture \n "
" Trade::PbrMetallicRoughnessMaterialData::baseColorTextureLayer(): the material doesn't have a base color texture \n "
" Trade::PbrMetallicRoughnessMaterialData::metalnessTexture(): the material doesn't have a metalness texture \n "
" Trade::PbrMetallicRoughnessMaterialData::metalnessTextureSwizzle(): the material doesn't have a metalness texture \n "
" Trade::PbrMetallicRoughnessMaterialData::metalnessTextureMatrix(): the material doesn't have a metalness texture \n "
" Trade::PbrMetallicRoughnessMaterialData::metalnessTextureCoordinates(): the material doesn't have a metalness texture \n "
" Trade::PbrMetallicRoughnessMaterialData::metalnessTextureLayer(): the material doesn't have a metalness texture \n "
" Trade::PbrMetallicRoughnessMaterialData::roughnessTexture(): the material doesn't have a roughness texture \n "
" Trade::PbrMetallicRoughnessMaterialData::roughnessTextureSwizzle(): the material doesn't have a roughness texture \n "
" Trade::PbrMetallicRoughnessMaterialData::roughnessTextureMatrix(): the material doesn't have a roughness texture \n "
" Trade::PbrMetallicRoughnessMaterialData::roughnessTextureCoordinates(): the material doesn't have a roughness texture \n "
" Trade::PbrMetallicRoughnessMaterialData::roughnessTextureLayer(): the material doesn't have a roughness texture \n "
" Trade::MaterialData::attribute(): attribute NormalTexture not found in layer 0 \n "
" Trade::PbrMetallicRoughnessMaterialData::normalTextureScale(): the material doesn't have a normal texture \n "
" Trade::PbrMetallicRoughnessMaterialData::normalTextureSwizzle(): the material doesn't have a normal texture \n "
" Trade::PbrMetallicRoughnessMaterialData::normalTextureMatrix(): the material doesn't have a normal texture \n "
" Trade::PbrMetallicRoughnessMaterialData::normalTextureCoordinates(): the material doesn't have a normal texture \n "
" Trade::PbrMetallicRoughnessMaterialData::normalTextureLayer(): the material doesn't have a normal texture \n "
" Trade::MaterialData::attribute(): attribute OcclusionTexture not found in layer 0 \n "
" Trade::PbrMetallicRoughnessMaterialData::occlusionTextureStrength(): the material doesn't have an occlusion texture \n "
" Trade::PbrMetallicRoughnessMaterialData::occlusionTextureSwizzle(): the material doesn't have an occlusion texture \n "
" Trade::PbrMetallicRoughnessMaterialData::occlusionTextureMatrix(): the material doesn't have an occlusion texture \n "
" Trade::PbrMetallicRoughnessMaterialData::occlusionTextureCoordinates(): the material doesn't have an occlusion texture \n "
" Trade::PbrMetallicRoughnessMaterialData::occlusionTextureLayer(): the material doesn't have an occlusion texture \n "
" Trade::MaterialData::attribute(): attribute EmissiveTexture not found in layer 0 \n "
" Trade::PbrMetallicRoughnessMaterialData::emissiveTextureMatrix(): the material doesn't have an emissive texture \n "
" Trade::PbrMetallicRoughnessMaterialData::emissiveTextureCoordinates(): the material doesn't have an emissive texture \n " ) ;
" Trade::PbrMetallicRoughnessMaterialData::emissiveTextureCoordinates(): the material doesn't have an emissive texture \n "
" Trade::PbrMetallicRoughnessMaterialData::emissiveTextureLayer(): the material doesn't have an emissive texture \n " ) ;
}
void PbrMetallicRoughnessMaterialDataTest : : commonTransformationCoordinatesNoTextures ( ) {
void PbrMetallicRoughnessMaterialDataTest : : commonTransformationCoordinatesLayer NoTextures ( ) {
PbrMetallicRoughnessMaterialData a { { } , { } } ;
CORRADE_VERIFY ( a . hasCommonTextureTransformation ( ) ) ;
CORRADE_VERIFY ( a . hasCommonTextureCoordinates ( ) ) ;
CORRADE_VERIFY ( a . hasCommonTextureLayer ( ) ) ;
CORRADE_COMPARE ( a . commonTextureMatrix ( ) , Matrix3 { } ) ;
CORRADE_COMPARE ( a . commonTextureCoordinates ( ) , 0 ) ;
CORRADE_COMPARE ( a . commonTextureLayer ( ) , 0 ) ;
PbrMetallicRoughnessMaterialData b { { } , {
{ MaterialAttribute : : TextureMatrix , Matrix3 : : scaling ( { 0.5f , 0.5f } ) } ,
{ MaterialAttribute : : TextureCoordinates , 7u }
{ MaterialAttribute : : TextureCoordinates , 7u } ,
{ MaterialAttribute : : TextureLayer , 22u }
} } ;
CORRADE_VERIFY ( b . hasCommonTextureTransformation ( ) ) ;
CORRADE_VERIFY ( b . hasCommonTextureCoordinates ( ) ) ;
CORRADE_VERIFY ( b . hasCommonTextureLayer ( ) ) ;
CORRADE_COMPARE ( b . commonTextureMatrix ( ) , Matrix3 : : scaling ( { 0.5f , 0.5f } ) ) ;
CORRADE_COMPARE ( b . commonTextureCoordinates ( ) , 7 ) ;
CORRADE_COMPARE ( b . commonTextureLayer ( ) , 22 ) ;
}
void PbrMetallicRoughnessMaterialDataTest : : commonTransformationCoordinatesOneTexture ( ) {
void PbrMetallicRoughnessMaterialDataTest : : commonTransformationCoordinatesLayer OneTexture ( ) {
Containers : : StringView textureName = PbrMetallicRoughnessTextureData [ testCaseInstanceId ( ) ] ;
setTestCaseDescription ( textureName ) ;
@ -785,19 +898,23 @@ void PbrMetallicRoughnessMaterialDataTest::commonTransformationCoordinatesOneTex
{ textureName , 5u } ,
{ textureName + " Matrix " , Matrix3 : : scaling ( { 0.5f , 1.0f } ) } ,
{ textureName + " Coordinates " , 17u } ,
{ textureName + " Layer " , 22u } ,
/* These shouldn't affect the above */
{ MaterialAttribute : : TextureMatrix , Matrix3 : : translation ( { 0.5f , 0.0f } ) } ,
{ MaterialAttribute : : TextureCoordinates , 3u }
{ MaterialAttribute : : TextureCoordinates , 3u } ,
{ MaterialAttribute : : TextureLayer , 66u } ,
} } ;
CORRADE_VERIFY ( data . hasCommonTextureTransformation ( ) ) ;
CORRADE_COMPARE ( data . commonTextureMatrix ( ) , Matrix3 : : scaling ( { 0.5f , 1.0f } ) ) ;
CORRADE_VERIFY ( data . hasCommonTextureCoordinates ( ) ) ;
CORRADE_COMPARE ( data . commonTextureCoordinates ( ) , 17u ) ;
CORRADE_VERIFY ( data . hasCommonTextureLayer ( ) ) ;
CORRADE_COMPARE ( data . commonTextureLayer ( ) , 22u ) ;
}
void PbrMetallicRoughnessMaterialDataTest : : commonTransformationCoordinatesOneDifferentTexture ( ) {
void PbrMetallicRoughnessMaterialDataTest : : commonTransformationCoordinatesLayer OneDifferentTexture ( ) {
Containers : : StringView textureName = PbrMetallicRoughnessTextureData [ testCaseInstanceId ( ) ] ;
setTestCaseDescription ( textureName ) ;
@ -810,18 +927,21 @@ void PbrMetallicRoughnessMaterialDataTest::commonTransformationCoordinatesOneDif
{ MaterialAttribute : : EmissiveTexture , 7u } ,
{ textureName + " Matrix " , Matrix3 : : scaling ( { 0.5f , 1.0f } ) } ,
{ textureName + " Coordinates " , 17u } ,
{ textureName + " Layer " , 22u } ,
/* These are used by all textures except the one above, failing the
check */
{ MaterialAttribute : : TextureMatrix , Matrix3 : : translation ( { 0.5f , 0.0f } ) } ,
{ MaterialAttribute : : TextureCoordinates , 3u }
{ MaterialAttribute : : TextureCoordinates , 3u } ,
{ MaterialAttribute : : TextureLayer , 66u } ,
} } ;
CORRADE_VERIFY ( ! data . hasCommonTextureTransformation ( ) ) ;
CORRADE_VERIFY ( ! data . hasCommonTextureCoordinates ( ) ) ;
CORRADE_VERIFY ( ! data . hasCommonTextureLayer ( ) ) ;
}
void PbrMetallicRoughnessMaterialDataTest : : commonCoordinatesImplicit ( ) {
void PbrMetallicRoughnessMaterialDataTest : : commonCoordinatesLayer Implicit ( ) {
Containers : : StringView textureName = PbrMetallicRoughnessTextureData [ testCaseInstanceId ( ) ] ;
setTestCaseDescription ( textureName ) ;
@ -830,16 +950,20 @@ void PbrMetallicRoughnessMaterialDataTest::commonCoordinatesImplicit() {
PbrMetallicRoughnessMaterialData data { { } , {
{ textureName , 5u } ,
{ textureName + " Coordinates " , 0u }
{ textureName + " Coordinates " , 0u } ,
{ textureName + " Layer " , 0u } ,
} } ;
/* Zero is treated same as if there would be no attribute at all */
CORRADE_VERIFY ( ! data . hasTextureCoordinates ( ) ) ;
CORRADE_VERIFY ( ! data . hasTextureLayer ( ) ) ;
CORRADE_VERIFY ( data . hasCommonTextureCoordinates ( ) ) ;
CORRADE_VERIFY ( data . hasCommonTextureLayer ( ) ) ;
CORRADE_COMPARE ( data . commonTextureCoordinates ( ) , 0u ) ;
CORRADE_COMPARE ( data . commonTextureLayer ( ) , 0u ) ;
}
void PbrMetallicRoughnessMaterialDataTest : : noCommonTransformationCoordinates ( ) {
void PbrMetallicRoughnessMaterialDataTest : : noCommonTransformationCoordinatesLayer ( ) {
# ifdef CORRADE_NO_ASSERT
CORRADE_SKIP ( " CORRADE_NO_ASSERT defined, can't test assertions " ) ;
# endif
@ -850,20 +974,24 @@ void PbrMetallicRoughnessMaterialDataTest::noCommonTransformationCoordinates() {
{ MaterialAttribute : : BaseColorTextureCoordinates , 3u } ,
{ MaterialAttribute : : MetalnessTexture , 4u } ,
{ MaterialAttribute : : MetalnessTextureMatrix , Matrix3 : : scaling ( { 0.5f , 1.0f } ) } ,
{ MaterialAttribute : : MetalnessTextureLayer , 22u } ,
{ MaterialAttribute : : RoughnessTexture , 5u } ,
{ MaterialAttribute : : RoughnessTextureCoordinates , 17u }
} } ;
CORRADE_VERIFY ( ! data . hasCommonTextureTransformation ( ) ) ;
CORRADE_VERIFY ( ! data . hasCommonTextureCoordinates ( ) ) ;
CORRADE_VERIFY ( ! data . hasCommonTextureLayer ( ) ) ;
std : : ostringstream out ;
Error redirectError { & out } ;
data . commonTextureMatrix ( ) ;
data . commonTextureCoordinates ( ) ;
data . commonTextureLayer ( ) ;
CORRADE_COMPARE ( out . str ( ) ,
" Trade::PbrMetallicRoughnessMaterialData::commonTextureMatrix(): the material doesn't have a common texture coordinate transformation \n "
" Trade::PbrMetallicRoughnessMaterialData::commonTextureCoordinates(): the material doesn't have a common texture coordinate set \n " ) ;
" Trade::PbrMetallicRoughnessMaterialData::commonTextureCoordinates(): the material doesn't have a common texture coordinate set \n "
" Trade::PbrMetallicRoughnessMaterialData::commonTextureLayer(): the material doesn't have a common array texture layer \n " ) ;
}
} } } }