- Home /
How do I fix directional light problem with multiple instances of prefab?
This works perfectly in the editor (mac). On the iOS device (iPad 3) it does not work correctly. I'm instantiating a simple low poly object multiple times. I'm using the mobile / diffuse shader with an opaque texture.
If I instantiate one prefab the directional lighting works correctly.
If I instantiate several the lighting dims on all objects. They are still lit but appear at 50% brightness.
I've tried switching the shader to an unlit variation and this works as expected. It appears related to directional lighting but, as yet, I haven't figured out the cause.
Thanks!
Try to the inspecter window the the model that you are using and set normals to calculate ins$$anonymous$$d of import
Yeah, already tried that. It made no difference. A single instance works, it breaks when there is two or more instances.
If I replace my models with a unity cube it works as expected. So it's definitely related to the model. I tried exporting as collada and wavefront - both have the same issue / doesn't work.
In case anyone is interested, I've submitted this issue with example as a bug. This is the unity project showing the issue: https://www.dropbox.com/s/d9nfd0zgtpdvkrd/directionalLightBug.zip
I too am seeing this issue. See my question here (http://answers.unity3d.com/questions/278948/why-does-the-lighting-on-an-object-change-when-mul.html)
It appears to have something to do with the object's scale. In the directionalLightBug project, if you change the object's scale to 1, the lighting behaves as expected. If the scale is 0.5, the lighting is twice as intense. If the scale is 2 the lighting is half as intense. Basically the light intensity seems to be inversely proportional to the objects scale.
Answer by idunlop_oefun · Jul 03, 2012 at 10:21 PM
I believe this is a bug. However, until Unity either a) fixes it or b) explains why this breaks I have figured out a workaround.
I created a simple script that instantiates a unique material for each instance of my prefab and sets the 'Renderer.Material' property with this new Material instance.
The downside is that this breaks batching. I'll update this answer if I hear back from Unity.
See comment from zmeinaz for alternate workaround.
Update: It's now fixed according to Unity. I assume that means it will be in the next build (> 3.5.3f3).
Update: This is still broken in 3.5.4f1 when testing on iOS device (iPad 3).
Update: This is now working in 3.5.5f2 (tested on iPad 3 / iOS 6b4).
I am still seeing this issue with Unity 3.5.4f1. Anyone else?