open-project-1 icon indicating copy to clipboard operation
open-project-1 copied to clipboard

Objects are black when the scene lighting is not baked

Open ciro-unity opened this issue 6 years ago • 4 comments

Short description All objects (both dynamic and static) are black when dragged into a new scene.

Expected behaviour Object should "work" automatically when dragged into a new scene.

To Reproduce

  1. Create a new scene.
  2. Drag any object from the /Prefabs folder (e.g. a character).
  3. Observe that the object is black.

Notes

  • Generating lighting, even if not the Baked GI, fixes the object. The object is probably becoming black due to missing ambient light information.

image

ciro-unity avatar Nov 21 '20 22:11 ciro-unity

I'm not that experienced in Unity so I'm trying my best by test-failure errors, I'm warning that my founding might not be clear/make sense :wink: :

For dynamic objects: we're using Skinned Mesh Renderer which doesn't support lightmap (they will be always dark without direct light?) - https://forum.unity.com/threads/problem-with-skinned-mesh-renderer.366293/

However I've played around with static objects, I've found that when I've set constant color in shader to value 1 (Shaders/CustomHLSL/CustomLighting.hlsl), objects get proper color. I assume that the light at the position of that object has wrong color (black?) and thus it doesn't enlighten it.

I'd like to follow up on fix, but I would need some more hint what can be wrong & what to check. Thanks.

Tatranskymedved avatar Nov 22 '20 21:11 Tatranskymedved

Hey @Tatranskymedved! Welcome to the project :) Have you followed the exact steps?

For clarification, when I say dynamic objects I mean not static. But they don't need to be SkinnedMeshRenderers. Both SkinnedMeshRenderer and MeshRenderer create the issue.

ciro-unity avatar Nov 22 '20 22:11 ciro-unity

Hi @ciro-unity , I've added PR, once you have little time, could You please review it & confirm if we want to do it this way and if we want light on all objects or just the static/with Baked GI? Thanks!

Tatranskymedved avatar Nov 25 '20 16:11 Tatranskymedved

@Tatranskymedved, regarding this issue, I think that the smallest impact needed to fix it without having to use branch should be:

image

(Backed GI) -> (one minus) -> (Step with edge to 1) will out 1 only if Baked GI will be zero and out 0 for any other value. So adding this value to the initial Backed GI node will force Backed GI to return a default value (1) if Backed GI is not defined.

Result from a brand new Default Scene: image

treivize avatar Jan 11 '21 11:01 treivize