I tried loading an .hdr
file to use it as a skybox and use its lighting informations. This is the code I used:
backgroundColor = UIColor.gray
// check if a default skybox is added
let environment = UIImage(named: "studio_small_09_2k.hdr")
scene?.lightingEnvironment.contents = environment
scene?.lightingEnvironment.intensity = 1.0
scene?.background.contents = environment
Unfortunately I recieve a grey screen and also no errors. Has anyone experience in using hdr files in SceneKit?
XCode Version: 13.2.1 iOS version: 15.3.1 hdr file: https://polyhaven.com/a/studio_small_09
I usually use a Cube Texture Set, where each of 6 images is square
(height == width)
.Also, the following cube map representations are supported:
(height == 6 * width)
(6 * height == width)
(2 * height == width)
Here's a SwiftUI code:
Pay particular attention – you need
.physicallyBased
lighting model to get HDR or EXR reflections.And let's set it for BG:
Why your
.exr
doesn't work?The solutions is simple: delete your
.exr
from project, empty the Trash and after that drag-and-drop.exr
file, inChoose options for adding these files
window chooseAdd to targets
:Now your
.exr
must work.