Skip to content
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
1b2d599
[render] add anisotropy tests
dlupo2 Feb 10, 2026
176be37
[render] add anisotropy data loading
dlupo2 Feb 10, 2026
21efe93
[render] add anisotropy ibl implementation
dlupo2 Feb 11, 2026
b4b8f92
[render] add anisotropy implementation for analytical lights
dlupo2 Feb 11, 2026
1744d51
Merge remote-tracking branch 'vclibMuntoni/dynamic_texture_stage' int…
dlupo2 Feb 12, 2026
3b1b872
[assets] add carbon fibre example
dlupo2 Feb 20, 2026
e85dd33
Merge branch 'main' into pr/alemuntoni/32
alemuntoni Mar 12, 2026
53de00a
[render] remove AnisotropyDiscs and AnisotropySpheres gltf examples
alemuntoni Mar 12, 2026
a968d52
[render] fixes
alemuntoni Mar 13, 2026
0df2d3f
[render] fix
alemuntoni Mar 13, 2026
28c816b
Merge branch 'main' into pr/alemuntoni/32
alemuntoni Mar 13, 2026
1bc488e
[render] restore viewer lights on pbr settings
alemuntoni Mar 25, 2026
d7beb79
Merge branch 'main' into pr/alemuntoni/32
alemuntoni Apr 1, 2026
f518f9c
[render] fix typo in GLTFExamples
malomo Apr 28, 2026
55bc230
[render] moved clampedDot to the top, and used in anisotropic pbr
malomo Apr 28, 2026
cacaf0b
Merge branch 'main' into pr/alemuntoni/32
alemuntoni Jun 29, 2026
1ff7024
Merge branch 'main' into pr/alemuntoni/32
alemuntoni Jun 29, 2026
627d54b
Merge branch 'main' into pr/alemuntoni/32
alemuntoni Jun 30, 2026
1b964db
Merge branch 'main' into pr/alemuntoni/32
alemuntoni Jul 2, 2026
a35db32
Merge branch 'main' into pr/alemuntoni/32
alemuntoni Jul 20, 2026
ca39e2a
Merge branch 'main' into pr/alemuntoni/32
alemuntoni Jul 20, 2026
6c2f4ce
[render] Add 2x2 downsampling for normal map mip generation in setTex…
alemuntoni Jul 20, 2026
b7ca637
Merge branch 'main' into pr/alemuntoni/32
alemuntoni Jul 21, 2026
d0acd5b
Merge branch 'main' into pr/alemuntoni/32
alemuntoni Aug 1, 2026
659fa3e
[render] add anisotropy to pbr tests
alemuntoni Aug 1, 2026
3dd2d8e
Merge branch 'main' into pr/alemuntoni/32
alemuntoni Aug 2, 2026
a9fad72
Merge branch 'main' into pr/alemuntoni/32
alemuntoni Aug 2, 2026
128d80c
Merge branch 'main' into pr/alemuntoni/32
alemuntoni Aug 2, 2026
51c81c1
Merge branch 'main' into pr/alemuntoni/32
alemuntoni Aug 9, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
181 changes: 181 additions & 0 deletions assets/example_meshes/gltf/CarbonFibre/CarbonFibre.gltf
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
{
"asset": {
"version": "2.0",
"generator": "3ds Max, Max2Babylon, Visual Studio Code, glTF Tools",
"copyright": "(C) 2023, Wayfair LLC. CC-BY 4.0 International https://creativecommons.org/licenses/by/4.0/. Model and textures created by Eric Chadwick."
},
"scene": 0,
"scenes": [
{
"nodes": [
0
]
}
],
"nodes": [
{
"mesh": 0,
"translation": [
0.0,
0.5,
0.0
],
"name": "CarbonFibre"
}
],
"meshes": [
{
"primitives": [
{
"attributes": {
"POSITION": 1,
"NORMAL": 2,
"TEXCOORD_0": 3
},
"indices": 0,
"material": 0
}
],
"name": "CarbonFibre"
}
],
"accessors": [
{
"bufferView": 0,
"componentType": 5123,
"count": 11904,
"type": "SCALAR",
"name": "accessorIndices"
},
{
"bufferView": 1,
"componentType": 5126,
"count": 2129,
"max": [
0.5,
0.5,
0.5
],
"min": [
-0.5,
-0.5,
-0.5
],
"type": "VEC3",
"name": "accessorPositions"
},
{
"bufferView": 1,
"byteOffset": 25548,
"componentType": 5126,
"count": 2129,
"type": "VEC3",
"name": "accessorNormals"
},
{
"bufferView": 2,
"componentType": 5126,
"count": 2129,
"type": "VEC2",
"name": "accessorUVs"
}
],
"bufferViews": [
{
"buffer": 0,
"byteLength": 23808,
"name": "bufferViewScalar",
"target": 34963
},
{
"buffer": 0,
"byteOffset": 23808,
"byteLength": 51096,
"byteStride": 12,
"name": "bufferViewFloatVec3",
"target": 34962
},
{
"buffer": 0,
"byteOffset": 74904,
"byteLength": 17032,
"byteStride": 8,
"name": "bufferViewFloatVec2",
"target": 34962
}
],
"buffers": [
{
"uri": "CarbonFibre.bin",
"byteLength": 91936
}
],
"extensionsUsed": [
"KHR_materials_anisotropy"
],
"images": [
{
"uri": "CarbonFibre_occlusion.png"
},
{
"uri": "CarbonFibre_normal.png"
},
{
"uri": "CarbonFibre_anisotropy.png"
}
],
"textures": [
{
"name": "CarbonFibre_occlusion.png",
"sampler": 0,
"source": 0
},
{
"name": "CarbonFibre_normal.png",
"sampler": 0,
"source": 1
},
{
"name": "CarbonFibre_anisotropy.png",
"sampler": 0,
"source": 2
}
],
"materials": [
{
"name": "CarbonFibre",
"pbrMetallicRoughness": {
"baseColorFactor": [
0.009,
0.009,
0.009,
1.0
],
"metallicFactor": 0,
"roughnessFactor": 0.4
},
"normalTexture": {
"index": 1,
"scale": 2
},
"occlusionTexture": {
"index": 0
},
"extensions": {
"KHR_materials_anisotropy": {
"anisotropyStrength": 0.5,
"anisotropyRotation": 0,
"anisotropyTexture": {
"index": 2
}
}
}
}
],
"samplers": [
{
"magFilter": 9729,
"minFilter": 9987
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 15 additions & 3 deletions examples/render/950-pbr/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ int main(int argc, char** argv)
NORMAL_TENGENT_MIRROR_TEST,
COMPARE_AMBIENT_OCCLUSION,
DAMAGED_HELMET,
ANISOTROPY_ROTATION_TEST,
CARBON_FIBRE,
COUNT_EXAMPLES
};

Expand All @@ -44,9 +46,11 @@ int main(int argc, char** argv)
"/gltf/MetalRoughSpheres/MetalRoughSpheres.gltf",
"/gltf/NormalTangentMirrorTest/NormalTangentMirrorTest.gltf",
"/gltf/CompareAmbientOcclusion/CompareAmbientOcclusion.gltf",
"/gltf/DamagedHelmet/DamagedHelmet.gltf"};
"/gltf/DamagedHelmet/DamagedHelmet.gltf",
"/gltf/AnisotropyRotationTest/AnisotropyRotationTest.gltf",
"/gltf/CarbonFibre/CarbonFibre.gltf"};

