Basically, if you create multiple ViewportFrames at the same time, each with a Sky parented to it, then one of the ViewportFrames will have incorrect lighting (determined by ViewportFrame.Ambient and ViewportFrame.LightColor). The effects that should be caused by these two properties seem to be less intense compared to all other ViewportFrames, even though they all use the same color values.
(EDIT: Additional information in replies.)
Repro
Create a ViewportFrame. Add a Sky and any number of reflective parts to it. Set up the ViewportFrame.CurrentCamera so that you can actually see the parts.
ViewportFrame.Ambient and ViewportFrame.LightColor can technically be anything, but for best results, set both to [0, 0, 0]. The bugged ViewportFrame will be significantly brighter than the rest.
At runtime, clone the ViewportFrame several times. All clones must be created at the same time.
Notice how one of the ViewportFrames’ lighting is less intense than it should be.
When you playtest, 10 ViewportFrames will be created on your screen, each showing a ball reflecting a skybox. Once the skyboxes load, notice how one of the ViewportFrames’ lighting is incorrect.
Workaround
Disabling and then re-enabling ViewportFrame.Visible seems to fix the problem on the affected ViewportFrame. However, if a ViewportFrame contains a Sky, then it may take a couple seconds to render. You also cannot toggle all ViewportFrames at the same time, or else one of them will end up being affected by this bug again, meaning that you would have to slowly loop through all ViewportFrames, and toggle one every couple seconds.
Uh, no? Every ViewportFrame, except for one of them, renders correctly. And the single bugged ViewportFrame always does seem to be a random one; the order is never consistent.
The first ViewportFrame you create will have the “bright” look. Any ViewportFrame created afterwards is going to be dark.
It is not random, your code does not have a wait method, so it looks like it’s random, but it really isn’t, it’s the first ViewportFrame that was created that gets the bright look.
Try with a wait function, you’ll see it’ll always be the first one.
So I guess to get around this bug I should preliminarily create one extra ViewportFrame before all the others, since that one is guaranteed to be bugged, and then delete it.
To be clear, the “bright” look is the incorrect lighting.
It happens not just in game but Studio as well. Something to do with first initialization of ViewportFrame object, it doesn’t take into consideration the Ambient and LightColor.
Making a ViewportFrame then deleting it while that one is the only frame remaining, will reintroduce the issue, because I guess it deinitializes when all are deleted?
Well, this bug technically doesn’t happen to the first ViewportFrame created, it just happens to the first one that is rendered.
For context, I have a bunch of portals placed around my game, with the “portal” effect being created by a SurfaceGui + ViewportFrame + Sky combo on each model. I tried to create the “bugged” ViewportFrame on a portal that was out of my sight, yet it kept happening on the portals that were closest to me.
I guess this is because SurfaceGuis can be occlusion-culled, so the “bugged” ViewportFrame wasn’t being rendered at all, even though it was technically “visible” in the world.
So, new workaround: Create the bugged ViewportFrame in a ScreenGui to force it to render immediately, and set ViewportFrame.ImageTransparency = 1 so that you can’t see it. You also cannot ever delete this ViewportFrame, or else the bug might happen again if more ViewportFrames are rendered later on, because like I said, SurfaceGuis are culled.