Dear Scenekit Experts,
I'm trying to get a material resembling clear glass using PBR. It should be 99% transparent while also very reflective.
Here's the sample I'm using:
lightingModel = .physicallyBased
metalness.contents = UIColor(white: 1.0, alpha: 1.0)
diffuse.contents = UIColor(white: 0.2, alpha: 1.0)
roughness.contents = UIColor(white: CGFloat(0.03), alpha: 1.0)
transparencyMode = .dualLayer
isDoubleSided = true
transparency = 0.2
The problem is that the amount of reflections seem to be affected by the transparency
:
transparency = 0.01
: the reflections of the scenes environment map are barely visible anymore.transparency = 0.2
: I get some nice reflections, but unfortunately now my whole object is visible, i.e. it looks like a piece of tinted glass (depending on which color I set indiffuse
).
How can I make it clear , i.e. see-through while still seeing the reflections ?
So, I think I figured it out myself now. The solution was to set all alpha material values to
1.0
(diffuse
,transparency
etc) and then set the alpha in the fragment shader based on the amount of specular lighting.Fragment Shader:
Basically this shader has