mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 19:21:16 +02:00
Merge pull request #309 from HifiExperiments/modelShader
Procedural Shader applies to entities other than target
This commit is contained in:
commit
954e8096bb
4 changed files with 34 additions and 6 deletions
|
@ -1460,6 +1460,31 @@ void ModelEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce
|
||||||
emit requestRenderUpdate();
|
emit requestRenderUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!_allProceduralMaterialsLoaded) {
|
||||||
|
std::lock_guard<std::mutex> lock(_materialsLock);
|
||||||
|
bool allProceduralMaterialsLoaded = true;
|
||||||
|
for (auto& shapeMaterialPair : _materials) {
|
||||||
|
auto material = shapeMaterialPair.second;
|
||||||
|
while (!material.empty()) {
|
||||||
|
auto mat = material.top();
|
||||||
|
if (mat.material && mat.material->isProcedural() && !mat.material->isReady()) {
|
||||||
|
allProceduralMaterialsLoaded = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
material.pop();
|
||||||
|
}
|
||||||
|
if (!allProceduralMaterialsLoaded) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!allProceduralMaterialsLoaded) {
|
||||||
|
emit requestRenderUpdate();
|
||||||
|
} else {
|
||||||
|
_allProceduralMaterialsLoaded = true;
|
||||||
|
model->setRenderItemsNeedUpdate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// When the individual mesh parts of a model finish fading, they will mark their Model as needing updating
|
// When the individual mesh parts of a model finish fading, they will mark their Model as needing updating
|
||||||
// we will watch for that and ask the model to update it's render items
|
// we will watch for that and ask the model to update it's render items
|
||||||
if (model->getRenderItemsNeedUpdate()) {
|
if (model->getRenderItemsNeedUpdate()) {
|
||||||
|
@ -1584,6 +1609,10 @@ void ModelEntityRenderer::addMaterial(graphics::MaterialLayer material, const st
|
||||||
if (_model && _model->fetchRenderItemIDs().size() > 0) {
|
if (_model && _model->fetchRenderItemIDs().size() > 0) {
|
||||||
_model->addMaterial(material, parentMaterialName);
|
_model->addMaterial(material, parentMaterialName);
|
||||||
}
|
}
|
||||||
|
if (material.material && material.material->isProcedural()) {
|
||||||
|
_allProceduralMaterialsLoaded = false;
|
||||||
|
emit requestRenderUpdate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelEntityRenderer::removeMaterial(graphics::MaterialPointer material, const std::string& parentMaterialName) {
|
void ModelEntityRenderer::removeMaterial(graphics::MaterialPointer material, const std::string& parentMaterialName) {
|
||||||
|
|
|
@ -202,10 +202,10 @@ private:
|
||||||
bool _prevModelLoaded { false };
|
bool _prevModelLoaded { false };
|
||||||
|
|
||||||
void processMaterials();
|
void processMaterials();
|
||||||
|
bool _allProceduralMaterialsLoaded { false };
|
||||||
|
|
||||||
static void metaBlendshapeOperator(render::ItemID renderItemID, int blendshapeNumber, const QVector<BlendshapeOffset>& blendshapeOffsets,
|
static void metaBlendshapeOperator(render::ItemID renderItemID, int blendshapeNumber, const QVector<BlendshapeOffset>& blendshapeOffsets,
|
||||||
const QVector<int>& blendedMeshSizes, const render::ItemIDs& subItemIDs);
|
const QVector<int>& blendedMeshSizes, const render::ItemIDs& subItemIDs);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} } // namespace
|
} } // namespace
|
||||||
|
|
|
@ -32,7 +32,7 @@ bool ShapeEntityRenderer::needsRenderUpdate() const {
|
||||||
if (resultWithReadLock<bool>([&] {
|
if (resultWithReadLock<bool>([&] {
|
||||||
auto mat = _materials.find("0");
|
auto mat = _materials.find("0");
|
||||||
if (mat != _materials.end() && mat->second.top().material && mat->second.top().material->isProcedural() &&
|
if (mat != _materials.end() && mat->second.top().material && mat->second.top().material->isProcedural() &&
|
||||||
mat->second.top().material->isEnabled()) {
|
mat->second.top().material->isReady()) {
|
||||||
auto procedural = std::static_pointer_cast<graphics::ProceduralMaterial>(mat->second.top().material);
|
auto procedural = std::static_pointer_cast<graphics::ProceduralMaterial>(mat->second.top().material);
|
||||||
if (procedural->isFading()) {
|
if (procedural->isFading()) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -88,7 +88,7 @@ void ShapeEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce
|
||||||
void ShapeEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) {
|
void ShapeEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) {
|
||||||
withReadLock([&] {
|
withReadLock([&] {
|
||||||
auto mat = _materials.find("0");
|
auto mat = _materials.find("0");
|
||||||
if (mat != _materials.end() && mat->second.top().material && mat->second.top().material->isProcedural() && mat->second.top().material->isEnabled()) {
|
if (mat != _materials.end() && mat->second.top().material && mat->second.top().material->isProcedural() && mat->second.top().material->isReady()) {
|
||||||
auto procedural = std::static_pointer_cast<graphics::ProceduralMaterial>(mat->second.top().material);
|
auto procedural = std::static_pointer_cast<graphics::ProceduralMaterial>(mat->second.top().material);
|
||||||
if (procedural->isFading()) {
|
if (procedural->isFading()) {
|
||||||
procedural->setIsFading(Interpolate::calculateFadeRatio(procedural->getFadeStartTime()) < 1.0f);
|
procedural->setIsFading(Interpolate::calculateFadeRatio(procedural->getFadeStartTime()) < 1.0f);
|
||||||
|
@ -140,7 +140,7 @@ bool ShapeEntityRenderer::isTransparent() const {
|
||||||
|
|
||||||
auto mat = _materials.find("0");
|
auto mat = _materials.find("0");
|
||||||
if (mat != _materials.end() && mat->second.top().material) {
|
if (mat != _materials.end() && mat->second.top().material) {
|
||||||
if (mat->second.top().material->isProcedural() && mat->second.top().material->isEnabled()) {
|
if (mat->second.top().material->isProcedural() && mat->second.top().material->isReady()) {
|
||||||
auto procedural = std::static_pointer_cast<graphics::ProceduralMaterial>(mat->second.top().material);
|
auto procedural = std::static_pointer_cast<graphics::ProceduralMaterial>(mat->second.top().material);
|
||||||
if (procedural->isFading()) {
|
if (procedural->isFading()) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -520,8 +520,7 @@ void ModelMeshPartPayload::render(RenderArgs* args) {
|
||||||
batch.setDrawcallUniform(drawcallInfo);
|
batch.setDrawcallUniform(drawcallInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_drawMaterials.empty() && _drawMaterials.top().material && _drawMaterials.top().material->isProcedural() &&
|
if (_shapeKey.hasOwnPipeline()) {
|
||||||
_drawMaterials.top().material->isReady()) {
|
|
||||||
if (!(enableMaterialProceduralShaders)) {
|
if (!(enableMaterialProceduralShaders)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue