[BUG?] Light2d renders as transparent when scene is rendered as a viewport
Asked Answered
O

5

0

Hi,
I've spiffed up my demo quite a bit, and I was going to add a feature that I've been thinking of doing for a bit.
Basically, my game runs at 800x600 resolution (A resolution that doesn't scale well in hindsight, but that's something that can't be remedied since I'm too far along.), and I wanted to make a rendering mode for the game that creates a border for the game in fullscreen so that it stays at a better resolution in terms of scaling.

Unfortunately, that doesn't seem to be an option for my game, since whenever a scene with Light2D nodes is rendered in the viewport, it considers the (subtract mode, rendering essentially a shadow) light2d as transparency, essentially making anything not in shadow transparent. Included is a screenshot of the issue.

I can't continue with this feature if it renders like this, is there a particular reason this happens? When the light is additive it seems fine, it's only when it's on subtract that it causes issues. Mix also seems effected, as it renders half transparency. I'd attribute this to an engine bug, but I want confirmation that there's no alternative that doesn't involve changing all of the lighting in the game before creating a bug report on Github.

In case it's not clear, this is on 3.X, not sure how it fares on 4.X.

Opsonin answered 17/11, 2023 at 22:19 Comment(0)
O
0

I managed to find a workaround, but it's a bit of a hack, if anyone else needs it.

I checked the box for Transparent BG on the viewport, but that made the part in the dark transparent rather than visible.

So I took a ColorRect the size of the game, made it black, and put it behind the display.

This seems to solve the problem for now, but I'm thinking that this is still an issue that needs to be investigated.

Opsonin answered 17/11, 2023 at 22:46 Comment(0)
W
0

Can you share a screenshot of the layout of your scene tree with the bug occurring?

If it is fixed in 4 and was done explicitly, then it should be simple for someone to backport to 3. Otherwise it may be less simple.

Wunderlich answered 17/11, 2023 at 23:27 Comment(0)
O
0

Wunderlich
Here is the scene tree for the base scene (Colorrect was added in as the solution, the Game texture is the render texture):

Here are the relevant properties for the render texture:

And here are the properties for the viewport. Transparent BG is now checked. Without it, everything with light subtracted was fully transparent. With it checked, everything with the light subtracted is semi transparent, which is still not intended.

Thanks so much for the quick reply!

Opsonin answered 18/11, 2023 at 0:1 Comment(0)
W
0

Threat Doesn't seem to happen on 4, though I only tested one version. Sometime after this weekend I can make sure I can replicate it on 3's latest. In the meantime, it can't hurt to submit a bug report if you want to do that. I hope that your hacky workaround is working sufficiently.

Wunderlich answered 18/11, 2023 at 1:48 Comment(0)
O
0

Wunderlich I'll submit one soon, thanks! Actually ended up scrapping the feature for now for other reasons, might pick it up later.

Opsonin answered 18/11, 2023 at 2:31 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.