Cycles microdisplacement: Support for Catmull-Clark subdivision via OpenSubdiv
Enables Catmull-Clark subdivision meshes with support for creases and attribute subdivision. Still waiting on OpenSubdiv to fully support face varying interpolation for subdividing uv coordinates tho. Also there may be some inconsistencies with Blender's subdivision which will be resolved at a later time. Code for reading patch tables and creating patch maps is borrowed from OpenSubdiv. Reviewed By: brecht Differential Revision: https://developer.blender.org/D2111
This commit is contained in:
@@ -29,6 +29,8 @@
|
||||
#include "util_progress.h"
|
||||
#include "util_vector.h"
|
||||
|
||||
#include "subd_patch_table.h"
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
/* Object */
|
||||
@@ -607,6 +609,37 @@ void ObjectManager::device_update_flags(Device *device,
|
||||
device->tex_alloc("__object_flag", dscene->object_flag);
|
||||
}
|
||||
|
||||
void ObjectManager::device_update_patch_map_offsets(Device *device, DeviceScene *dscene, Scene *scene)
|
||||
{
|
||||
uint4* objects = (uint4*)dscene->objects.get_data();
|
||||
|
||||
bool update = false;
|
||||
|
||||
int object_index = 0;
|
||||
foreach(Object *object, scene->objects) {
|
||||
int offset = object_index*OBJECT_SIZE + 11;
|
||||
|
||||
Mesh* mesh = object->mesh;
|
||||
|
||||
if(mesh->patch_table) {
|
||||
uint patch_map_offset = 2*(mesh->patch_table_offset + mesh->patch_table->total_size() -
|
||||
mesh->patch_table->num_nodes * PATCH_NODE_SIZE) - mesh->patch_offset;
|
||||
|
||||
if(objects[offset].x != patch_map_offset) {
|
||||
objects[offset].x = patch_map_offset;
|
||||
update = true;
|
||||
}
|
||||
}
|
||||
|
||||
object_index++;
|
||||
}
|
||||
|
||||
if(update) {
|
||||
device->tex_free(dscene->objects);
|
||||
device->tex_alloc("__objects", dscene->objects);
|
||||
}
|
||||
}
|
||||
|
||||
void ObjectManager::device_free(Device *device, DeviceScene *dscene)
|
||||
{
|
||||
device->tex_free(dscene->objects);
|
||||
|
Reference in New Issue
Block a user