Do not cauterize bones in SHADOW_RENDER_MODE

This commit is contained in:
Zach Pomerantz 2016-01-18 20:50:03 -08:00
parent 3c80002dfe
commit 7a5562abce
3 changed files with 20 additions and 13 deletions

View file

@ -215,7 +215,7 @@ void MeshPartPayload::bindMaterial(gpu::Batch& batch, const ShapePipeline::Locat
}
}
void MeshPartPayload::bindTransform(gpu::Batch& batch, const ShapePipeline::LocationsPointer locations) const {
void MeshPartPayload::bindTransform(gpu::Batch& batch, const ShapePipeline::LocationsPointer locations, bool canCauterize) const {
batch.setModelTransform(_drawTransform);
}
@ -442,25 +442,25 @@ void ModelMeshPartPayload::bindMesh(gpu::Batch& batch) const {
}
}
void ModelMeshPartPayload::bindTransform(gpu::Batch& batch, const ShapePipeline::LocationsPointer locations) const {
void ModelMeshPartPayload::bindTransform(gpu::Batch& batch, const ShapePipeline::LocationsPointer locations, bool canCauterize) const {
// Still relying on the raw data from the model
const Model::MeshState& state = _model->_meshStates.at(_meshIndex);
Transform transform;
if (state.clusterBuffer) {
if (_model->_cauterizeBones) {
if (canCauterize && _model->getCauterizeBones()) {
batch.setUniformBuffer(ShapePipeline::Slot::SKINNING_GPU, state.cauterizedClusterBuffer);
} else {
batch.setUniformBuffer(ShapePipeline::Slot::SKINNING_GPU, state.clusterBuffer);
}
} else {
if (_model->_cauterizeBones) {
if (canCauterize && _model->getCauterizeBones()) {
transform = Transform(state.cauterizedClusterMatrices[0]);
} else {
transform = Transform(state.clusterMatrices[0]);
}
}
// transform.preTranslate(_modelPosition);
transform.preTranslate(_transform.getTranslation());
batch.setModelTransform(transform);
}
@ -507,8 +507,9 @@ void ModelMeshPartPayload::render(RenderArgs* args) const {
assert(locations);
// Bind the model transform and the skinCLusterMatrices if needed
bool canCauterize = args->_renderMode != RenderArgs::SHADOW_RENDER_MODE;
_model->updateClusterMatrices(_transform.getTranslation(), _transform.getRotation());
bindTransform(batch, locations);
bindTransform(batch, locations, canCauterize);
//Bind the index buffer and vertex buffer and Blend shapes if needed
bindMesh(batch);

View file

@ -46,7 +46,7 @@ public:
void drawCall(gpu::Batch& batch) const;
virtual void bindMesh(gpu::Batch& batch) const;
virtual void bindMaterial(gpu::Batch& batch, const render::ShapePipeline::LocationsPointer locations) const;
virtual void bindTransform(gpu::Batch& batch, const render::ShapePipeline::LocationsPointer locations) const;
virtual void bindTransform(gpu::Batch& batch, const render::ShapePipeline::LocationsPointer locations, bool canCauterize = true) const;
// Payload resource cached values
model::MeshPointer _drawMesh;
@ -88,15 +88,17 @@ public:
// ModelMeshPartPayload functions to perform render
void bindMesh(gpu::Batch& batch) const override;
void bindTransform(gpu::Batch& batch, const render::ShapePipeline::LocationsPointer locations) const override;
void bindTransform(gpu::Batch& batch, const render::ShapePipeline::LocationsPointer locations, bool canCauterize) const override;
void initCache();
Model* _model;
int _meshIndex;
int _shapeID;
bool _isSkinned = false;
bool _isBlendShaped = false;
bool _isSkinned{ false };
bool _isBlendShaped{ false };
};
#endif // hifi_MeshPartPayload_h

View file

@ -138,20 +138,24 @@ void RenderShadowTask::run(const SceneContextPointer& sceneContext, const Render
return;
}
// Cache old render args
ViewFrustum* viewFrustum = args->_viewFrustum;
RenderArgs::RenderMode mode = args->_renderMode;
auto nearClip = viewFrustum->getNearClip();
const int SHADOW_NEAR_DEPTH = -2;
const int SHADOW_FAR_DEPTH = 20;
globalLight->shadow.setKeylightFrustum(viewFrustum, nearClip + SHADOW_NEAR_DEPTH, nearClip + SHADOW_FAR_DEPTH);
// Set the keylight frustum
// Set the keylight render args
args->_viewFrustum = globalLight->shadow.getFrustum().get();
args->_renderMode = RenderArgs::SHADOW_RENDER_MODE;
for (auto job : _jobs) {
job.run(sceneContext, renderContext);
}
// Reset the view frustum
// Reset the render args
args->_viewFrustum = viewFrustum;
args->_renderMode = mode;
};