fix avatar highlighting

This commit is contained in:
SamGondelman 2018-09-24 14:02:35 -07:00
parent 45b206d748
commit ad73cb3996
2 changed files with 25 additions and 22 deletions

View file

@ -37,6 +37,8 @@ namespace gr {
#define OUTLINE_STENCIL_MASK 1 #define OUTLINE_STENCIL_MASK 1
extern void initZPassPipelines(ShapePlumber& plumber, gpu::StatePointer state);
HighlightRessources::HighlightRessources() { HighlightRessources::HighlightRessources() {
} }
@ -180,6 +182,7 @@ void DrawHighlightMask::run(const render::RenderContextPointer& renderContext, c
auto maskPipeline = _shapePlumber->pickPipeline(args, defaultKeyBuilder); auto maskPipeline = _shapePlumber->pickPipeline(args, defaultKeyBuilder);
auto maskSkinnedPipeline = _shapePlumber->pickPipeline(args, defaultKeyBuilder.withSkinned()); auto maskSkinnedPipeline = _shapePlumber->pickPipeline(args, defaultKeyBuilder.withSkinned());
auto maskSkinnedDQPipeline = _shapePlumber->pickPipeline(args, defaultKeyBuilder.withSkinned().withDualQuatSkinned());
// Setup camera, projection and viewport for all items // Setup camera, projection and viewport for all items
batch.setViewportTransform(args->_viewport); batch.setViewportTransform(args->_viewport);
@ -187,14 +190,17 @@ void DrawHighlightMask::run(const render::RenderContextPointer& renderContext, c
batch.setProjectionJitter(jitter.x, jitter.y); batch.setProjectionJitter(jitter.x, jitter.y);
batch.setViewTransform(viewMat); batch.setViewTransform(viewMat);
std::vector<ShapeKey> skinnedShapeKeys{}; std::vector<ShapeKey> skinnedShapeKeys;
std::vector<ShapeKey> skinnedDQShapeKeys;
// Iterate through all inShapes and render the unskinned // Iterate through all inShapes and render the unskinned
args->_shapePipeline = maskPipeline; args->_shapePipeline = maskPipeline;
batch.setPipeline(maskPipeline->pipeline); batch.setPipeline(maskPipeline->pipeline);
for (const auto& items : inShapes) { for (const auto& items : inShapes) {
itemBounds.insert(itemBounds.end(), items.second.begin(), items.second.end()); itemBounds.insert(itemBounds.end(), items.second.begin(), items.second.end());
if (items.first.isSkinned()) { if (items.first.isSkinned() && items.first.isDualQuatSkinned()) {
skinnedDQShapeKeys.push_back(items.first);
} else if (items.first.isSkinned()) {
skinnedShapeKeys.push_back(items.first); skinnedShapeKeys.push_back(items.first);
} else { } else {
renderItems(renderContext, items.second); renderItems(renderContext, items.second);
@ -202,10 +208,21 @@ void DrawHighlightMask::run(const render::RenderContextPointer& renderContext, c
} }
// Reiterate to render the skinned // Reiterate to render the skinned
args->_shapePipeline = maskSkinnedPipeline; if (skinnedShapeKeys.size() > 0) {
batch.setPipeline(maskSkinnedPipeline->pipeline); args->_shapePipeline = maskSkinnedPipeline;
for (const auto& key : skinnedShapeKeys) { batch.setPipeline(maskSkinnedPipeline->pipeline);
renderItems(renderContext, inShapes.at(key)); for (const auto& key : skinnedShapeKeys) {
renderItems(renderContext, inShapes.at(key));
}
}
// Reiterate to render the DQ skinned
if (skinnedDQShapeKeys.size() > 0) {
args->_shapePipeline = maskSkinnedDQPipeline;
batch.setPipeline(maskSkinnedDQPipeline->pipeline);
for (const auto& key : skinnedDQShapeKeys) {
renderItems(renderContext, inShapes.at(key));
}
} }
args->_shapePipeline = nullptr; args->_shapePipeline = nullptr;
@ -488,7 +505,7 @@ void DrawHighlightTask::build(JobModel& task, const render::Varying& inputs, ren
state->setDepthTest(true, true, gpu::LESS_EQUAL); state->setDepthTest(true, true, gpu::LESS_EQUAL);
state->setColorWriteMask(false, false, false, false); state->setColorWriteMask(false, false, false, false);
initMaskPipelines(*shapePlumber, state); initZPassPipelines(*shapePlumber, state);
} }
auto sharedParameters = std::make_shared<HighlightSharedParameters>(); auto sharedParameters = std::make_shared<HighlightSharedParameters>();
@ -548,16 +565,4 @@ const render::Varying DrawHighlightTask::addSelectItemJobs(JobModel& task, const
const auto selectedMetasAndOpaques = task.addJob<SelectItems>("OpaqueSelection", selectMetaAndOpaqueInput); const auto selectedMetasAndOpaques = task.addJob<SelectItems>("OpaqueSelection", selectMetaAndOpaqueInput);
const auto selectItemInput = SelectItems::Inputs(transparents, selectedMetasAndOpaques, selectionName).asVarying(); const auto selectItemInput = SelectItems::Inputs(transparents, selectedMetasAndOpaques, selectionName).asVarying();
return task.addJob<SelectItems>("TransparentSelection", selectItemInput); return task.addJob<SelectItems>("TransparentSelection", selectItemInput);
} }
void DrawHighlightTask::initMaskPipelines(render::ShapePlumber& shapePlumber, gpu::StatePointer state) {
gpu::ShaderPointer modelProgram = gpu::Shader::createProgram(shader::render_utils::program::model_shadow);
shapePlumber.addPipeline(
ShapeKey::Filter::Builder().withoutSkinned(),
modelProgram, state);
gpu::ShaderPointer skinProgram = gpu::Shader::createProgram(shader::render_utils::program::skin_model_shadow);
shapePlumber.addPipeline(
ShapeKey::Filter::Builder().withSkinned(),
skinProgram, state);
}

View file

@ -208,8 +208,6 @@ public:
void build(JobModel& task, const render::Varying& inputs, render::Varying& outputs); void build(JobModel& task, const render::Varying& inputs, render::Varying& outputs);
private: private:
static void initMaskPipelines(render::ShapePlumber& plumber, gpu::StatePointer state);
static const render::Varying addSelectItemJobs(JobModel& task, const render::Varying& selectionName, const RenderFetchCullSortTask::BucketList& items); static const render::Varying addSelectItemJobs(JobModel& task, const render::Varying& selectionName, const RenderFetchCullSortTask::BucketList& items);
}; };