Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Glass effect in SceneKit material

I want to make glass effect in SceneKit. I searched in google but there's no perfect answer. So I'm finding SceneKit warrior who can solve my problem clearly. There's an image that I'm going to make.

Final

It should be looks like real. The glass effect, reflection and shadow are main point here. I have obj and dae file already.

So, Is there anyone to help me?

like image 905
Fury Avatar asked Oct 13 '17 01:10

Fury


1 Answers

Create a SCNMaterial and configure the following properties and assign it to the bottle geometry of a SCNNode :

.lightingModel = .blinn
.transparent.content = // an image/texture whose alpha channel defines
                       // the area of partial transparency (the glass)
                       // and the opaque part (the label).
.transparencyMode = .dualLayer
.fresnelExponent = 1.5
.isDoubleSide = true
.specular.contents = UIColor(white: 0.6, alpha: 1.0)
.diffuse.contents =    // texture image including the label (rest can be gray)
.shininess =           // somewhere between 25 and 100
.reflective.contents = // glass won’t look good unless it has something
                       // to reflect, so also configure this as well.
                       // To at least a gray color with value 0.7 
                       // but preferably an image.

Depending on what else is in your scene, the background, and the lighting used, you will probably have to tune the values above to get the desired results. If you want a bottle without the label, use the .transparency property (set its contents to a gray color) instead of the .transparent property.

like image 124
Xartec Avatar answered Oct 23 '22 17:10

Xartec