uint selectedExample = METAL_ROUGH_SPHERES;
uint selectedExample = CARBON_FIBRE;

enum PanoramasExamples {
COLOSSEUM_HDR,
Expand All @@ -66,7 +70,7 @@ int main(int argc, char** argv)
"/panoramas/uffizi.hdr",
"/panoramas/uffizi.ktx"};

uint selectedPanorama = UFFIZI_KTX;
uint selectedPanorama = COLOSSEUM_HDR;

std::vector<vcl::TriMesh> meshes = vcl::loadMeshes<vcl::TriMesh>(
VCLIB_EXAMPLE_MESHES_PATH + gltfExampleFilenames[selectedExample]);
Expand All @@ -88,6 +92,9 @@ int main(int argc, char** argv)
else if (type == EMISSIVE) {
typeName = "emissive";
}
else if (type == ANISOTROPY) {
typeName = "anisotropy";
}

std::cout << " " << typeName << "Texture: ";
if (!texture.isNull()) {
Expand Down Expand Up @@ -120,11 +127,16 @@ int main(int argc, char** argv)
std::cout << " normalScale: " << mat.normalScale() << std::endl;
std::cout << " occlusionStrength: " << mat.occlusionStrength()
<< std::endl;
std::cout << " anisotropyStrength: " << mat.anisotropyStrength()
<< std::endl;
std::cout << " anisotropyRotation: " << mat.anisotropyRotation()
<< std::endl;
printTextureInfo(mat, BASE_COLOR);
printTextureInfo(mat, METALLIC_ROUGHNESS);
printTextureInfo(mat, NORMAL);
printTextureInfo(mat, OCCLUSION);
printTextureInfo(mat, EMISSIVE);
printTextureInfo(mat, ANISOTROPY);
std::cout << " ------------------------" << std::endl;
}
std::cout << "------------------------" << std::endl;
Expand Down
55 changes: 45 additions & 10 deletions vclib/core/include/vclib/io/mesh/gltf/detail/load_mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ int loadGltfPrimitiveMaterial(
bool doubleSided;
int baseColorTextureId, metallicRoughnessTextureId, normalTextureId,
occlusionTextureId, emissiveTextureId;

double anisotropyStrength = 0.0;
double anisotropyRotation = 0.0;
int anisotropyTextureId = -1;

const tinygltf::Material& mat = model.materials[p.material];

std::string matName = mat.name;
Expand Down Expand Up @@ -122,6 +127,32 @@ int loadGltfPrimitiveMaterial(
// occlusionStrength
occlusionStrength = mat.occlusionTexture.strength;

// anisotropy
if (mat.extensions.contains("KHR_materials_anisotropy")) {
const auto& anisotropyExt =
mat.extensions.at("KHR_materials_anisotropy");

if (anisotropyExt.Has("anisotropyStrength")) {
anisotropyStrength = anisotropyExt
.Get("anisotropyStrength")
.GetNumberAsDouble();
anisotropyStrength = std::clamp(anisotropyStrength, 0.0, 1.0);
}

if (anisotropyExt.Has("anisotropyRotation")) {
anisotropyRotation = anisotropyExt
.Get("anisotropyRotation")
.GetNumberAsDouble();
}

if (anisotropyExt.Has("anisotropyTexture")) {
auto& tex = anisotropyExt.Get("anisotropyTexture");
if (tex.Has("index")) {
anisotropyTextureId = tex.Get("index").GetNumberAsInt();
}
}
Comment thread
alemuntoni marked this conversation as resolved.
}

// function to load a texture in a material
auto loadTextureInMaterial = [&](Material& mat,
int textureId,
Expand Down Expand Up @@ -185,16 +216,18 @@ int loadGltfPrimitiveMaterial(

if constexpr (HasMaterials<MeshType>) {
Material mat;
mat.name() = matName;
mat.baseColor() = baseColor;
mat.metallic() = metallic;
mat.roughness() = roughness;
mat.emissiveColor() = emissiveColor;
mat.alphaMode() = alphaMode;
mat.alphaCutoff() = alphaCutoff;
mat.doubleSided() = doubleSided;
mat.normalScale() = normalScale;
mat.occlusionStrength() = occlusionStrength;
mat.name() = matName;
mat.baseColor() = baseColor;
mat.metallic() = metallic;
mat.roughness() = roughness;
mat.emissiveColor() = emissiveColor;
mat.alphaMode() = alphaMode;
mat.alphaCutoff() = alphaCutoff;
mat.doubleSided() = doubleSided;
mat.normalScale() = normalScale;
mat.occlusionStrength() = occlusionStrength;
mat.anisotropyStrength() = anisotropyStrength;
mat.anisotropyRotation() = anisotropyRotation;
loadTextureInMaterial(
mat, baseColorTextureId, Material::TextureType::BASE_COLOR);
loadTextureInMaterial(
Expand All @@ -207,6 +240,8 @@ int loadGltfPrimitiveMaterial(
mat, occlusionTextureId, Material::TextureType::OCCLUSION);
loadTextureInMaterial(
mat, emissiveTextureId, Material::TextureType::EMISSIVE);
loadTextureInMaterial(
mat, anisotropyTextureId, Material::TextureType::ANISOTROPY);
m.pushMaterial(mat);
idx = m.materialCount() - 1; // index of the added material
if constexpr (HasColor<MeshType>) {
Expand Down
Loading
Loading