• S sverchok
  • Информация о проекте
    • Информация о проекте
    • Активность
    • Метки
    • Участники
  • Репозиторий
    • Репозиторий
    • Файлы
    • Коммиты
    • Ветки
    • Теги
    • Участники
    • Диаграмма
    • Сравнение
  • Задачи 148
    • Задачи 148
    • Список
    • Доски
    • Спринты
  • Запросы на слияние 21
    • Запросы на слияние 21
  • CI/CD
    • CI/CD
    • Конвейеры
    • Задания
    • Расписания
  • Развертывания
    • Развертывания
    • Окружения
    • Релизы
  • Пакеты и реестры
    • Пакеты и реестры
    • Реестр пакетов
    • Реестр контейнеров
  • Мониторинг
    • Мониторинг
    • Инциденты
  • Аналитика
    • Аналитика
    • Поток ценности
    • CI/CD
    • Репозиторий
  • Wiki
    • Wiki
  • Сниппеты
    • Сниппеты
  • Активность
  • Диаграмма
  • Создать новую задачу
  • Задания
  • Коммиты
  • Доски с задачами
Свернуть панель
  • nikitronn
  • sverchok
  • Задачи
  • #4575
Закр.
Открыто
Задача созд. Июл 17, 2022 пользователемnikitronn@nikitronnВладелец

Add Catmull-Clark subdivision to Sverchok

Created by: GeneralPancakeMSTR

Problem statement

Catmull-Clark Subdivision (usually as OpenSubdiv) is an important tool standard to most (if not all) poly-based 3D modeling programs, and a core component of many users' modeling pipeline (including mine).

However, in Sverchok, there is no way to apply Catmull-Clark subdivision directly to mesh data, which is a significant drawback of an otherwise very powerful and complete tool.

Solution

A potential solution to this problem would be to somehow wrap the OpenSubdiv subdivision algorithm in Python, to make it compatible with Sverchok.

I am pleased to say that I have achieved this, specifically using ctypes for wrapping the C++ code from OpenSubdiv. I have also forked Sverchok, written a node that implements my subdivision wrapper, and tested its functionality directly in Blender:

vectorized_opensubdiv_final

Implementation

  • The code I wrote for wrapping OpenSubdiv's subdivision algorithm is available at my pyOpenSubdivision repository, which includes instructions on how to build and test it.

  • My fork of Sverchok that includes the OpenSubdiv node is available here. The modifications are as follows:

    • Added nodes/modifier_change/opensubdivide.py: The OpenSubdiv node.

    • Added utils/modules/ctypes_pyOpenSubdiv.py: Python code which communicates with the C++ code (using ctypes) that implements the OpenSubdiv Subdivision function and exposes it in a "friendly" way (i.e. as an easily useable function) to the OpenSubdiv node (opensubdivide.py).

    • Added utils/modules/ctypes_OpenSubdiv.dll: C++ code compiled into a Dynamic Linked Library (.dll) to expose the OpenSubdiv Subdivision function to ctypes (i.e. to ctypes_pyOpenSubdiv.py), on Windows x64 platforms.

    • Added utils/modules/ctypes_OpenSubdiv.so: C++ code compiled into a Dynamic Library to expose the OpenSubdiv Subdivision function to ctypes (i.e. to ctypes_pyOpenSubdiv.py), on Linux x64 platforms.

    • modified: .gitignore: +!/utils/modules/ctypes_OpenSubdiv.so, to include the Linux dynamic library file in version control.

    • modified: index.md: To make the OpenSubdiv node available from the Sverchok menu.

        ...
        ## Modifier Make
            LineConnectNodeMK2
            ---
            SvOpenSubdivideNode <- Add the OpenSubdiv node to Sverchok menu 
            SvSubdivideNodeMK2
            SvSubdivideToQuadsNode
            SvOffsetLineNode
            SvContourNode
            ---
        ...
        ```
    

Advantages

  • Speed: The OpenSubdiv library is extremely fast, capable of performing simultaneous subdivision on many meshes in roughly real time, the below example shows 3 levels of subdivision applied to 100 randomly variable cubes:

multi_opensubdiv

  • Low User Overhead: No extra or complicated steps must be taken to activate the OpenSubdiv node, and because ctypes is built into python, the linked libraries (.dll and .so files) should not be python version-sensitive.

Disadvantages

  • Platform Dependency: A dynamic library file containing the C++ code in binary format must be compiled separately for every platform Blender is available on, i.e. Windows, Linux, and OS X Intel and ARM. I have compiled libraries for Linux and Windows, but have yet to compile for OS X (this should not be too complicated, though).
Ответственный
Назначить
Оценка трудозатрат