Is there a way to make a dark/low light SceneKit scene? - ios

I've searched and there doesn't appear to be a way to make a dark SceneKit scene... As in a scene with low lighting. I've removed all lights from my scene, set my autoenablesDefaultLighting to false, made sure it's unchecked in the storyboard, I even tried adding a black ambient light but that didn't do anything. Is there a way to make a SceneKit Scene with low/dark lighting??

Had to try this for myself, as it didn't sound right. Removing all lights from the default SceneKit game template does indeed result in a model lit with an ambient light. I expect it's some kind of default that kicks into action when SceneKit identifies you have no lights in your scene.
Adding a black ambient light doesn't seem to change this, however adding a single dark non-ambient (omni, directional, spot) does result in a dark scene. The following image is with a dark gray omni light, and no ambient light.
I don't think this matters too much in real use, you'd be unlikely to have a scene with no non-ambient lights. Certainly understand the confusion in this instance however.

SCNLightingModelConstant is worth a look.
The SceneKit demos (code provided at apple.com) from 2014 and 2013 are quite dark. There's plenty to learn from there.

Related

Keep original node lighting after using a light for another node

I am attempting to give my island more of a "3D" effect, as you cannot see depth in the grass hills.
My solution was to place the lights in the scene. I have placed a spot light above the island, however, the rock underneath is now black/really dark. I would like the rock underneath to be unaffected and stay lit. Here is what I have so far:
Even when placing an ambient light in the scene editor, it does not help at all with the rock (but slightly brightens the grass by a tiny amount).
The lighting model I am using is Blinn.
How can I keep my rock like it's original lighting?
I figured out to the answer to this very quickly after I made this post, even though I was stuck on this for about a day. It was actually very simple.
All you need to do is go into the original island scene file, and click on the rock and access it's Material Properties. Then change the lighting mode from Blinn to Constant:
Hope this helps anyone from the future, as there haven't been any other posts I have found about this before! :)

How to add directional light for shadows properly in sceneView of SceneKit?

I am learning ARKit. I'm placing Virtual Objects in Augmented Reality scene and struggling in these problems!
I am using this demo project from github
1- How to add only one directional light for all (separate) nodes in SceneView of SceneKit & Move directional light with camera position? So that my added shadow can also move with light direction.
If I translate the object shadows are working as it should be. But If I rotate object now shadow should not move on the plan. They are moving because of light is at fixed position.
2- Shadow is looking fine only in case If I add only one object on the plane. But If I add two or more objects more directional lights are adding in SceneView. Now every object has more than one shadows. I want it to restrict only one shadow.
I have added light and shadow plane in sceneKit editor. (not programmatically). Here are my scenekit editor's screenshots.
3- I have read and confirmed that shadow are adding only If I set directional light property to deffered. But in this case app is crashing If I call remove all nodes from sceneView's root node. My removing nodes code is.
self.sceneView.scene.rootNode.enumerateChildNodes { (node, stop) -> Void in
node.removeFromParentNode()
print("removed ", node.name as Any)
}
You can watch my apps video for more clearance. Apps video, How it is working now
My requirement is to add only one shadow for every object. When I Rotate and translate objects shadows should look real.
I also have tried it as removing light from scn file of vase, and add a separate light.scn file having only light in it. added These two (vase and light) nodes in sceneView. But No shadow is appearing.
Directional lights are interpreted from the shader only with their direction (that one light-red vector coming out of the node in Xcode). It does not matter where the position of the light is. Directional light are often used for imitating sun light.
I implemented a similar project so here is my attempt.
I added one directional light from a separate SCN-File to the scene when I initialize the SCNScene.
My settings for it:
castsShadow: true
mode: deferred (my App is not crashing, if I remove my objects from the scene :/ )
And actually thats it to make it work in my project.
One thing about your planes: I think you have not disabled castsShadow on the planes. Therefore a user can see the planes.
Edit:
I could reproduce the crash. It does occur when removing the directional light. Thats why the app is not crashing in my project. So you could do it like me and add the directional light in viewDidLoad() for example.

SceneKit Directional Light causing flickering

I'm trying to add a directional light in Scenekit to cast shadows, but it is causing weird artefacts on objects.
The orange block below has a material with default settings and the diffuse set to orange.
The directional light is pointing downwards, and the scale is increased, otherwise it has default settings. (Making the scale smaller still has the same issue).
When I pan the camera around the texture is covered in flickering lines and dots, it looks terrible.
This isn't visible on the simulator, only the device. What is going on and how can I fix it?
Thanks to Toyos I now know that self-shadowing is what's causing the lines. The docs for shadowBias say setting this value should correct it, but for me it made no difference.
In the end I fixed it by rotating the directional light by 2 degrees. It was originally at -90, pointing straight down. Changing this to -88 has completely removed all the artefacts.
Configure the zNear/zFar range of your light to make it as small as possible (but not clipping your world). The smaller the zRange is the more precision you will get.
You can also play with the shadowBias to limit the self shadowing artefacts

Lightning Shadow effect in CORONA SDK

I am trying to create a spotlight effect in my story book such that as the character moves around from one location to the other then the light focus moves towards that same character.Is it possible to do that in Corona SDK? How can I do that coz sprites aren't
helping me.Any idea regarding this.
I found some reference telling me that I can't do that
http://web-c2.anscamobile.com/forum/2012/10/27/dynamic-shadows-2d
http://developer.coronalabs.com/forum/2012/09/13/lightingshadows
Those two threads seem pretty definitive. You could create a spotlight pretty easy, but you can't cast shadows and the light moves different directions very easily.
If you want to do a spotlight without shadows, just create an image that's all black with a transparent hole in them middle that has some feathering around the hole. Make the black partially transparent so you can see the scene but have it a bit darker. You can them move the image around to be your spot light. You can also do it with a maskk (see the Flashlight example in the sample code)

Lights in Three.js not affecting meshes added to the scene after the light

Basically when I add a light to a scene, I need to wait ~100ms to add meshes or else the dynamic lighting will not be applied to the mesh. In my current implementation, I replace all of the relevant parts whenever a new light is added, although this seems inefficient and wrong. Is there an easier way to do it?

Resources