Skip to content
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,322 @@
{
"accessors": [
{
"bufferView": 0,
"componentType": 5123,
"count": 3840,
"max": [
672
],
"min": [
0
],
"type": "SCALAR"
},
{
"bufferView": 1,
"componentType": 5126,
"count": 673,
"max": [
0.5,
0.5,
0.5
],
"min": [
-0.5,
-0.5,
-0.5
],
"type": "VEC3"
},
{
"bufferView": 2,
"componentType": 5126,
"count": 673,
"max": [
0.9999999403953552,
1
],
"min": [
-0.15000003576278687,
0
],
"type": "VEC2"
},
{
"bufferView": 3,
"componentType": 5126,
"count": 673,
"max": [
0.9999998211860657,
1,
1
],
"min": [
-0.9999998211860657,
-1,
-1
],
"type": "VEC3"
},
{
"bufferView": 4,
"componentType": 5123,
"count": 3840,
"max": [
672
],
"min": [
0
],
"type": "SCALAR"
},
{
"bufferView": 5,
"componentType": 5126,
"count": 673,
"max": [
0.5,
0.5,
0.5
],
"min": [
-0.5,
-0.5,
-0.5
],
"type": "VEC3"
},
{
"bufferView": 6,
"componentType": 5126,
"count": 673,
"max": [
0.9999999403953552,
1
],
"min": [
-0.15000003576278687,
0
],
"type": "VEC2"
},
{
"bufferView": 7,
"componentType": 5126,
"count": 673,
"max": [
0.9999998211860657,
1,
1
],
"min": [
-0.9999998211860657,
-1,
-1
],
"type": "VEC3"
}
],
"asset": {
"copyright": "Asset CC0, created by Eric Chadwick and DGG. glTF logo © 2017, Khronos Group.",
"generator": "Created by RapidCompact v6.8.1 | www.rapidcompact.com",
"version": "2.0"
},
"bufferViews": [
{
"buffer": 0,
"byteLength": 7680,
"byteOffset": 0,
"target": 34963
},
{
"buffer": 0,
"byteLength": 8076,
"byteOffset": 7680,
"byteStride": 12,
"target": 34962
},
{
"buffer": 0,
"byteLength": 5384,
"byteOffset": 15756,
"byteStride": 8,
"target": 34962
},
{
"buffer": 0,
"byteLength": 8076,
"byteOffset": 21140,
"byteStride": 12,
"target": 34962
},
{
"buffer": 0,
"byteLength": 7680,
"byteOffset": 29216,
"target": 34963
},
{
"buffer": 0,
"byteLength": 8076,
"byteOffset": 36896,
"byteStride": 12,
"target": 34962
},
{
"buffer": 0,
"byteLength": 5384,
"byteOffset": 44972,
"byteStride": 8,
"target": 34962
},
{
"buffer": 0,
"byteLength": 8076,
"byteOffset": 50356,
"byteStride": 12,
"target": 34962
}
],
"buffers": [
{
"uri": "CompareEmissiveStrength.bin",
"byteLength": 58432
}
],
"extensionsUsed": [
"KHR_materials_emissive_strength"
],
"images": [
{
"uri": "Compare_Emissive-Strength_img0.jpg"
}
],
"materials": [
{
"emissiveFactor": [
1,
1,
1
],
"emissiveTexture": {
"index": 0
},
"name": "glTF Logo Emissive",
"pbrMetallicRoughness": {
"baseColorFactor": [
0,
0,
0,
1
],
"metallicFactor": 0,
"roughnessFactor": 0
}
},
{
"emissiveFactor": [
1,
1,
1
],
"emissiveTexture": {
"index": 0
},
"extensions": {
"KHR_materials_emissive_strength": {
"emissiveStrength": 3
}
},
"name": "glTF Logo Emissive Strength",
"pbrMetallicRoughness": {
"baseColorFactor": [
0,
0,
0,
1
],
"metallicFactor": 0,
"roughnessFactor": 0
}
}
],
"meshes": [
{
"name": "GeoSphere001",
"primitives": [
{
"attributes": {
"NORMAL": 3,
"POSITION": 1,
"TEXCOORD_0": 2
},
"indices": 0,
"material": 0,
"mode": 4
}
]
},
{
"name": "GeoSphere002",
"primitives": [
{
"attributes": {
"NORMAL": 7,
"POSITION": 5,
"TEXCOORD_0": 6
},
"indices": 4,
"material": 1,
"mode": 4
}
]
}
],
"nodes": [
{
"mesh": 0,
"name": "GeoSphere001",
"rotation": [
0.6532815098762512,
-0.27059805393218994,
-0.27059805393218994,
-0.6532815098762512
],
"translation": [
-0.550000011920929,
0,
0
]
},
{
"mesh": 1,
"name": "GeoSphere002",
"rotation": [
0.6532815098762512,
-0.27059805393218994,
-0.27059805393218994,
-0.6532815098762512
],
"translation": [
0.550000011920929,
0,
0
]
}
],
"scene": 0,
"scenes": [
{
"nodes": [
0,
1
]
}
],
"textures": [
{
"source": 0
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 6 additions & 2 deletions examples/render/950-pbr/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ int main(int argc, char** argv)
NORMAL_TENGENT_MIRROR_TEST,
COMPARE_AMBIENT_OCCLUSION,
DAMAGED_HELMET,
COMPARE_EMISSIVE_STRENGTH,
COUNT_EXAMPLES
};

Expand All @@ -44,9 +45,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/CompareEmissiveStrength/CompareEmissiveStrength.gltf"
};

uint selectedExample = METAL_ROUGH_SPHERES;
uint selectedExample = COMPARE_EMISSIVE_STRENGTH;

enum PanoramasExamples {
COLOSSEUM_HDR,
Expand Down Expand Up @@ -120,6 +123,7 @@ int main(int argc, char** argv)
std::cout << " normalScale: " << mat.normalScale() << std::endl;
std::cout << " occlusionStrength: " << mat.occlusionStrength()
<< std::endl;
std::cout << " emissiveStrength: " << mat.emissiveStrength() << std::endl;
printTextureInfo(mat, BASE_COLOR);
printTextureInfo(mat, METALLIC_ROUGHNESS);
printTextureInfo(mat, NORMAL);
Expand Down
15 changes: 15 additions & 0 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,10 @@ int loadGltfPrimitiveMaterial(
bool doubleSided;
int baseColorTextureId, metallicRoughnessTextureId, normalTextureId,
occlusionTextureId, emissiveTextureId;

// extensions data
double emissiveStrength = 1.0f;

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

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

// extensions
if(mat.extensions.contains("KHR_materials_emissive_strength")) {
const auto& emissiveStrengthExt =
mat.extensions.at("KHR_materials_emissive_strength");
if(emissiveStrengthExt.Has("emissiveStrength"))
emissiveStrength = emissiveStrengthExt
.Get("emissiveStrength")
.GetNumberAsDouble();
}

// function to load a texture in a material
auto loadTextureInMaterial = [&](Material& mat,
int textureId,
Expand Down Expand Up @@ -195,6 +209,7 @@ int loadGltfPrimitiveMaterial(
mat.doubleSided() = doubleSided;
mat.normalScale() = normalScale;
mat.occlusionStrength() = occlusionStrength;
mat.emissiveStrength() = emissiveStrength;
loadTextureInMaterial(
mat, baseColorTextureId, Material::TextureType::BASE_COLOR);
loadTextureInMaterial(
Expand Down
Loading
Loading