mirror of
https://github.com/lubosz/overte.git
synced 2025-04-07 15:22:09 +02:00
(✿◠‿◠)
This commit is contained in:
parent
3eac2cf1d6
commit
de90c5088c
15 changed files with 230 additions and 192 deletions
|
@ -1325,7 +1325,7 @@ void ModelEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce
|
|||
|
||||
// Check for addition
|
||||
if (_hasModel && !model) {
|
||||
model = std::make_shared<Model>(nullptr, entity.get());
|
||||
model = std::make_shared<Model>(nullptr, entity.get(), _created);
|
||||
connect(model.get(), &Model::requestRenderUpdate, this, &ModelEntityRenderer::requestRenderUpdate);
|
||||
connect(model.get(), &Model::setURLFinished, this, [&](bool didVisualGeometryRequestSucceed) {
|
||||
setKey(didVisualGeometryRequestSucceed);
|
||||
|
|
|
@ -64,6 +64,7 @@ namespace scriptable {
|
|||
* @property {string} lightmapParams
|
||||
* @property {string} materialParams
|
||||
* @property {boolean} defaultFallthrough
|
||||
* @property {string} procedural
|
||||
*/
|
||||
class ScriptableMaterial {
|
||||
public:
|
||||
|
@ -98,6 +99,8 @@ namespace scriptable {
|
|||
bool defaultFallthrough;
|
||||
std::unordered_map<uint, bool> propertyFallthroughs; // not actually exposed to script
|
||||
|
||||
QString procedural;
|
||||
|
||||
graphics::MaterialKey key { 0 };
|
||||
};
|
||||
|
||||
|
|
|
@ -372,120 +372,125 @@ namespace scriptable {
|
|||
obj.setProperty("opacity", material.opacity);
|
||||
}
|
||||
|
||||
if (hasPropertyFallthroughs && material.propertyFallthroughs.at(graphics::MaterialKey::GLOSSY_VAL_BIT)) {
|
||||
obj.setProperty("roughness", FALLTHROUGH);
|
||||
} else if (material.key.isGlossy()) {
|
||||
obj.setProperty("roughness", material.roughness);
|
||||
}
|
||||
|
||||
if (hasPropertyFallthroughs && material.propertyFallthroughs.at(graphics::MaterialKey::METALLIC_VAL_BIT)) {
|
||||
obj.setProperty("metallic", FALLTHROUGH);
|
||||
} else if (material.key.isMetallic()) {
|
||||
obj.setProperty("metallic", material.metallic);
|
||||
}
|
||||
|
||||
if (hasPropertyFallthroughs && material.propertyFallthroughs.at(graphics::MaterialKey::SCATTERING_VAL_BIT)) {
|
||||
obj.setProperty("scattering", FALLTHROUGH);
|
||||
} else if (material.key.isScattering()) {
|
||||
obj.setProperty("scattering", material.scattering);
|
||||
}
|
||||
|
||||
if (hasPropertyFallthroughs && material.propertyFallthroughs.at(graphics::MaterialKey::UNLIT_VAL_BIT)) {
|
||||
obj.setProperty("unlit", FALLTHROUGH);
|
||||
} else if (material.key.isUnlit()) {
|
||||
obj.setProperty("unlit", material.unlit);
|
||||
}
|
||||
|
||||
if (hasPropertyFallthroughs && material.propertyFallthroughs.at(graphics::MaterialKey::EMISSIVE_VAL_BIT)) {
|
||||
obj.setProperty("emissive", FALLTHROUGH);
|
||||
} else if (material.key.isEmissive()) {
|
||||
obj.setProperty("emissive", vec3ColorToScriptValue(engine, material.emissive));
|
||||
}
|
||||
|
||||
if (hasPropertyFallthroughs && material.propertyFallthroughs.at(graphics::MaterialKey::ALBEDO_VAL_BIT)) {
|
||||
obj.setProperty("albedo", FALLTHROUGH);
|
||||
} else if (material.key.isAlbedo()) {
|
||||
obj.setProperty("albedo", vec3ColorToScriptValue(engine, material.albedo));
|
||||
}
|
||||
|
||||
if (hasPropertyFallthroughs && material.propertyFallthroughs.at(graphics::MaterialKey::EMISSIVE_MAP_BIT)) {
|
||||
obj.setProperty("emissiveMap", FALLTHROUGH);
|
||||
} else if (!material.emissiveMap.isEmpty()) {
|
||||
obj.setProperty("emissiveMap", material.emissiveMap);
|
||||
}
|
||||
if (material.model.toStdString() == graphics::Material::HIFI_PBR) {
|
||||
if (hasPropertyFallthroughs && material.propertyFallthroughs.at(graphics::MaterialKey::GLOSSY_VAL_BIT)) {
|
||||
obj.setProperty("roughness", FALLTHROUGH);
|
||||
} else if (material.key.isGlossy()) {
|
||||
obj.setProperty("roughness", material.roughness);
|
||||
}
|
||||
|
||||
if (hasPropertyFallthroughs && material.propertyFallthroughs.at(graphics::MaterialKey::ALBEDO_MAP_BIT)) {
|
||||
obj.setProperty("albedoMap", FALLTHROUGH);
|
||||
} else if (!material.albedoMap.isEmpty()) {
|
||||
obj.setProperty("albedoMap", material.albedoMap);
|
||||
}
|
||||
if (hasPropertyFallthroughs && material.propertyFallthroughs.at(graphics::MaterialKey::METALLIC_VAL_BIT)) {
|
||||
obj.setProperty("metallic", FALLTHROUGH);
|
||||
} else if (material.key.isMetallic()) {
|
||||
obj.setProperty("metallic", material.metallic);
|
||||
}
|
||||
|
||||
if (!material.opacityMap.isEmpty()) {
|
||||
obj.setProperty("opacityMap", material.opacityMap);
|
||||
}
|
||||
if (hasPropertyFallthroughs && material.propertyFallthroughs.at(graphics::MaterialKey::SCATTERING_VAL_BIT)) {
|
||||
obj.setProperty("scattering", FALLTHROUGH);
|
||||
} else if (material.key.isScattering()) {
|
||||
obj.setProperty("scattering", material.scattering);
|
||||
}
|
||||
|
||||
if (hasPropertyFallthroughs && material.propertyFallthroughs.at(graphics::MaterialKey::OCCLUSION_MAP_BIT)) {
|
||||
obj.setProperty("occlusionMap", FALLTHROUGH);
|
||||
} else if (!material.occlusionMap.isEmpty()) {
|
||||
obj.setProperty("occlusionMap", material.occlusionMap);
|
||||
}
|
||||
if (hasPropertyFallthroughs && material.propertyFallthroughs.at(graphics::MaterialKey::UNLIT_VAL_BIT)) {
|
||||
obj.setProperty("unlit", FALLTHROUGH);
|
||||
} else if (material.key.isUnlit()) {
|
||||
obj.setProperty("unlit", material.unlit);
|
||||
}
|
||||
|
||||
if (hasPropertyFallthroughs && material.propertyFallthroughs.at(graphics::MaterialKey::LIGHTMAP_MAP_BIT)) {
|
||||
obj.setProperty("lightmapMap", FALLTHROUGH);
|
||||
} else if (!material.lightmapMap.isEmpty()) {
|
||||
obj.setProperty("lightmapMap", material.lightmapMap);
|
||||
}
|
||||
if (hasPropertyFallthroughs && material.propertyFallthroughs.at(graphics::MaterialKey::EMISSIVE_VAL_BIT)) {
|
||||
obj.setProperty("emissive", FALLTHROUGH);
|
||||
} else if (material.key.isEmissive()) {
|
||||
obj.setProperty("emissive", vec3ColorToScriptValue(engine, material.emissive));
|
||||
}
|
||||
|
||||
if (hasPropertyFallthroughs && material.propertyFallthroughs.at(graphics::MaterialKey::SCATTERING_MAP_BIT)) {
|
||||
obj.setProperty("scatteringMap", FALLTHROUGH);
|
||||
} else if (!material.scatteringMap.isEmpty()) {
|
||||
obj.setProperty("scatteringMap", material.scatteringMap);
|
||||
}
|
||||
if (hasPropertyFallthroughs && material.propertyFallthroughs.at(graphics::MaterialKey::EMISSIVE_MAP_BIT)) {
|
||||
obj.setProperty("emissiveMap", FALLTHROUGH);
|
||||
} else if (!material.emissiveMap.isEmpty()) {
|
||||
obj.setProperty("emissiveMap", material.emissiveMap);
|
||||
}
|
||||
|
||||
// Only set one of each of these
|
||||
if (hasPropertyFallthroughs && material.propertyFallthroughs.at(graphics::MaterialKey::METALLIC_MAP_BIT)) {
|
||||
obj.setProperty("metallicMap", FALLTHROUGH);
|
||||
} else if (!material.metallicMap.isEmpty()) {
|
||||
obj.setProperty("metallicMap", material.metallicMap);
|
||||
} else if (!material.specularMap.isEmpty()) {
|
||||
obj.setProperty("specularMap", material.specularMap);
|
||||
}
|
||||
if (hasPropertyFallthroughs && material.propertyFallthroughs.at(graphics::MaterialKey::ALBEDO_MAP_BIT)) {
|
||||
obj.setProperty("albedoMap", FALLTHROUGH);
|
||||
} else if (!material.albedoMap.isEmpty()) {
|
||||
obj.setProperty("albedoMap", material.albedoMap);
|
||||
}
|
||||
|
||||
if (hasPropertyFallthroughs && material.propertyFallthroughs.at(graphics::MaterialKey::ROUGHNESS_MAP_BIT)) {
|
||||
obj.setProperty("roughnessMap", FALLTHROUGH);
|
||||
} else if (!material.roughnessMap.isEmpty()) {
|
||||
obj.setProperty("roughnessMap", material.roughnessMap);
|
||||
} else if (!material.glossMap.isEmpty()) {
|
||||
obj.setProperty("glossMap", material.glossMap);
|
||||
}
|
||||
if (!material.opacityMap.isEmpty()) {
|
||||
obj.setProperty("opacityMap", material.opacityMap);
|
||||
}
|
||||
|
||||
if (hasPropertyFallthroughs && material.propertyFallthroughs.at(graphics::MaterialKey::NORMAL_MAP_BIT)) {
|
||||
obj.setProperty("normalMap", FALLTHROUGH);
|
||||
} else if (!material.normalMap.isEmpty()) {
|
||||
obj.setProperty("normalMap", material.normalMap);
|
||||
} else if (!material.bumpMap.isEmpty()) {
|
||||
obj.setProperty("bumpMap", material.bumpMap);
|
||||
}
|
||||
if (hasPropertyFallthroughs && material.propertyFallthroughs.at(graphics::MaterialKey::OCCLUSION_MAP_BIT)) {
|
||||
obj.setProperty("occlusionMap", FALLTHROUGH);
|
||||
} else if (!material.occlusionMap.isEmpty()) {
|
||||
obj.setProperty("occlusionMap", material.occlusionMap);
|
||||
}
|
||||
|
||||
// These need to be implemented, but set the fallthrough for now
|
||||
if (hasPropertyFallthroughs && material.propertyFallthroughs.at(graphics::Material::TEXCOORDTRANSFORM0)) {
|
||||
obj.setProperty("texCoordTransform0", FALLTHROUGH);
|
||||
} else if (material.texCoordTransforms[0] != mat4()) {
|
||||
obj.setProperty("texCoordTransform0", mat4toScriptValue(engine, material.texCoordTransforms[0]));
|
||||
}
|
||||
if (hasPropertyFallthroughs && material.propertyFallthroughs.at(graphics::Material::TEXCOORDTRANSFORM1)) {
|
||||
obj.setProperty("texCoordTransform1", FALLTHROUGH);
|
||||
} else if (material.texCoordTransforms[1] != mat4()) {
|
||||
obj.setProperty("texCoordTransform1", mat4toScriptValue(engine, material.texCoordTransforms[1]));
|
||||
}
|
||||
if (hasPropertyFallthroughs && material.propertyFallthroughs.at(graphics::Material::LIGHTMAP_PARAMS)) {
|
||||
obj.setProperty("lightmapParams", FALLTHROUGH);
|
||||
}
|
||||
if (hasPropertyFallthroughs && material.propertyFallthroughs.at(graphics::Material::MATERIAL_PARAMS)) {
|
||||
obj.setProperty("materialParams", FALLTHROUGH);
|
||||
}
|
||||
if (hasPropertyFallthroughs && material.propertyFallthroughs.at(graphics::MaterialKey::LIGHTMAP_MAP_BIT)) {
|
||||
obj.setProperty("lightmapMap", FALLTHROUGH);
|
||||
} else if (!material.lightmapMap.isEmpty()) {
|
||||
obj.setProperty("lightmapMap", material.lightmapMap);
|
||||
}
|
||||
|
||||
obj.setProperty("defaultFallthrough", material.defaultFallthrough);
|
||||
if (hasPropertyFallthroughs && material.propertyFallthroughs.at(graphics::MaterialKey::SCATTERING_MAP_BIT)) {
|
||||
obj.setProperty("scatteringMap", FALLTHROUGH);
|
||||
} else if (!material.scatteringMap.isEmpty()) {
|
||||
obj.setProperty("scatteringMap", material.scatteringMap);
|
||||
}
|
||||
|
||||
// Only set one of each of these
|
||||
if (hasPropertyFallthroughs && material.propertyFallthroughs.at(graphics::MaterialKey::METALLIC_MAP_BIT)) {
|
||||
obj.setProperty("metallicMap", FALLTHROUGH);
|
||||
} else if (!material.metallicMap.isEmpty()) {
|
||||
obj.setProperty("metallicMap", material.metallicMap);
|
||||
} else if (!material.specularMap.isEmpty()) {
|
||||
obj.setProperty("specularMap", material.specularMap);
|
||||
}
|
||||
|
||||
if (hasPropertyFallthroughs && material.propertyFallthroughs.at(graphics::MaterialKey::ROUGHNESS_MAP_BIT)) {
|
||||
obj.setProperty("roughnessMap", FALLTHROUGH);
|
||||
} else if (!material.roughnessMap.isEmpty()) {
|
||||
obj.setProperty("roughnessMap", material.roughnessMap);
|
||||
} else if (!material.glossMap.isEmpty()) {
|
||||
obj.setProperty("glossMap", material.glossMap);
|
||||
}
|
||||
|
||||
if (hasPropertyFallthroughs && material.propertyFallthroughs.at(graphics::MaterialKey::NORMAL_MAP_BIT)) {
|
||||
obj.setProperty("normalMap", FALLTHROUGH);
|
||||
} else if (!material.normalMap.isEmpty()) {
|
||||
obj.setProperty("normalMap", material.normalMap);
|
||||
} else if (!material.bumpMap.isEmpty()) {
|
||||
obj.setProperty("bumpMap", material.bumpMap);
|
||||
}
|
||||
|
||||
if (hasPropertyFallthroughs && material.propertyFallthroughs.at(graphics::Material::TEXCOORDTRANSFORM0)) {
|
||||
obj.setProperty("texCoordTransform0", FALLTHROUGH);
|
||||
} else if (material.texCoordTransforms[0] != mat4()) {
|
||||
obj.setProperty("texCoordTransform0", mat4toScriptValue(engine, material.texCoordTransforms[0]));
|
||||
}
|
||||
if (hasPropertyFallthroughs && material.propertyFallthroughs.at(graphics::Material::TEXCOORDTRANSFORM1)) {
|
||||
obj.setProperty("texCoordTransform1", FALLTHROUGH);
|
||||
} else if (material.texCoordTransforms[1] != mat4()) {
|
||||
obj.setProperty("texCoordTransform1", mat4toScriptValue(engine, material.texCoordTransforms[1]));
|
||||
}
|
||||
|
||||
// These need to be implemented, but set the fallthrough for now
|
||||
if (hasPropertyFallthroughs && material.propertyFallthroughs.at(graphics::Material::LIGHTMAP_PARAMS)) {
|
||||
obj.setProperty("lightmapParams", FALLTHROUGH);
|
||||
}
|
||||
if (hasPropertyFallthroughs && material.propertyFallthroughs.at(graphics::Material::MATERIAL_PARAMS)) {
|
||||
obj.setProperty("materialParams", FALLTHROUGH);
|
||||
}
|
||||
|
||||
obj.setProperty("defaultFallthrough", material.defaultFallthrough);
|
||||
} else if (material.model.toStdString() == graphics::Material::HIFI_SHADER_SIMPLE) {
|
||||
obj.setProperty("procedural", material.procedural);
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
|
|
@ -23,27 +23,32 @@ scriptable::ScriptableMaterial& scriptable::ScriptableMaterial::operator=(const
|
|||
name = material.name;
|
||||
model = material.model;
|
||||
opacity = material.opacity;
|
||||
roughness = material.roughness;
|
||||
metallic = material.metallic;
|
||||
scattering = material.scattering;
|
||||
unlit = material.unlit;
|
||||
emissive = material.emissive;
|
||||
albedo = material.albedo;
|
||||
emissiveMap = material.emissiveMap;
|
||||
albedoMap = material.albedoMap;
|
||||
opacityMap = material.opacityMap;
|
||||
metallicMap = material.metallicMap;
|
||||
specularMap = material.specularMap;
|
||||
roughnessMap = material.roughnessMap;
|
||||
glossMap = material.glossMap;
|
||||
normalMap = material.normalMap;
|
||||
bumpMap = material.bumpMap;
|
||||
occlusionMap = material.occlusionMap;
|
||||
lightmapMap = material.lightmapMap;
|
||||
scatteringMap = material.scatteringMap;
|
||||
|
||||
defaultFallthrough = material.defaultFallthrough;
|
||||
propertyFallthroughs = material.propertyFallthroughs;
|
||||
if (model.toStdString() == graphics::Material::HIFI_PBR) {
|
||||
roughness = material.roughness;
|
||||
metallic = material.metallic;
|
||||
scattering = material.scattering;
|
||||
unlit = material.unlit;
|
||||
emissive = material.emissive;
|
||||
emissiveMap = material.emissiveMap;
|
||||
albedoMap = material.albedoMap;
|
||||
opacityMap = material.opacityMap;
|
||||
metallicMap = material.metallicMap;
|
||||
specularMap = material.specularMap;
|
||||
roughnessMap = material.roughnessMap;
|
||||
glossMap = material.glossMap;
|
||||
normalMap = material.normalMap;
|
||||
bumpMap = material.bumpMap;
|
||||
occlusionMap = material.occlusionMap;
|
||||
lightmapMap = material.lightmapMap;
|
||||
scatteringMap = material.scatteringMap;
|
||||
|
||||
defaultFallthrough = material.defaultFallthrough;
|
||||
propertyFallthroughs = material.propertyFallthroughs;
|
||||
} else if (model.toStdString() == graphics::Material::HIFI_SHADER_SIMPLE) {
|
||||
procedural = material.procedural;
|
||||
}
|
||||
|
||||
key = material.key;
|
||||
|
||||
|
@ -55,73 +60,78 @@ scriptable::ScriptableMaterial::ScriptableMaterial(const graphics::MaterialPoint
|
|||
name = material->getName().c_str();
|
||||
model = material->getModel().c_str();
|
||||
opacity = material->getOpacity();
|
||||
roughness = material->getRoughness();
|
||||
metallic = material->getMetallic();
|
||||
scattering = material->getScattering();
|
||||
unlit = material->isUnlit();
|
||||
emissive = material->getEmissive();
|
||||
albedo = material->getAlbedo();
|
||||
defaultFallthrough = material->getDefaultFallthrough();
|
||||
propertyFallthroughs = material->getPropertyFallthroughs();
|
||||
key = material->getKey();
|
||||
|
||||
auto map = material->getTextureMap(graphics::Material::MapChannel::EMISSIVE_MAP);
|
||||
if (map && map->getTextureSource()) {
|
||||
emissiveMap = map->getTextureSource()->getUrl().toString();
|
||||
}
|
||||
if (model.toStdString() == graphics::Material::HIFI_PBR) {
|
||||
roughness = material->getRoughness();
|
||||
metallic = material->getMetallic();
|
||||
scattering = material->getScattering();
|
||||
unlit = material->isUnlit();
|
||||
emissive = material->getEmissive();
|
||||
defaultFallthrough = material->getDefaultFallthrough();
|
||||
propertyFallthroughs = material->getPropertyFallthroughs();
|
||||
key = material->getKey();
|
||||
|
||||
map = material->getTextureMap(graphics::Material::MapChannel::ALBEDO_MAP);
|
||||
if (map && map->getTextureSource()) {
|
||||
albedoMap = map->getTextureSource()->getUrl().toString();
|
||||
if (map->useAlphaChannel()) {
|
||||
opacityMap = albedoMap;
|
||||
auto map = material->getTextureMap(graphics::Material::MapChannel::EMISSIVE_MAP);
|
||||
if (map && map->getTextureSource()) {
|
||||
emissiveMap = map->getTextureSource()->getUrl().toString();
|
||||
}
|
||||
}
|
||||
|
||||
map = material->getTextureMap(graphics::Material::MapChannel::METALLIC_MAP);
|
||||
if (map && map->getTextureSource()) {
|
||||
if (map->getTextureSource()->getType() == image::TextureUsage::Type::METALLIC_TEXTURE) {
|
||||
metallicMap = map->getTextureSource()->getUrl().toString();
|
||||
} else if (map->getTextureSource()->getType() == image::TextureUsage::Type::SPECULAR_TEXTURE) {
|
||||
specularMap = map->getTextureSource()->getUrl().toString();
|
||||
map = material->getTextureMap(graphics::Material::MapChannel::ALBEDO_MAP);
|
||||
if (map && map->getTextureSource()) {
|
||||
albedoMap = map->getTextureSource()->getUrl().toString();
|
||||
if (map->useAlphaChannel()) {
|
||||
opacityMap = albedoMap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
map = material->getTextureMap(graphics::Material::MapChannel::ROUGHNESS_MAP);
|
||||
if (map && map->getTextureSource()) {
|
||||
if (map->getTextureSource()->getType() == image::TextureUsage::Type::ROUGHNESS_TEXTURE) {
|
||||
roughnessMap = map->getTextureSource()->getUrl().toString();
|
||||
} else if (map->getTextureSource()->getType() == image::TextureUsage::Type::GLOSS_TEXTURE) {
|
||||
glossMap = map->getTextureSource()->getUrl().toString();
|
||||
map = material->getTextureMap(graphics::Material::MapChannel::METALLIC_MAP);
|
||||
if (map && map->getTextureSource()) {
|
||||
if (map->getTextureSource()->getType() == image::TextureUsage::Type::METALLIC_TEXTURE) {
|
||||
metallicMap = map->getTextureSource()->getUrl().toString();
|
||||
} else if (map->getTextureSource()->getType() == image::TextureUsage::Type::SPECULAR_TEXTURE) {
|
||||
specularMap = map->getTextureSource()->getUrl().toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
map = material->getTextureMap(graphics::Material::MapChannel::NORMAL_MAP);
|
||||
if (map && map->getTextureSource()) {
|
||||
if (map->getTextureSource()->getType() == image::TextureUsage::Type::NORMAL_TEXTURE) {
|
||||
normalMap = map->getTextureSource()->getUrl().toString();
|
||||
} else if (map->getTextureSource()->getType() == image::TextureUsage::Type::BUMP_TEXTURE) {
|
||||
bumpMap = map->getTextureSource()->getUrl().toString();
|
||||
map = material->getTextureMap(graphics::Material::MapChannel::ROUGHNESS_MAP);
|
||||
if (map && map->getTextureSource()) {
|
||||
if (map->getTextureSource()->getType() == image::TextureUsage::Type::ROUGHNESS_TEXTURE) {
|
||||
roughnessMap = map->getTextureSource()->getUrl().toString();
|
||||
} else if (map->getTextureSource()->getType() == image::TextureUsage::Type::GLOSS_TEXTURE) {
|
||||
glossMap = map->getTextureSource()->getUrl().toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
map = material->getTextureMap(graphics::Material::MapChannel::OCCLUSION_MAP);
|
||||
if (map && map->getTextureSource()) {
|
||||
occlusionMap = map->getTextureSource()->getUrl().toString();
|
||||
}
|
||||
map = material->getTextureMap(graphics::Material::MapChannel::NORMAL_MAP);
|
||||
if (map && map->getTextureSource()) {
|
||||
if (map->getTextureSource()->getType() == image::TextureUsage::Type::NORMAL_TEXTURE) {
|
||||
normalMap = map->getTextureSource()->getUrl().toString();
|
||||
} else if (map->getTextureSource()->getType() == image::TextureUsage::Type::BUMP_TEXTURE) {
|
||||
bumpMap = map->getTextureSource()->getUrl().toString();
|
||||
}
|
||||
}
|
||||
|
||||
map = material->getTextureMap(graphics::Material::MapChannel::LIGHTMAP_MAP);
|
||||
if (map && map->getTextureSource()) {
|
||||
lightmapMap = map->getTextureSource()->getUrl().toString();
|
||||
}
|
||||
map = material->getTextureMap(graphics::Material::MapChannel::OCCLUSION_MAP);
|
||||
if (map && map->getTextureSource()) {
|
||||
occlusionMap = map->getTextureSource()->getUrl().toString();
|
||||
}
|
||||
|
||||
map = material->getTextureMap(graphics::Material::MapChannel::SCATTERING_MAP);
|
||||
if (map && map->getTextureSource()) {
|
||||
scatteringMap = map->getTextureSource()->getUrl().toString();
|
||||
}
|
||||
map = material->getTextureMap(graphics::Material::MapChannel::LIGHTMAP_MAP);
|
||||
if (map && map->getTextureSource()) {
|
||||
lightmapMap = map->getTextureSource()->getUrl().toString();
|
||||
}
|
||||
|
||||
for (int i = 0; i < graphics::Material::NUM_TEXCOORD_TRANSFORMS; i++) {
|
||||
texCoordTransforms[i] = material->getTexCoordTransform(i);
|
||||
map = material->getTextureMap(graphics::Material::MapChannel::SCATTERING_MAP);
|
||||
if (map && map->getTextureSource()) {
|
||||
scatteringMap = map->getTextureSource()->getUrl().toString();
|
||||
}
|
||||
|
||||
for (int i = 0; i < graphics::Material::NUM_TEXCOORD_TRANSFORMS; i++) {
|
||||
texCoordTransforms[i] = material->getTexCoordTransform(i);
|
||||
}
|
||||
} else if (model.toStdString() == graphics::Material::HIFI_SHADER_SIMPLE) {
|
||||
procedural = material->getProceduralString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,9 @@ const float Material::DEFAULT_METALLIC { 0.0f };
|
|||
const float Material::DEFAULT_ROUGHNESS { 1.0f };
|
||||
const float Material::DEFAULT_SCATTERING { 0.0f };
|
||||
|
||||
const std::string Material::HIFI_PBR { "hifi_pbr" };
|
||||
const std::string Material::HIFI_SHADER_SIMPLE { "hifi_shader_simple" };
|
||||
|
||||
Material::Material() {
|
||||
for (int i = 0; i < NUM_TOTAL_FLAGS; i++) {
|
||||
_propertyFallthroughs[i] = false;
|
||||
|
|
|
@ -346,12 +346,16 @@ public:
|
|||
virtual bool isProcedural() const { return false; }
|
||||
virtual bool isEnabled() const { return true; }
|
||||
virtual bool isReady() const { return true; }
|
||||
virtual QString getProceduralString() const { return QString(); }
|
||||
|
||||
static const std::string HIFI_PBR;
|
||||
static const std::string HIFI_SHADER_SIMPLE;
|
||||
|
||||
protected:
|
||||
std::string _name { "" };
|
||||
|
||||
private:
|
||||
std::string _model { "hifi_pbr" };
|
||||
std::string _model { HIFI_PBR };
|
||||
mutable MaterialKey _key { 0 };
|
||||
|
||||
// Material properties
|
||||
|
|
|
@ -201,7 +201,12 @@ public:
|
|||
bool isProcedural() const override { return true; }
|
||||
bool isEnabled() const override { return _procedural.isEnabled(); }
|
||||
bool isReady() const override { return _procedural.isReady(); }
|
||||
void setProceduralData(const QString& data) { _procedural.setProceduralData(ProceduralData::parse(data)); }
|
||||
QString getProceduralString() const override { return _proceduralString; }
|
||||
|
||||
void setProceduralData(const QString& data) {
|
||||
_proceduralString = data;
|
||||
_procedural.setProceduralData(ProceduralData::parse(data));
|
||||
}
|
||||
glm::vec4 getColor(const glm::vec4& color) const { return _procedural.getColor(color); }
|
||||
bool isFading() const { return _procedural.isFading(); }
|
||||
void setIsFading(bool isFading) { _procedural.setIsFading(isFading); }
|
||||
|
@ -214,6 +219,7 @@ public:
|
|||
void initializeProcedural();
|
||||
|
||||
private:
|
||||
QString _proceduralString;
|
||||
Procedural _procedural;
|
||||
};
|
||||
typedef std::shared_ptr<ProceduralMaterial> ProceduralMaterialPointer;
|
||||
|
|
|
@ -172,9 +172,7 @@ std::pair<std::string, std::shared_ptr<NetworkMaterial>> NetworkMaterialResource
|
|||
std::string name = "";
|
||||
std::shared_ptr<NetworkMaterial> networkMaterial;
|
||||
|
||||
static const std::string HIFI_PBR = "hifi_pbr";
|
||||
static const std::string HIFI_SHADER_SIMPLE = "hifi_shader_simple";
|
||||
std::string modelString = HIFI_PBR;
|
||||
std::string modelString = graphics::Material::HIFI_PBR;
|
||||
auto modelJSONIter = materialJSON.find("model");
|
||||
if (modelJSONIter != materialJSON.end() && modelJSONIter.value().isString()) {
|
||||
modelString = modelJSONIter.value().toString().toStdString();
|
||||
|
@ -182,7 +180,7 @@ std::pair<std::string, std::shared_ptr<NetworkMaterial>> NetworkMaterialResource
|
|||
|
||||
std::array<glm::mat4, graphics::Material::NUM_TEXCOORD_TRANSFORMS> texcoordTransforms;
|
||||
|
||||
if (modelString == HIFI_PBR) {
|
||||
if (modelString == graphics::Material::HIFI_PBR) {
|
||||
auto material = std::make_shared<NetworkMaterial>();
|
||||
const QString FALLTHROUGH("fallthrough");
|
||||
for (auto& key : materialJSON.keys()) {
|
||||
|
@ -424,7 +422,7 @@ std::pair<std::string, std::shared_ptr<NetworkMaterial>> NetworkMaterialResource
|
|||
}
|
||||
}
|
||||
networkMaterial = material;
|
||||
} else if (modelString == HIFI_SHADER_SIMPLE) {
|
||||
} else if (modelString == graphics::Material::HIFI_SHADER_SIMPLE) {
|
||||
auto material = std::make_shared<graphics::ProceduralMaterial>();
|
||||
const QString FALLTHROUGH("fallthrough");
|
||||
for (auto& key : materialJSON.keys()) {
|
||||
|
|
|
@ -18,8 +18,9 @@
|
|||
|
||||
using namespace render;
|
||||
|
||||
CauterizedMeshPartPayload::CauterizedMeshPartPayload(ModelPointer model, int meshIndex, int partIndex, int shapeIndex, const Transform& transform, const Transform& offsetTransform)
|
||||
: ModelMeshPartPayload(model, meshIndex, partIndex, shapeIndex, transform, offsetTransform) {}
|
||||
CauterizedMeshPartPayload::CauterizedMeshPartPayload(ModelPointer model, int meshIndex, int partIndex, int shapeIndex,
|
||||
const Transform& transform, const Transform& offsetTransform, const uint64_t& created)
|
||||
: ModelMeshPartPayload(model, meshIndex, partIndex, shapeIndex, transform, offsetTransform, created) {}
|
||||
|
||||
void CauterizedMeshPartPayload::updateClusterBuffer(const std::vector<glm::mat4>& clusterMatrices,
|
||||
const std::vector<glm::mat4>& cauterizedClusterMatrices) {
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
class CauterizedMeshPartPayload : public ModelMeshPartPayload {
|
||||
public:
|
||||
CauterizedMeshPartPayload(ModelPointer model, int meshIndex, int partIndex, int shapeIndex, const Transform& transform, const Transform& offsetTransform);
|
||||
CauterizedMeshPartPayload(ModelPointer model, int meshIndex, int partIndex, int shapeIndex, const Transform& transform, const Transform& offsetTransform, const uint64_t& created);
|
||||
|
||||
// matrix palette skinning
|
||||
void updateClusterBuffer(const std::vector<glm::mat4>& clusterMatrices,
|
||||
|
|
|
@ -88,7 +88,7 @@ void CauterizedModel::createRenderItemSet() {
|
|||
for (int partIndex = 0; partIndex < numParts; partIndex++) {
|
||||
initializeBlendshapes(hfmModel.meshes[i], i);
|
||||
|
||||
auto ptr = std::make_shared<CauterizedMeshPartPayload>(shared_from_this(), i, partIndex, shapeID, transform, offset);
|
||||
auto ptr = std::make_shared<CauterizedMeshPartPayload>(shared_from_this(), i, partIndex, shapeID, transform, offset, _created);
|
||||
_modelMeshRenderItems << std::static_pointer_cast<ModelMeshPartPayload>(ptr);
|
||||
auto material = getGeometry()->getShapeMaterial(shapeID);
|
||||
_modelMeshMaterialNames.push_back(material ? material->getName() : "");
|
||||
|
|
|
@ -52,7 +52,9 @@ template <> void payloadRender(const MeshPartPayload::Pointer& payload, RenderAr
|
|||
}
|
||||
}
|
||||
|
||||
MeshPartPayload::MeshPartPayload(const std::shared_ptr<const graphics::Mesh>& mesh, int partIndex, graphics::MaterialPointer material) {
|
||||
MeshPartPayload::MeshPartPayload(const std::shared_ptr<const graphics::Mesh>& mesh, int partIndex, graphics::MaterialPointer material, const uint64_t& created) :
|
||||
_created(created)
|
||||
{
|
||||
updateMeshPart(mesh, partIndex);
|
||||
addMaterial(graphics::MaterialLayer(material, 0));
|
||||
}
|
||||
|
@ -172,7 +174,7 @@ void MeshPartPayload::render(RenderArgs* args) {
|
|||
auto& schema = _drawMaterials.getSchemaBuffer().get<graphics::MultiMaterial::Schema>();
|
||||
glm::vec4 outColor = glm::vec4(ColorUtils::tosRGBVec3(schema._albedo), schema._opacity);
|
||||
outColor = procedural->getColor(outColor);
|
||||
procedural->prepare(batch, _drawTransform.getTranslation(), _drawTransform.getScale(), _drawTransform.getRotation(), 0, // FIXME: pass in _created
|
||||
procedural->prepare(batch, _drawTransform.getTranslation(), _drawTransform.getScale(), _drawTransform.getRotation(), _created,
|
||||
ProceduralProgramKey(outColor.a < 1.0f));
|
||||
batch._glColor4f(outColor.r, outColor.g, outColor.b, outColor.a);
|
||||
} else {
|
||||
|
@ -220,7 +222,8 @@ template <> void payloadRender(const ModelMeshPartPayload::Pointer& payload, Ren
|
|||
|
||||
}
|
||||
|
||||
ModelMeshPartPayload::ModelMeshPartPayload(ModelPointer model, int meshIndex, int partIndex, int shapeIndex, const Transform& transform, const Transform& offsetTransform) :
|
||||
ModelMeshPartPayload::ModelMeshPartPayload(ModelPointer model, int meshIndex, int partIndex, int shapeIndex,
|
||||
const Transform& transform, const Transform& offsetTransform, const uint64_t& created) :
|
||||
_meshIndex(meshIndex),
|
||||
_shapeID(shapeIndex) {
|
||||
|
||||
|
@ -272,6 +275,7 @@ ModelMeshPartPayload::ModelMeshPartPayload(ModelPointer model, int meshIndex, in
|
|||
}
|
||||
#endif
|
||||
|
||||
_created = created;
|
||||
}
|
||||
|
||||
void ModelMeshPartPayload::initCache(const ModelPointer& model) {
|
||||
|
@ -468,7 +472,7 @@ void ModelMeshPartPayload::render(RenderArgs* args) {
|
|||
auto& schema = _drawMaterials.getSchemaBuffer().get<graphics::MultiMaterial::Schema>();
|
||||
glm::vec4 outColor = glm::vec4(ColorUtils::tosRGBVec3(schema._albedo), schema._opacity);
|
||||
outColor = procedural->getColor(outColor);
|
||||
procedural->prepare(batch, _drawTransform.getTranslation(), _drawTransform.getScale(), _drawTransform.getRotation(), 0,// FIXME: pass in _created
|
||||
procedural->prepare(batch, _drawTransform.getTranslation(), _drawTransform.getScale(), _drawTransform.getRotation(), _created,
|
||||
ProceduralProgramKey(outColor.a < 1.0f, _shapeKey.isDeformed(), _shapeKey.isDualQuatSkinned()));
|
||||
batch._glColor4f(outColor.r, outColor.g, outColor.b, outColor.a);
|
||||
} else {
|
||||
|
|
|
@ -27,7 +27,7 @@ class Model;
|
|||
class MeshPartPayload {
|
||||
public:
|
||||
MeshPartPayload() = default;
|
||||
MeshPartPayload(const std::shared_ptr<const graphics::Mesh>& mesh, int partIndex, graphics::MaterialPointer material);
|
||||
MeshPartPayload(const std::shared_ptr<const graphics::Mesh>& mesh, int partIndex, graphics::MaterialPointer material, const uint64_t& created);
|
||||
virtual ~MeshPartPayload() = default;
|
||||
|
||||
typedef render::Payload<MeshPartPayload> Payload;
|
||||
|
@ -77,6 +77,7 @@ public:
|
|||
|
||||
protected:
|
||||
render::ItemKey _itemKey{ render::ItemKey::Builder::opaqueShape().build() };
|
||||
uint64_t _created;
|
||||
};
|
||||
|
||||
namespace render {
|
||||
|
@ -88,7 +89,7 @@ namespace render {
|
|||
|
||||
class ModelMeshPartPayload : public MeshPartPayload {
|
||||
public:
|
||||
ModelMeshPartPayload(ModelPointer model, int meshIndex, int partIndex, int shapeIndex, const Transform& transform, const Transform& offsetTransform);
|
||||
ModelMeshPartPayload(ModelPointer model, int meshIndex, int partIndex, int shapeIndex, const Transform& transform, const Transform& offsetTransform, const uint64_t& created);
|
||||
|
||||
typedef render::Payload<ModelMeshPartPayload> Payload;
|
||||
typedef Payload::DataPointer Pointer;
|
||||
|
|
|
@ -48,7 +48,7 @@ int normalTypeVecTypeId = qRegisterMetaType<QVector<NormalType>>("QVector<Normal
|
|||
float Model::FAKE_DIMENSION_PLACEHOLDER = -1.0f;
|
||||
#define HTTP_INVALID_COM "http://invalid.com"
|
||||
|
||||
Model::Model(QObject* parent, SpatiallyNestable* spatiallyNestableOverride) :
|
||||
Model::Model(QObject* parent, SpatiallyNestable* spatiallyNestableOverride, uint64_t created) :
|
||||
QObject(parent),
|
||||
_renderGeometry(),
|
||||
_renderWatcher(_renderGeometry),
|
||||
|
@ -62,7 +62,8 @@ Model::Model(QObject* parent, SpatiallyNestable* spatiallyNestableOverride) :
|
|||
_snapModelToRegistrationPoint(false),
|
||||
_snappedToRegistrationPoint(false),
|
||||
_url(HTTP_INVALID_COM),
|
||||
_renderItemKeyGlobalFlags(render::ItemKey::Builder().withVisible().withTagBits(render::hifi::TAG_ALL_VIEWS).build())
|
||||
_renderItemKeyGlobalFlags(render::ItemKey::Builder().withVisible().withTagBits(render::hifi::TAG_ALL_VIEWS).build()),
|
||||
_created(created)
|
||||
{
|
||||
// we may have been created in the network thread, but we live in the main thread
|
||||
if (_viewState) {
|
||||
|
@ -1495,7 +1496,7 @@ void Model::createRenderItemSet() {
|
|||
int numParts = (int)mesh->getNumParts();
|
||||
for (int partIndex = 0; partIndex < numParts; partIndex++) {
|
||||
initializeBlendshapes(hfmModel.meshes[i], i);
|
||||
_modelMeshRenderItems << std::make_shared<ModelMeshPartPayload>(shared_from_this(), i, partIndex, shapeID, transform, offset);
|
||||
_modelMeshRenderItems << std::make_shared<ModelMeshPartPayload>(shared_from_this(), i, partIndex, shapeID, transform, offset, _created);
|
||||
auto material = getGeometry()->getShapeMaterial(shapeID);
|
||||
_modelMeshMaterialNames.push_back(material ? material->getName() : "");
|
||||
_modelMeshRenderItemShapes.emplace_back(ShapeInfo{ (int)i });
|
||||
|
|
|
@ -99,7 +99,7 @@ public:
|
|||
|
||||
static void setAbstractViewStateInterface(AbstractViewStateInterface* viewState) { _viewState = viewState; }
|
||||
|
||||
Model(QObject* parent = nullptr, SpatiallyNestable* spatiallyNestableOverride = nullptr);
|
||||
Model(QObject* parent = nullptr, SpatiallyNestable* spatiallyNestableOverride = nullptr, uint64_t created = 0);
|
||||
virtual ~Model();
|
||||
|
||||
inline ModelPointer getThisPointer() const {
|
||||
|
@ -511,6 +511,8 @@ protected:
|
|||
|
||||
void initializeBlendshapes(const HFMMesh& mesh, int index);
|
||||
|
||||
uint64_t _created;
|
||||
|
||||
private:
|
||||
float _loadingPriority { 0.0f };
|
||||
|
||||
|
|
Loading…
Reference in a new issue