Houdini Ứng Dụng SDF Để Culling Geometry Và Tối Ưu Scene Large Scale Trong VFX & Animation

Sau khi đã thực hiện bài viết SDF Signed Distance Field tôi nhận thấy cần thêm phần nội dung thực tế ứng dụng này cụ thể hơn khi sử dụng vào trong sản xuất VFX & Animation.

Đây là một creation của Pixar animation họ ứng dụng và phát triển trên GPU (tại thời điểm phát hành và sản xuất thì kinh òi), họ cull đi các geometry không cần trong scene để render nhẹ hơn.


ứng dụng của Disney Pixar trong sản xuất phim hoạt hình xử lý tối ưu cho bối cảnh siêu lớn Large Scale Geometric Visibility Culling Trên Phim Hoạt Hình BRAVE 2005

Link: https://graphics.pixar.com/library/VisibilityCulling/

[quote title=”Disney Pixar Text Memo Abstract]Disney/Pixar’s Brave is visually complex, containing fully clothed and articulated crowds characters, a forest full of vegetation, ruins littered with debris, and a full fledged castle. In fact, it is so complex that our previous methods to remove unnecessary geometry are no longer adequate in keeping the renders feasible.

On prior shows, we used a low quality render to determine an object’s visibility per shot. However, even a shot-level removal of the geometry limited the artist’s turnaround times. To address this, we developed a new two pass algorithm that aggressively culls geometry on a per frame-level, while maintaining accurate visibility. In addition to our implementation that uses a software renderer, we developed a GPU version that allows immediate geometry removal.[/quote]

Tôi biết đến tài liệu này khoảng năm 2013 ~ 2014 tuy nhiên chỉ đọc và hiểu là họ muốn làm gì chứ không đủ trình độ để làm theo nhưng phần nội dung cũng giúp ít nhiều, lúc đó các dự án tôi dùng chính là 3DS Max nên sau đó tôi có mua phần mềm Forest Pack Pro để sử dụng phần culling sẵn có, một đôi lúc phần animation culling hoạt động không được tốt lắm, khi các geometry bị nhảy, sau này dùng Houdini tôi hoàn toàn hiểu việc này. 

Dưới đây là sản phẩm sử dụng có Forest Pack Pro

https://youtu.be/w-rVm4r8nEE

Ứng Dụng Với Houdini

Hiện nay thì đang dùng các phương án camera frustume dựa trên normalized device coordinates (NDC) và rất hiệu quả để trim đi cái phần không cần.

Cái city trong cái build này anh làm bằng procedural, cũng như các fracture rãi làm asset và prop của environment, anh đã dùng SDF để culling đi các vị trí không mong muốn theo camera và sử dụng nó như 1 dạng geometry chỉ có trong scene nhằm tối ưu bộ nhớ khi render làm cho scene nhẹ đi hẳn (vì chỉ hiển thị thứ nằm trong camera), đây là kết quả, mấy cái này này đều khác nhau.

https://www.youtube.com/watch?v=sPWDqgcmq5k

Và cũng dùng technique NDC để trim những cái geometry hay particle theo camera trong scene này. Tuy nhiên việc culling trên mỗi data (fluid simulation, whitewater, geometry, … ) là khác nhau về xử lý tình huống, theo tài liệu của Pixar thì họ xử lý trên frame, đến nay tôi cũng không biết cái đó là gì.

https://youtu.be/C0YLeevs6rg

Kỹ thuật culling này một phần tôi dùng đã dựa theo SDF tức cái gì bên trong volume thì cull đi kết hợp trong không gian NDC

Tôi nghĩ rằng phần RenderMan 24 hiện nay đã tích hợp sẵn, vì từ nhưng phiên bản RenderMan 20 đã có RIS xử lý attribute này chỉ chuyên để tối ưu scene và culling geometric. 

Mà trong tài liệu của MPC làm phim Lion King cũng có đề cập đến. 

[quote title=”MPC Making Large Scale Environment Lion King”]To be able to render and simulate these vast environments with millions of pebbles, rocks, moving grass blades and plants we needed to find a way to reduce the complexity as early as possible and promote selected areas for hero simulations.

Inspired by [Repasky et al.2013], we introduced a template-based, procedural processing step to optimize each environment per shot: Based on the camera and configurable heuristics, the level of detail for each instance was calculated. Any instances not within the camera’s frustum, occluded by the environment or too small to be seen were also automatically culled. What is more, TDs could also add sequence or shot specific edits to these operations to further reduce the complexity. This way we were able to produce a highly optimized per shot representation of the scatter with a geometrical complexity often reduced by 95 percent. The latter helped creating localised simulation set-ups, higher quality QC dailies (providing more information earlier in the pipeline) and further reducing the cost of our final renders.[/quote]

Tài liệu liên kết có thể đọc ở đây: https://www.mpc-rnd.com/the-king-has-returned-advancing-technologies-for-the-lion-king/

Và đây là tài liệu của RenderMan 24: https://rmanwiki.pixar.com/display/REN24/Coordinate+Systems

Một đoạn code xử lý chuyển camera world space về local space NDC thì thường có kết quả như sau

// Camera Frustrum [Point Wrangle]
vector pos = toNDC("/obj/cam1", @P);
if (pos.x < 0+ch('overLeft')) removepoint(0, @ptnum); if (pos.x > 1-ch('overRight')) removepoint(0, @ptnum);
if (pos.y < 0+ch('overDown')) removepoint(0, @ptnum); if (pos.y > 1-ch('overUp')) removepoint(0, @ptnum);

Và chưa kể trong một số phân đoạn làm simulation bãi biển tôi còn thường hay dùng phương án lấy silhoutte geometry của một object bằng đoạn VEX sau đây

// Silhouette Retain [Point Wrangle]
vector pos = toNDC("/obj/cam1", @P);
pos.z += ch("offset");
@P = fromNDC("/obj/cam1", pos);

Culling Trong Unreal Engine

Tối ưu scene large scale trong các data set lớn không chỉ dùng các phương án giới hạn drawcall mà với công cụ hiện đại ngày nay thì việc kết hợp camera frustum culling với cả real-time là điều hoàn toàn khả dĩ, năm 2019, Epic Games đã tung ra video thực hiện việc culling geometry bằng camera frustume trên Unreal Engine. 

https://youtu.be/6WtE3CoFMXU

Post Author: Vu Pham