简体   繁体   中英

PBR rendering in Apple Metal

I want to work primarily on Metal-level, but I need PBR for some of my objects. I thought there should be nothing that can be done in SceneKit (which is based on Metal), which can't be done in Metal itself. But now I'am confused about PBR-rendering as it seems to be exclusive SceneKit feature. How is it working? Is there are some well known shaders or something, can it be reproduced on Metal level?

PBR isn't just about shaders; it's a holistic, empirical approach to representing and approximating physical phenomena.

SceneKit's PBR implementation is just one way of incorporating PBR techniques into a rendering engine. Metal doesn't expressly have PBR support, because Metal is a low-level API, and agnostic to rendering techniques.

If you want "the SceneKit look," you could hypothetically dump the Metal shaders that SceneKit uses to achieve its rendering, but that's only part of the picture. You need to understand how to construct render pipeline objects from these shader functions and build a multi-pass renderer that draws meshes with them (not just the initial pass that draws into an HDR render target, but subsequent passes that perform post-processing effects like bloom, vignette, tone mapping, etc.). You'll also need to ensure that the assets you're rendering have physically-plausible materials, which is an art unto itself.

My GLTFKit framework includes a Metal PBR renderer sample implementation. It's intended more for instruction than production use, but you might find it interesting to read the PBR shader source .

For another take on the same problem, see Apple's LOD with Function Specialization sample; it has some nice, clean PBR Metal shaders.

If you want to jump in and actually understand what's going on here, I encourage you to read some of the many papers and samples that have been published on the topic. Some of the most foundational ones are Burley 2012 , Karis 2013 , and Lagarde 2015 . Also consult Joey de Vries' articles on the subject. Plenty of advances have been made in the last few years, but this stuff is good for getting started.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM