Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SceneKit view renders as phong instead of physically based materials

I have several objects in my scene, all of which had the "lighting model" of their material set to be physically based.

When I run the app, the view I get looks nothing like the scene editor - it instead looks more like Phong materials.

Is there a root node I need to change in order to have it render physically based from the get-go? I'm new to objective-c, so I'm not sure if I need to set the lighting model of the root node to physically based, and if so, how I would access the root node (and furthermore, can the root node even have a lighting model attribute since it itself is not renderable).

My models were created in ZBrush, retopologized and UV mapped in UIViewController, and were converted to .dae files in Blender. Is it possible that one of those programs set the material shader to be phong? Wouldn't the SceneKit editor overwrite that and set it to physically based?

As far as I can tell, all versions of Xcode, iOS, and SceneKit are recent enough to support PBR.

Thank you for any help :)

like image 984
DanN Avatar asked Dec 09 '25 15:12

DanN


1 Answers

It's quite easy to apply a physically based shader to your model in SceneKit (or change its texture or color). If your model consists of several parts, find the part you need in the hierarchical level using the following approach:

enter image description here

enter image description here

SCNScene *scene = [SCNScene sceneNamed: @"art.scnassets/biplane.usdz"];

SCNNode *modelNode = [scene.rootNode childNodeWithName: @"biplane"      
                                           recursively: YES];

SCNNode *body = modelNode.childNodes[0].childNodes[0]
                         .childNodes[0].childNodes[0];

body.geometry.materials[0].lightingModelName = SCNLightingModelPhysicallyBased;
body.geometry.materials[0].diffuse.contents = [UIColor redColor];
body.geometry.materials[0].metalness.contents = @1.0;
body.geometry.materials[0].roughness.contents = @0.0; 

Resulted biplane.usdz model

enter image description here

like image 97
Andy Jazz Avatar answered Dec 11 '25 06:12

Andy Jazz