14#include <tracy/TracyC.h>
15#include <tracy/Tracy.hpp>
34 const std::vector<tinygltf::BufferView> &bufferViews,
35 const std::vector<tinygltf::Accessor>& accessors,
36 const tinygltf::Primitive &primitive) {
37#define EXTRACT_VERTEX_DATA( view, attribKey ) \
39 constexpr const char * positionKey = attribKey; \
40 if ( primitive.attributes.find( attribKey ) != primitive.attributes.end() ) \
42 view.emplace( buffers, bufferViews, accessors.at(primitive.attributes.at( attribKey ))); \
55#undef EXTRACT_VERTEX_DATA
59 throw std::logic_error(
"Not implemented");
69 std::vector<Vertex> vertices;
70 std::vector<uint32_t> indices;
73 for (uint32_t index = 0; index < vertexData.
indexDataView->accessor.count; index++)
75 uint32_t vertexIndex = 0;
77 case TINYGLTF_COMPONENT_TYPE_UNSIGNED_BYTE:
78 vertexIndex =
static_cast<uint32_t
>(
reinterpret_cast<const uint8_t *
>(vertexData.
indexDataView->data)[index]);
80 case TINYGLTF_COMPONENT_TYPE_UNSIGNED_SHORT:
81 vertexIndex =
static_cast<uint32_t
>(
reinterpret_cast<const uint16_t *
>(vertexData.
indexDataView->data)[index]);
83 case TINYGLTF_COMPONENT_TYPE_UNSIGNED_INT:
84 vertexIndex =
reinterpret_cast<const uint32_t *
>( vertexData.
indexDataView->data )[index];
87 PLOGF <<
"Unsupported index type! Type: "
118 vertex.
tangent = glm::vec4(1.0f, 0.0f, 0.0f, 1.0f);
124 vertexData.
uvDataView->data[2 * vertexIndex + 0],
125 vertexData.
uvDataView->data[2 * vertexIndex + 1],
136 vertices.emplace_back( vertex );
137 indices.emplace_back(
static_cast<uint32_t
>(vertices.size()) - 1 );
139 return { vertices, indices };
143 return image != tinygltf::Image();
150 if (vs_extension.Has(
"meshProperties")) {
156 if (vs_extension.Has(
"lightingProperties")) {
162 if (vs_extension.Has(
"lightmapProperties")) {
169 const tinygltf::Value &
meshProperties = extension.Get(
"meshProperties");
174 this->isStatic =
isStatic.Get<
bool>();
180 const tinygltf::Value &lightingProperties = extension.Get(
"lightingProperties");
182 const tinygltf::Value &castShadowsVal = lightingProperties.Get(
"castShadows");
183 const tinygltf::Value &receiveShadowsVal = lightingProperties.Get(
"receiveShadows");
184 const tinygltf::Value &hasLightmapsVal = lightingProperties.Get(
"hasLightmaps");
194 const tinygltf::Value &lightmapProps) {
197 if (lightmapProps.Has(
"lightmapPath")) {
198 const tinygltf::Value &pathVal = lightmapProps.Get(
"lightmapPath");
199 if (pathVal.IsString()) {
202 PLOGE <<
"Lightmap path is not a string. Will return empty string.";
205 PLOGE <<
"Lightmap path not found in lightmapProperties. Will return empty string.";
208 if (lightmapProps.Has(
"lightmapUvIndex")) {
209 const tinygltf::Value &uvIndexVal = lightmapProps.Get(
"lightmapUvIndex");
210 if (uvIndexVal.IsInt()) {
213 PLOGE <<
"Lightmap UV index is not an integer. Will return 0.";
216 PLOGE <<
"Lightmap UV index not found in lightmapProperties. Will return 0.";
237 if (!vs_extension.Has(
"version")) {
238 PLOGE <<
"Version not found in material extension. Will return empty string.";
241 return vs_extension.Get(
"version").Get<std::string>();
245 this->
type = param.Get(
"type").Get<std::string>();
246 this->
socketType = param.Get(
"socketType").Get<std::string>();
249 if (this->
type ==
"value" && param.Has(
"value")) {
250 this->
value = param.Get(
"value");
256 if (vs_extension.Has(
"shaderType")) {
257 this->
shaderType = vs_extension.Get(
"shaderType").Get<std::string>();
259 PLOGE <<
"Shader type not found in material extension. Will default to Normals shader";
265 PLOGI <<
"Loading material extension - Shader Type: " << this->
shaderType;
268 if (vs_extension.Has(
"shaderParameters")) {
269 const tinygltf::Value ¶ms = vs_extension.Get(
"shaderParameters");
270 if (params.IsObject()) {
271 const auto ¶msObj = params.Get<tinygltf::Value::Object>();
272 for (
const auto &[key, value]: paramsObj) {
275 PLOGI <<
" Shader Parameters: " << this->
shaderParameters.size() <<
" parameter(s) loaded";
277 PLOGI <<
" - " << key <<
" [" << param.socketType <<
"]: " << param.type;
283 if (vs_extension.Has(
"nodeProperties")) {
284 const tinygltf::Value &nodeProps = vs_extension.Get(
"nodeProperties");
285 if (nodeProps.IsObject()) {
286 const auto &propsObj = nodeProps.Get<tinygltf::Value::Object>();
287 for (
const auto &[key, value]: propsObj) {
290 this->
nodeProperties[key] =
static_cast<double>(value.Get<
int>());
291 }
else if (value.IsReal()) {
295 PLOGI <<
" Node Properties: " << this->
nodeProperties.size() <<
" property(ies) loaded";
297 PLOGI <<
" - " << key <<
": " << val;
303 if (vs_extension.Has(
"customProperties")) {
304 const tinygltf::Value &customProps = vs_extension.Get(
"customProperties");
305 if (customProps.IsObject()) {
306 const auto &customObj = customProps.Get<tinygltf::Value::Object>();
307 for (
const auto &[key, value]: customObj) {
310 PLOGI <<
" Custom Properties: " << this->
customProperties.size() <<
" property(ies) loaded";
316 if (material.find(
"VULKAN_SCHNEE_materials") != material.end()) {
319 PLOGI <<
" No VULKAN_SCHNEE_materials extension found in material";
336 if (extensions.find(
"VULKAN_SCHNEE_engine_properties") != extensions.end()) {
339 PLOGI <<
" No VULKAN_SCHNEE_engine_properties extension found in mesh";
347 PLOGI <<
"Loading material: " <<
material.name;
351 PLOGI <<
" Material has Vulkan Schnee extension";
353 PLOGI <<
" Material has no extensions, using default shader";
360 const std::vector<double> baseColor =
material.pbrMetallicRoughness.baseColorFactor;
361 if (!baseColor.empty()) {
362 if (baseColor.size() < 4)
363 throw std::runtime_error(
"Tried to load a color which was not rgba!");
376 if (vulkanSchneeExtension.hasLightmapProperties()
377 && vulkanSchneeExtension.lightProperties.value().getHasLightmaps()
378 && vulkanSchneeExtension.lightmapProperties.value().isLightmapPathValid()
380 const auto &lightMapSettings = vulkanSchneeExtension.lightmapProperties.value();
388 PLOGI <<
"Loaded lightmap texture from: " <<
lightmapPath;
394 const tinygltf::TextureInfo &textureInfo =
material.pbrMetallicRoughness.baseColorTexture;
395 if (textureInfo.index != -1) {
396 const tinygltf::Texture &texture = model.textures[textureInfo.index];
397 const tinygltf::Image &image = model.images[texture.source];
405 const tinygltf::TextureInfo &textureInfo =
material.pbrMetallicRoughness.baseColorTexture;
406 if (textureInfo.index != -1) {
407 const tinygltf::Texture &texture = model.textures[textureInfo.index];
408 const tinygltf::Image &image = model.images[texture.source];
418 PLOGI <<
"Mesh has no vulkan schnee extension in exported mesh data";
429 const auto& metallicRoughnessTexture =
material.pbrMetallicRoughness.metallicRoughnessTexture;
430 if (metallicRoughnessTexture.index != -1) {
432 const tinygltf::Texture& texture = model.textures[metallicRoughnessTexture.index];
433 if (texture.source >= 0 && texture.source <
static_cast<int>(model.images.size())) {
435 PLOGD <<
" Metallic/roughness texture extracted (GLTF index " << metallicRoughnessTexture.index
436 <<
", image source " << texture.source <<
")";
441 if (
material.normalTexture.index != -1) {
444 const tinygltf::Texture& texture = model.textures[
material.normalTexture.index];
445 if (texture.source >= 0 && texture.source <
static_cast<int>(model.images.size())) {
447 PLOGD <<
" Normal texture extracted (GLTF index " <<
material.normalTexture.index
448 <<
", image source " << texture.source <<
", scale " <<
normalScale <<
")";
453 if (
material.emissiveTexture.index != -1) {
455 const tinygltf::Texture& texture = model.textures[
material.emissiveTexture.index];
456 if (texture.source >= 0 && texture.source <
static_cast<int>(model.images.size())) {
458 PLOGD <<
" Emissive texture extracted (GLTF index " <<
material.emissiveTexture.index
459 <<
", image source " << texture.source <<
")";
464 const auto& emissive =
material.emissiveFactor;
465 if (emissive.size() >= 3) {
467 static_cast<float>(emissive[0]),
468 static_cast<float>(emissive[1]),
469 static_cast<float>(emissive[2])
480 return textureIndex != std::numeric_limits<uint32_t>::max();
498 throw std::runtime_error(
"Material does not have Vulkan Schnee extension");
508 return "diffuseFlatColor";
519 PLOGI <<
"setupMaterialData: No material extensions, defaulting to NormalMaterialData";
525 PLOGI <<
"setupMaterialData: No vulkan schnee material extension, defaulting to NormalMaterialData";
531 PLOGI <<
"setupMaterialData: shaderType=" << ext.
shaderType
532 <<
", materialName=" <<
static_cast<int>(ext.
materialName)
535#define MATCH_MATERIAL(name, type, ...) \
536 if (ext.materialName == PipelineNames::name) { \
537 materialData = type(__VA_ARGS__); \
541 auto shaderParams =
materialExtensions->vulkanSchneeMaterialExtension->shaderParameters;
543 const auto it = shaderParams.find(
"Color");
544 std::array<float, 4> colors{};
545 if (it != shaderParams.end()) {
546 const auto arr = it->second.value.Get<tinygltf::Value::Array>();
548 static_cast<float>(arr[0].GetNumberAsDouble()),
549 static_cast<float>(arr[1].GetNumberAsDouble()),
550 static_cast<float>(arr[2].GetNumberAsDouble()),
551 static_cast<float>(arr[3].GetNumberAsDouble())
560 glm::vec3 diffuseColor;
562 bool colorParamValid = (it != shaderParams.end()) && (colors[0] != 0.0f || colors[1] != 0.0f || colors[2] != 0.0f);
563 if (colorParamValid) {
564 diffuseColor = {colors[0], colors[1], colors[2]};
565 PLOGI <<
"FLAT_COLOR using shader Color param: " << diffuseColor.r <<
", " << diffuseColor.g <<
", " << diffuseColor.b;
569 PLOGI <<
"FLAT_COLOR using baseColorFactor fallback: " << diffuseColor.r <<
", " << diffuseColor.g <<
", " << diffuseColor.b
570 <<
" (Color param " << (it != shaderParams.end() ?
"was zero" :
"not found") <<
")";
580 float shScale = 0.15f;
581 float ambientTerm = 0.1f;
582 uint32_t debugMode = 0;
583 uint32_t toneMapping = 0;
590 toneMapping =
static_cast<uint32_t
>(ext.
nodeProperties.at(
"tone_mapping"));
604 float lightmapAmbientTerm = ext.
nodeProperties.count(
"ambient_term")
605 ? ambientTerm : 1.0f;
622 PLOGI <<
"Created StaticLightmapMaterialData with baseColorTex=" << texIndex
623 <<
" (normalTex not loaded - PBR texture loading not yet implemented)";
628 PLOGW <<
"setupMaterialData: No material type matched for materialName="
630 <<
". Defaulting to NormalMaterialData.";
646 int uvCoordinateAccessorIndex;
648 vkScExtension.has_value()
649 && vkScExtension->hasLightProperties()
650 && vkScExtension->lightProperties->getHasLightmaps()
651 && vkScExtension->hasLightmapProperties()) {
652 const uint32_t lightmapIndex = meshSettings.
vulkanSchneeExtension.value().lightmapProperties.value().
654 std::stringstream strStream;
655 strStream <<
"TEXCOORD_" << lightmapIndex;
656 uvCoordinateAccessorIndex =
primitive.attributes.find(strStream.str())->second;
658 uvCoordinateAccessorIndex =
primitive.attributes.find(
"TEXCOORD_0")->second;
661 if (!(model.accessors.size() >
static_cast<size_t>(uvCoordinateAccessorIndex) && uvCoordinateAccessorIndex != -
663 PLOGE <<
"Failed to load UV coordinate accessor";
665 const int &positionAccessorIndex =
primitive.attributes.find(
"POSITION")->second;
666 if (!(model.accessors.size() >
static_cast<size_t>(positionAccessorIndex) && positionAccessorIndex >= 0)) {
667 PLOGE <<
"Failed to load position accessor";
671 bool hasNormals =
false;
672 const float *vertexNormals =
nullptr;
673 auto normalAttributeIt =
primitive.attributes.find(
"NORMAL");
674 if (normalAttributeIt !=
primitive.attributes.end()) {
675 int normalAccessorIndex = normalAttributeIt->second;
676 if (model.accessors.size() >
static_cast<size_t>(normalAccessorIndex) && normalAccessorIndex >= 0) {
677 const tinygltf::Accessor &normalAccessor = model.accessors[normalAccessorIndex];
678 const tinygltf::BufferView &normalBufferView = model.bufferViews[normalAccessor.bufferView];
679 const tinygltf::Buffer &normalBuffer = model.buffers[normalBufferView.buffer];
680 vertexNormals =
reinterpret_cast<const float *
>(
681 &normalBuffer.data[normalBufferView.byteOffset + normalAccessor.byteOffset]);
683 PLOGI <<
"NORMAL attribute found and loaded.";
685 PLOGW <<
"NORMAL attribute found but accessor invalid.";
688 PLOGW <<
"NORMAL attribute NOT found. Normals will be (0.0, 0.0, 0.0).";
690 const tinygltf::Accessor &accessor = model.accessors[uvCoordinateAccessorIndex];
691 if (accessor.componentType != TINYGLTF_COMPONENT_TYPE_FLOAT || accessor.type != TINYGLTF_TYPE_VEC2) {
692 PLOGE <<
"UV coordinates are not in supported format";
694 const tinygltf::BufferView &bufferView = model.bufferViews[accessor.bufferView];
695 const tinygltf::Buffer &buffer = model.buffers[bufferView.buffer];
697 const float *uvData =
reinterpret_cast<const float *
>(&buffer.data[
698 bufferView.byteOffset + accessor.byteOffset]);
700 const tinygltf::Accessor &positionAccessor = model.accessors[positionAccessorIndex];
701 const tinygltf::BufferView &positionBufferView = model.bufferViews[positionAccessor.bufferView];
702 const tinygltf::Buffer &positionBuffer = model.buffers[positionBufferView.buffer];
703 const float *vertexPositions =
reinterpret_cast<const float *
>(
704 &positionBuffer.data[positionBufferView.byteOffset + positionAccessor.byteOffset]);
707 const tinygltf::Accessor &indexAccessor = model.accessors[
primitive.indices];
708 const tinygltf::BufferView &indexBufferView = model.bufferViews[indexAccessor.bufferView];
709 const tinygltf::Buffer &indexBuffer = model.buffers[indexBufferView.buffer];
710 const void *indexDataPointer =
711 static_cast<const void *
>(&indexBuffer.data[indexBufferView.byteOffset + indexAccessor.byteOffset]);
714 for (
size_t i = 0u; i < indexAccessor.count; i++) {
715 uint32_t vertexIndex = 0;
716 switch (indexAccessor.componentType) {
717 case TINYGLTF_COMPONENT_TYPE_UNSIGNED_BYTE:
718 vertexIndex =
static_cast<uint32_t
>(
reinterpret_cast<const uint8_t *
>(indexDataPointer)[i]);
720 case TINYGLTF_COMPONENT_TYPE_UNSIGNED_SHORT:
721 vertexIndex =
static_cast<uint32_t
>(
reinterpret_cast<const uint16_t *
>(indexDataPointer)[i]);
723 case TINYGLTF_COMPONENT_TYPE_UNSIGNED_INT:
724 vertexIndex =
reinterpret_cast<const uint32_t *
>(indexDataPointer)[i];
727 PLOGF <<
"Unsupported index type! Type: " << indexAccessor.componentType;
731 vertexPositions[3 * vertexIndex + 0], vertexPositions[3 * vertexIndex + 1],
732 vertexPositions[3 * vertexIndex + 2], 0.0f
736 uvData[2 * vertexIndex + 1]
741 vertex.
normal = glm::vec4(
742 vertexNormals[3 * vertexIndex + 0], vertexNormals[3 * vertexIndex + 1],
743 vertexNormals[3 * vertexIndex + 2], 0.0f
746 vertex.
normal = glm::vec4(0.0f);
776 const tinygltf::Node &node,
const glm::mat4 &
transform) {
780 this->
name = node.name;
784 primitives.resize(this->mesh.primitives.size());
785 for (uint32_t i = 0u; i < this->mesh.primitives.size(); i++) {
791 const tinygltf::Value &hasLightMap = extras.Get(
"HasLightmaps");
794 const tinygltf::Value &lightMapPathValue = extras.Get(
"LightMapPath");
795 lightMapPath = std::filesystem::path(lightMapPathValue.Get<std::string>());
797 const tinygltf::Value &lightMapUvIndexValue = extras.Get(
"LightMapUvIndex");
801 void GltfLoader::load(
const std::filesystem::path &path, std::vector<GltfMeshData> &meshes)
const {
805 const size_t nodeCount = model.nodes.size();
806 std::vector<GltfMeshData> meshList;
807 meshList.reserve(nodeCount);
811 for (
const tinygltf::Node &node: model.nodes) {
822 if (!node.translation.empty()) {
824 const auto translation = glm::vec3(node.translation[0], node.translation[1], node.translation[2]);
825 transform.setLocation(translation);
828 if (!node.rotation.empty()) {
830 const auto rotation = glm::quat(node.rotation[3], node.rotation[0], node.rotation[1],
832 transform.setRotationQuat(rotation);
835 if (!node.scale.empty()) {
836 const auto scale = glm::vec3(node.scale[0], node.scale[1], node.scale[2]);
837 transform.setScale(scale);
841 const GltfMeshData data(model, model.meshes[node.mesh], node, transform.toMatrix());
843 meshes.push_back(data);
851 tinygltf::Model model;
852 tinygltf::TinyGLTF loader;
854 std::string warning{};
856 loader.SetStoreOriginalJSONForExtrasAndExtensions(
true); {
859 if (!loader.LoadASCIIFromFile(&model, &error, &warning, path.generic_string())) {
860 std::stringstream errorStream{};
861 errorStream <<
"Failed to load mesh: " << path.generic_string() <<
" with gltf loading error: " << error;
862 throw std::runtime_error(errorStream.str());
864 if (!error.empty()) {
865 PLOGE_ASSET <<
"Failed to load mesh: " << path.generic_string() <<
" with error: " << error;
867 if (!warning.empty()) {
868 PLOGE_ASSET <<
"Loaded asset " << path.generic_string() <<
" with warnings " << warning;
877 tinygltf::TinyGLTF loader;
881 auto noOpImageLoader = [](tinygltf::Image* image,
const int image_idx, std::string* err,
882 std::string* warn,
int width,
int height,
883 const unsigned char* data,
int size,
void* user_data) ->
bool {
887 loader.SetImageLoader(noOpImageLoader,
nullptr);
888 loader.SetStoreOriginalJSONForExtrasAndExtensions(
true);
890 tinygltf::Model model;
891 std::string error, warning;
892 if (!loader.LoadASCIIFromFile(&model, &error, &warning, path.generic_string())) {
893 PLOGE <<
"Failed to load mesh: " << path.generic_string();
895 if (!error.empty()) {
896 PLOGE <<
"Error loading mesh: " << error;
898 if (!warning.empty()) {
899 PLOGW <<
"Warning loading mesh: " << warning;
908 tinygltf::TinyGLTF loader;
911 loader.SetParseStages(tinygltf::PARSE_NODES_ONLY);
913 tinygltf::Model model;
914 std::string error, warning;
916 const std::string pathStr = path.generic_string();
917 const std::string ext = path.extension().string();
919 bool success =
false;
920 if (ext ==
".glb" || ext ==
".GLB") {
921 success = loader.LoadBinaryFromFile(&model, &error, &warning, pathStr);
923 success = loader.LoadASCIIFromFile(&model, &error, &warning, pathStr);
927 PLOGE <<
"Failed to load GLTF metadata: " << path.generic_string();
929 if (!error.empty()) {
930 PLOGE <<
"Error loading GLTF metadata: " << error;
932 if (!warning.empty()) {
933 PLOGW <<
"Warning loading GLTF metadata: " << warning;
#define EXTRACT_VERTEX_DATA(view, attribKey)
#define MATCH_MATERIAL(name, type,...)
constexpr EngineCore::PipelineNames DEFAULT_MATERIAL_PIPELINE
#define TRACY_LOCKABLE(type, varname, desc)
#define TRACY_ZONE_SCOPED_NAMED(name)
Material data for an Object which displays a flat color.
Dynamic textures material with PBR and lightmap support.
Loader for EXR (OpenEXR) image files.
tinygltf::Image load(const std::filesystem::path &filename)
Load a complete EXR image file.
tinygltf::Model loadMetadataOnly(const std::filesystem::path &path) const
Loads only the GLTF metadata (nodes, names, transforms) without loading buffer data.
void load(const std::filesystem::path &path, std::vector< GltfMeshData > &meshes) const
Loads a vector of meshes from a gltf file.
std::optional< tinygltf::Model > loadModel(const std::filesystem::path &path) const
tinygltf::Model loadAsync(const std::filesystem::path &path) const
NamedThreadPool * threadPool
Ecs::PrimitiveData loadPrimitiveData(GltfVertexData vertexData)
GltfLoader(NamedThreadPool *threadPool=nullptr)
std::vector< Vertex > getPrimitiveVertices(const tinygltf::Primitive &primitive)
L1 Spherical Harmoics shader.
Moveable diffuse shader with PBR and lightmap support.
Material data for an object which displays its normals.
Static lightmap material with PBR support.
Tracy-named thread pool using BS_tracy::tracy_thread_pool.
Log category system implementation.
T UnpackOptional(std::optional< T > var)
const tinygltf::Accessor & accessor
const tinygltf::Buffer & buffer
const tinygltf::BufferView & bufferView
GltfBufferDataView(const std::vector< tinygltf::Buffer > &buffers, const std::vector< tinygltf::BufferView > &bufferViews, const tinygltf::Accessor &accessor)
Stores the material data which is relevant for our current set of shaders.
void parsePbrData(const tinygltf::Model &model, const tinygltf::Material &material)
int32_t gltfMetallicRoughnessTextureIndex
std::string getShaderName() const
uint32_t getTextureIndex() const
bool hasVulkanSchneeExtension() const
GltfTextureData lightmapTextureData
const VulkanSchneeMaterialExtension & getVulkanSchneeExtension() const
GltfTextureData metallicRoughnessTextureData
GltfTextureData normalTextureData
std::variant< NormalMaterialData, DiffuseFlatColorMaterialData, DiffuseShaderMaterialData, MovableDiffuseShaderMaterialData, L0ShaderMaterialData, L1ShaderMaterialData, L2ShaderMaterialData, DynamicTexturesMaterialData, StaticLightmapMaterialData > materialData
GltfMaterialData()=default
GltfTextureData getTextureData() const
std::filesystem::path lightmapPath
GltfTextureData emissiveTextureData
glm::vec4 baseColorFactor
uint32_t normalTextureIndex
tinygltf::Material material
int32_t gltfNormalTextureIndex
int32_t gltfEmissiveTextureIndex
std::variant< NormalMaterialData, DiffuseFlatColorMaterialData, DiffuseShaderMaterialData, MovableDiffuseShaderMaterialData, L0ShaderMaterialData, L1ShaderMaterialData, L2ShaderMaterialData, DynamicTexturesMaterialData, StaticLightmapMaterialData > getMaterialDataRaw() const
GltfTextureData textureData
std::optional< MaterialExtensions > materialExtensions
GltfMeshData(const tinygltf::Model &model, const tinygltf::Mesh &mesh, const tinygltf::Node &node, const glm::mat4 &transform)
std::vector< GltfMeshPrimitiveData > primitives
Stores intermediate data from loading the asset from disk. These are the vertices,...
std::vector< Vertex > vertices
std::vector< uint32_t > indices
Texture * colorTexturePtr
GltfMaterialData getMaterialData() const
std::vector< uint32_t > getIndices() const
Gets the raw unprocessed list of all indices.
GltfMeshPrimitiveData()=default
std::vector< Vertex > getVertices() const
Gets a list of all unprocessed vertices of this primtitive.
uint32_t getColorTextureIndex() const
tinygltf::Primitive primitive
Texture * getColorTexturePtr() const
Gets the pointer to the primitive of the color texture. This is only a valid pointer after it has bee...
GltfMaterialData materialData
bool hasTextureData() const
std::optional< GltfBufferDataView > positionDataView
GltfVertexData(const std::vector< tinygltf::Buffer > &buffers, const std::vector< tinygltf::BufferView > &bufferViews, const std::vector< tinygltf::Accessor > &accessors, const tinygltf::Primitive &primitive)
std::optional< GltfBufferDataView > normalDataView
std::optional< GltfBufferDataView > indexDataView
std::optional< GltfBufferDataView > lightmapDataView
std::optional< GltfBufferDataView > uvDataView
std::optional< GltfBufferDataView > tangentDataView
Stores all material extensions. So if another extension for some kind of specific material attribute ...
MaterialExtensions()=default
std::optional< VulkanSchneeMaterialExtension > vulkanSchneeMaterialExtension
Parses all extensions and extracts recognized extensions.
StaticMeshExtensions()=default
std::optional< VulkanSchneeExtension > vulkanSchneeExtension
StaticMeshSettings()=default
std::filesystem::path lightMapPath
std::filesystem::path lightmapPath
bool isLightmapPathValid() const
LightmapProperties(const tinygltf::Value &extension)
stores all properties related to lighting information
bool getReceiveShadows() const
LightProperties(const tinygltf::Value &extension)
bool getHasLightmaps() const
bool getCastShadows() const
Stores the mesh information like if it is a static object and if it simulates physics.
MeshProperties(const tinygltf::Value &extension)
The vulkan schnee extension for gltf files stores all data related to the engines core functionality.
std::optional< LightProperties > lightProperties
std::optional< MeshProperties > meshProperties
bool hasLightProperties() const
bool hasLightmapProperties() const
static std::string extractVersion(const tinygltf::Value &vs_extension)
Extracts the version from the material extension.
VulkanSchneeExtension()=default
bool hasMeshProperties() const
std::optional< LightProperties::LightmapProperties > lightmapProperties
Represents a single shader parameter that can be either connected or a direct value.
ShaderParameter(const tinygltf::Value ¶m)
Extracts all material data from the gltf file. All data during runtime will be read from an object of...
VulkanSchneeMaterialExtension()=default
PipelineNames materialName
std::map< std::string, double > nodeProperties
std::map< std::string, tinygltf::Value > customProperties
std::map< std::string, ShaderParameter > shaderParameters
static std::string getPipelineNameFromString(PipelineNames pipelineName)
Gets the pipeline name as string.
The fundamental building block of all meshes in this engine.
glm::vec2 lightmapUvCoordinate
glm::vec2 textureCoordinate