ARkit:How to make your model more realistic

Light

Light types

Ambient

Ambient simulates an equal amount of light hitting the object from all directions. As you can see since light hits the object equally from every direction there are no shadows.

directional

Directional light has a direction but no source location, just imagine an infinite place emitting light from the surface.

Omni

Omni also was known as a spotlight. This is a light that has direction (like directional) but also a position. This is useful if you want to perform calculations like how intense the light is based on the distance of the geometry from the light source.

Spot

spot light is like omni, but as well as direction and position, a spot light falls off in intensity in a cone shape, just like a spot light on your desk.

IES

(Illumination Engineering Society) light illuminates the scene with shape, direction and intensity of illumination specified in a IES standard file. This file format was created for the electronic transfer of photometric data over the web. IES light files are created by many major lighting manufacturers and can be downloaded free from their websites. SCNLight provides also the iesProfileURL property to import the light IES standard file into SceneKit. After setting this property to a URL that references a valid IES profile, you must set the light’s type property to IES to load that file and apply its effect.

probe

light can be used to measure the direction and the intensity of the light in a point of the 3D space. They are local lights facing towards the scene. They capture the local diffused contribution. So when shading a point on a surface we can find the closest light probes and interpolate lighting from these probes. Light probes are really lightweight and efficient. Apple recommends to add many of them to the scene

Light setting

autoenablesDefaultLighting

if you set this to true, SceneKit will add an Onmi directional light to the scene, located from the position of the camera and pointing in the direction of the camera. The intensity of the light is always 1000 by default. And it make 3D model unrealistic so let’s turn it off

self.sceneView.autoenablesDefaultLighting = false;

automaticallyUpdatesLighting

If this value is YES (the default), the view automatically creates one or more SCNLight objects, adds them to the scene, and updates their properties to reflect estimated lighting information from the camera scene.
Sound great but it doesnt work well.

isLightEstimationEnabled

If you dim the lights in your room for example, and want to apply these lighting conditions on your virtual objects to make them more realistic, this is what you want to use.
Always better if set it to true.

func renderer(_ renderer: SCNSceneRenderer, updateAtTime time: TimeInterval) {
        DispatchQueue.main.async {
            // If light estimation is enabled, update the intensity of the model's lights and the environment map
            if let lightEstimate = self.session.currentFrame?.lightEstimate {
                self.enableEnvironmentMapWithIntensity(lightEstimate.ambientIntensity / 1000)
            } else {
                self.enableEnvironmentMapWithIntensity(25)
            }
        }
    }
if sceneView.scene.lightingEnvironment.contents == nil {
            if let environmentMap = UIImage(named: "Models.scnassets/sharedImages/environment_blur.exr") {
                sceneView.scene.lightingEnvironment.contents = environmentMap
            }
        }
        sceneView.scene.lightingEnvironment.intensity = intensity

Render

The way you render your model effects so much to how it looks. I will give you a very short explanation about some properties of meterials. Short but good enough.

Shading

Constant

As you can see

Lambert

no highlight

Phong, Blinn, Physically Based

These 3 modes show color, light, shadow,… close to real word with higher cost.

Diffuse

Setting for surface. It also can be thought of as a material’s “base” color or texture.

Metalness

Determine how metallic the material’s surface appears.

Roughness

Determine the apparent smoothness of the surface.

Normal

Transparent

determines the opacity of each point in a material.Use this property to selectively make parts of a material appear transparent.
Setting the transparent property’s contents to any solid color uniformly fades the opacity of the material based on that color’s opacity value. To make parts of a material appear transparent, set the property’s contents to an image or other texture-mapped content whose alpha channel defines areas of full or partial opacity.

Occlision

emission

Manage the material’s specular response to lighting.You can use an emissive map texture to simulate parts of a surface that glow with their own light

Occlision

A nature, universe, science, music, love lover

Leave a Reply

Your email address will not be published. Required fields are marked *

Bitnami