From f62857b6b67229abf6868fa95d0ea997d617c2de Mon Sep 17 00:00:00 2001 From: Janine Liu Date: Thu, 1 Feb 2024 17:37:13 -0500 Subject: [PATCH] Cleanup code --- .../src/UnityPrepareRendererResources.cpp | 131 +----------------- 1 file changed, 7 insertions(+), 124 deletions(-) diff --git a/native~/Runtime/src/UnityPrepareRendererResources.cpp b/native~/Runtime/src/UnityPrepareRendererResources.cpp index d973f526..87e380f2 100644 --- a/native~/Runtime/src/UnityPrepareRendererResources.cpp +++ b/native~/Runtime/src/UnityPrepareRendererResources.cpp @@ -1007,9 +1007,15 @@ void setGltfMaterialParameterValues( const CesiumGltf::Model& model, const CesiumPrimitiveInfo& primitiveInfo, const CesiumGltf::Material& gltfMaterial, - const CesiumGltf::MaterialPBRMetallicRoughness& pbr, const UnityEngine::Material& unityMaterial, const CesiumShaderProperties& shaderProperties) { + CESIUM_TRACE("Cesium::CreateMaterials"); + + const CesiumGltf::MaterialPBRMetallicRoughness& pbr = + gltfMaterial.pbrMetallicRoughness + ? gltfMaterial.pbrMetallicRoughness.value() + : defaultPbrMetallicRoughness; + // Add base color factor and metallic-roughness factor regardless // of whether the textures are present. const std::vector& baseColorFactor = pbr.baseColorFactor; @@ -1443,133 +1449,10 @@ void* UnityPrepareRendererResources::prepareInMainThread( meshRenderer.material(material); if (pMaterial) { - CESIUM_TRACE("Cesium::CreateMaterials"); - - const CesiumGltf::MaterialPBRMetallicRoughness& pbr = - pMaterial->pbrMetallicRoughness - ? pMaterial->pbrMetallicRoughness.value() - : defaultPbrMetallicRoughness; - - //// Add base color factor and metallic-roughness factor regardless - //// of whether the textures are present. - // const std::vector& baseColorFactor = pbr.baseColorFactor; - // material.SetVector( - // shaderProperties.getBaseColorFactorID(), - // gltfVectorToUnityVector(baseColorFactor, 1.0f)); - - // UnityEngine::Vector4 metallicRoughnessFactor; - // material.SetVector( - // shaderProperties.getMetallicRoughnessFactorID(), - // {(float)pbr.metallicFactor, (float)pbr.roughnessFactor, 0, 0}); - - // const std::optional& baseColorTexture = - // pbr.baseColorTexture; - // if (baseColorTexture) { - // auto texCoordIndexIt = - // primitiveInfo.uvIndexMap.find(baseColorTexture->texCoord); - // if (texCoordIndexIt != primitiveInfo.uvIndexMap.end()) { - // UnityEngine::Texture texture = - // TextureLoader::loadTexture(gltf, baseColorTexture->index); - // if (texture != nullptr) { - // material.SetTexture( - // shaderProperties.getBaseColorTextureID(), - // texture); - // material.SetFloat( - // shaderProperties.getBaseColorTextureCoordinateIndexID(), - // static_cast(texCoordIndexIt->second)); - // } - // } - //} - - // const std::optional& metallicRoughness = - // pbr.metallicRoughnessTexture; - // if (metallicRoughness) { - // auto texCoordIndexIt = - // primitiveInfo.uvIndexMap.find(metallicRoughness->texCoord); - // if (texCoordIndexIt != primitiveInfo.uvIndexMap.end()) { - // UnityEngine::Texture texture = - // TextureLoader::loadTexture(gltf, metallicRoughness->index); - // if (texture != nullptr) { - // material.SetTexture( - // shaderProperties.getMetallicRoughnessTextureID(), - // texture); - // material.SetFloat( - // shaderProperties - // .getMetallicRoughnessTextureCoordinateIndexID(), - // static_cast(texCoordIndexIt->second)); - // } - // } - //} - - // if (pMaterial->normalTexture) { - // auto texCoordIndexIt = primitiveInfo.uvIndexMap.find( - // pMaterial->normalTexture->texCoord); - // if (texCoordIndexIt != primitiveInfo.uvIndexMap.end()) { - // UnityEngine::Texture texture = TextureLoader::loadTexture( - // gltf, - // pMaterial->normalTexture->index); - // if (texture != nullptr) { - // material.SetTexture( - // shaderProperties.getNormalMapTextureID(), - // texture); - // material.SetFloat( - // shaderProperties.getNormalMapTextureCoordinateIndexID(), - // static_cast(texCoordIndexIt->second)); - // material.SetFloat( - // shaderProperties.getNormalMapScaleID(), - // static_cast(pMaterial->normalTexture->scale)); - // } - // } - //} - - // if (pMaterial->occlusionTexture) { - // auto texCoordIndexIt = primitiveInfo.uvIndexMap.find( - // pMaterial->occlusionTexture->texCoord); - // if (texCoordIndexIt != primitiveInfo.uvIndexMap.end()) { - // UnityEngine::Texture texture = TextureLoader::loadTexture( - // gltf, - // pMaterial->occlusionTexture->index); - // if (texture != nullptr) { - // material.SetTexture( - // shaderProperties.getOcclusionTextureID(), - // texture); - // material.SetFloat( - // shaderProperties.getOcclusionTextureCoordinateIndexID(), - // static_cast(texCoordIndexIt->second)); - // material.SetFloat( - // shaderProperties.getOcclusionStrengthID(), - // static_cast(pMaterial->occlusionTexture->strength)); - // } - // } - //} - - // const std::vector& emissiveFactor = - // pMaterial->emissiveFactor; material.SetVector( - // shaderProperties.getEmissiveFactorID(), - // gltfVectorToUnityVector(emissiveFactor, 0.0f)); - // if (pMaterial->emissiveTexture) { - // auto texCoordIndexIt = primitiveInfo.uvIndexMap.find( - // pMaterial->emissiveTexture->texCoord); - // if (texCoordIndexIt != primitiveInfo.uvIndexMap.end()) { - // UnityEngine::Texture texture = TextureLoader::loadTexture( - // gltf, - // pMaterial->emissiveTexture->index); - // if (texture != nullptr) { - // material.SetTexture( - // shaderProperties.getEmissiveTextureID(), - // texture); - // material.SetFloat( - // shaderProperties.getEmissiveTextureCoordinateIndexID(), - // static_cast(texCoordIndexIt->second)); - // } - // } - //} - setGltfMaterialParameterValues( gltf, primitiveInfo, *pMaterial, - pbr, material, shaderProperties); }