mirror of
https://github.com/lubosz/overte.git
synced 2025-04-23 17:54:00 +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();
|
||||
}
|
||||
|
||||
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
|
||||
// we will watch for that and ask the model to update it's render items
|
||||
if (model->getRenderItemsNeedUpdate()) {
|
||||
|
@ -1584,6 +1609,10 @@ void ModelEntityRenderer::addMaterial(graphics::MaterialLayer material, const st
|
|||
if (_model && _model->fetchRenderItemIDs().size() > 0) {
|
||||
_model->addMaterial(material, parentMaterialName);
|
||||
}
|
||||
if (material.material && material.material->isProcedural()) {
|
||||
_allProceduralMaterialsLoaded = false;
|
||||
emit requestRenderUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
void ModelEntityRenderer::removeMaterial(graphics::MaterialPointer material, const std::string& parentMaterialName) {
|
||||
|
|
|
@ -202,10 +202,10 @@ private:
|
|||
bool _prevModelLoaded { false };
|
||||
|
||||
void processMaterials();
|
||||
bool _allProceduralMaterialsLoaded { false };
|
||||
|
||||
static void metaBlendshapeOperator(render::ItemID renderItemID, int blendshapeNumber, const QVector<BlendshapeOffset>& blendshapeOffsets,
|
||||
const QVector<int>& blendedMeshSizes, const render::ItemIDs& subItemIDs);
|
||||
|
||||
};
|
||||
|
||||
} } // namespace
|
||||
|
|
|
@ -32,7 +32,7 @@ bool ShapeEntityRenderer::needsRenderUpdate() const {
|
|||
if (resultWithReadLock<bool>([&] {
|
||||
auto mat = _materials.find("0");
|
||||
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);
|
||||
if (procedural->isFading()) {
|
||||
return true;
|
||||
|
@ -88,7 +88,7 @@ void ShapeEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce
|
|||
void ShapeEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) {
|
||||
withReadLock([&] {
|
||||
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);
|
||||
if (procedural->isFading()) {
|
||||
procedural->setIsFading(Interpolate::calculateFadeRatio(procedural->getFadeStartTime()) < 1.0f);
|
||||
|
@ -140,7 +140,7 @@ bool ShapeEntityRenderer::isTransparent() const {
|
|||
|
||||
auto mat = _materials.find("0");
|
||||
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);
|
||||
if (procedural->isFading()) {
|
||||
return true;
|
||||
|
|
|
@ -520,8 +520,7 @@ void ModelMeshPartPayload::render(RenderArgs* args) {
|
|||
batch.setDrawcallUniform(drawcallInfo);
|
||||
}
|
||||
|
||||
if (!_drawMaterials.empty() && _drawMaterials.top().material && _drawMaterials.top().material->isProcedural() &&
|
||||
_drawMaterials.top().material->isReady()) {
|
||||
if (_shapeKey.hasOwnPipeline()) {
|
||||
if (!(enableMaterialProceduralShaders)) {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue