Fix Cycles viewport render not updating when tweaking displacement shader.

This was disabled to avoid updating the geometry every time when the
material includes displacement, because there was no way to distinguish
between surface shader and displacement updates.

As a solution, we now compute an MD5 hash of the nodes linked to the
displacement socket, and only update the mesh if that changes.

Differential Revision: https://developer.blender.org/D3018
This commit is contained in:
2018-01-24 20:19:48 +01:00
parent fb941679bb
commit 1eeb846e78
11 changed files with 87 additions and 10 deletions

View File

@@ -1964,7 +1964,7 @@ void MeshManager::device_update(Device *device, DeviceScene *dscene, Scene *scen
/* Update normals. */
foreach(Mesh *mesh, scene->meshes) {
foreach(Shader *shader, mesh->used_shaders) {
if(shader->need_update_attributes)
if(shader->need_update_mesh)
mesh->need_update = true;
}
@@ -2104,7 +2104,7 @@ void MeshManager::device_update(Device *device, DeviceScene *dscene, Scene *scen
<< summary.full_report();
foreach(Shader *shader, scene->shaders) {
shader->need_update_attributes = false;
shader->need_update_mesh = false;
}
Scene::MotionType need_motion = scene->need_motion();