问题
I am working on a 3D map in SceneKit. When I enable the Cast Shadow Property of a directional light in SceneKit, the shadows appear, but the application becomes very slow.
How do I reduce the lag while still maintaining shadows in the scene?
回答1:
Use Fake Shadows
(shadows generated and baked as a texture in 3D authoring tool) rather than True Shadow Map
. To apply fake shadows as a texture for 3D plane use PNG
file format with premultiplied alpha channel (RGB * A
).
It helps you get rid of (or considerably reduce) application lag while using shadows in SceneKit or ARKit.
To see how it works just download a sample application from here: Handling 3D Interaction and UI Controls in Augmented Reality.
来源:https://stackoverflow.com/questions/51070521/reduce-application-lag-while-using-shadows-in-scenekit