[icon ] blenderdumbass . org [icon scene] Articles

Why Night Scenes in Video Games are so Hard to Make Right?

January 02, 2025

๐Ÿ‘ 383

https://mastodon.social/ : ๐Ÿ‘ 3
https://odysee.com/@blenderdumbass:f/why_night_scenes_in_video_games_are_so_hard_to_make_right_:2 : ๐Ÿ‘ 1
https://lemmy.dbzer0.com/ : ๐Ÿ‘ 1
https://blenderdumbass.org/ : ๐Ÿ‘ 4
https://blenderdumbass.org/articles : ๐Ÿ‘ 1
https://mastodon.online/ : ๐Ÿ‘ 2
https://blenderdumbass.org/articles/the_incels_of_computing:_the_depressive_defense_mechanisms_of_free_software : ๐Ÿ‘ 14
https://blenderdumbass.org/articles/why_night_scenes_in_video_games_are_so_hard_to_make_right_ : ๐Ÿ‘ 1
https://phanpy.social/ : ๐Ÿ‘ 2
https://duckduckgo.com/ : ๐Ÿ‘ 2
https://www.google.com/ : ๐Ÿ‘ 2
https://blenderdumbass.org/articles/a_rant_about_making_a_multiplayer_game : ๐Ÿ‘ 1
https://blenderdumbass.org/articles/upbge_-_what_is_depsgraph__and_how_to_optimize_for_depsgraph_ : ๐Ÿ‘ 1
https://www.qwant.com/ : ๐Ÿ‘ 1

#DanisRace #MoriasRace #Game #Gamedev #UPBGE #blender3d #animation #GTAClone #programming #project #light

License:
Creative Commons Attribution Share-Alike
Audio Version




[avatar]by Blender Dumbass

Aka: J.Y. Amihud. A Jewish by blood, multifaceted artist with experience in film-making, visual effects, programming, game development, music and more. A philosopher at heart. An activist for freedom and privacy. Anti-Paternalist. A user of Libre Software. Speaking at least 3 human languages. The writer and director of the 2023 film "Moria's Race" and the lead developer of it's game sequel "Dani's Race".


From 1 years ago.
Information or opinions might not be up to date.


10 Minute Read



Yesterday on Dani's Race Development Stream I went on an ADHD tangent away from fixing spaghetti and into trying to make the city look good at night. โ†ฉ Reply

The problem is that the city has tons of lights all around the place, and placing all of them will simply fry the GPU. I can do that in the film version, but in a game everything should render fast enough to be responsive. And more than that, UPBGE has an optimization problem, so I have to be clever about how and if to do it. โ†ฉ Reply

[embedded image]
โ†ฉ Reply

Until yesterday I thought that street lights was impossible to make, so I was trying to find some kind of other ways to brighten up the frame at night, so at least it would be visible, but yesterday I stumbled upon something that might work. โ†ฉ Reply

โ†ฉ Reply

Please go look at the petition for the previous version of the game. As soon as it is released I can start releasing newer updates, which includes a lot of stuff, since the last time the game was packaged was in September. It is up to you to make the game released. So please release it. โ†ฉ Reply

Why Petitions? โ†ฉ Reply


The problem(s)


UPBGE rendering with the Blender's EEVEE renderer can look phenomenally pretty, but it is not particularly the most optimized engine / renderer out there. Since EEVEE was built not for games, but rather for previewing scenes in a more responsive way before rendering them, it can be rather tricky to make it work on something other than the beastiest computers out there. โ†ฉ Reply

More than that, EEVEE has a limit on the amount of lights that you can put in the scene, which I'm sure should not a be a great hustle to turn off, but is probably a good thing to keep actually. โ†ฉ Reply

I have a computer that is beyond average in specs, based on the target demographic, of those people who might be interested in something like Dani's Race right now. Most GNU / Linux users have extremely under-powered machines that barely run. So I need to not only think about some ways to implement the game that will work on my machine. But also some ways that will make it at least somewhat playable on older computers. c:0 โ†ฉ Reply

The game has 619 light poles at the moment. If I would put so many lights all around the scene, the computer will explode! โ†ฉ Reply

Solution 1, Fake it


I already made an adaptation of this same city into a different game called SuperTuxKart, where the user-base is even more limited with their hardware and where the engine is not as capable. Yet, as you can see, the lights are present and the road is lit. c:0 โ†ฉ Reply

[embedded image]
โ†ฉ Reply

This was done with 2 tricks. โ†ฉ Reply

For the shadows and general visibility of the karts I used the normal in-game sun which is one light lighting the entire scene. But when in the same time the background is dark, it already kind of resembles night in a weird way. And so your mind subconsciously solves the issue making it seem like the sun-light is some artificial light from some kind of a street lamp. โ†ฉ Reply

Then for the terrain model I baked a texture containing all of the lights and shadows that would result from all those lights. Making it look like it is lit, but it is only a texture. โ†ฉ Reply

This approach could work for Dani's Race too, if only I didn't want day scenes as well. But since I want it to have a dynamic day-night cycle, this approach would not work. โ†ฉ Reply

I actually tried adding some baked light to the terrain, which I would slowly fade in an out of existence based on the in-game time, so there will not be any of it during the day. But it made the ground material so demanding that some people had a significant drop in FPS just pointing the camera at it. โ†ฉ Reply

[embedded image]
โ†ฉ Reply

Early on, when I just made the fist steps into rendering the night in the game, I tried putting a bazillion lights, quickly understanding that my computer would not survive it long. And then I simply gave up. Making the night sky be a bit brighter than usual, when lighting objects, so at least something would be visible. Though as you can see on that screenshot I've added a kind of neon glow to the cars as well, making it look a bit more salvageable. โ†ฉ Reply

[embedded image]
โ†ฉ Reply

This screenshot of the sky material is not particularly useful to understand the trick. So here is a simple version of it. โ†ฉ Reply

[embedded image]
โ†ฉ Reply

As you can see you can pipe different texture information to the rendered bases on whether it is lighting the surfaces of objects, or it is being directly shown in the camera. Making the stuff directly to the camera dark, like the night sky, while making it way brighter for the objects, gives some visibility, while still making you feel like it is night. โ†ฉ Reply

And then adding colored, shadow-less lamps into cars, for the neon glow, makes it look like a start of something good. But it is not yet there. โ†ฉ Reply

Solution 2, swap lights.


Compare it to the stuff I made yesterday on the steam. โ†ฉ Reply

[embedded image]
โ†ฉ Reply

Here I am using 2 huge area lamps to simulate the light on the street. And basically as soon as you pass under one of them and it is no longer needed, the game moves that light to the front. The best way to understand it is to actually see the effect in action in the game itself. โ†ฉ Reply

โ†ฉ Reply

โ†ฉ Reply

โ†ฉ Reply

As you can see it is a pretty seamless effect. Even though I am using only 2 lamps. And here is how I did it: โ†ฉ Reply

def NightLightsEffect(car):

    # Night Lights spawning around
    # the main characters when driving
    # at night.

    scene = bge.logic.getCurrentScene()
    dani = scene.objects["Dani_Box"]
    cam = scene.active_camera

    timeIs = bge.logic.globalDict["time"]

    # If it is day, do nothing
    onTheRoad = Vehicle.NearRoad(car) < 50
    if ( 7 < timeIs < 18 ) or not onTheRoad:
        return

    # Initilize 2 street lights
    if "car-nigh-lights" not in bge.logic.globalDict:
        bge.logic.globalDict["car-nigh-lights"] = []

    lights = bge.logic.globalDict["car-nigh-lights"]

    while len(lights) < 2:

        light = Reuse.Create("Area_Lamp")
        light.scaling = [10,10,10]
        light.blenderObject.data.energy = 1000
        light.blenderObject.data.shape = "DISK"

        lights.append(light)

        light.position = Vehicle.RelativePoint(car, (0,-50*(len(lights)),10))

    # Moving the lights in front

    # Sort based on the point

    spawnPoint = Vehicle.RelativePoint(car, (0,-100,10))
    lights = sorted(lights, key=lambda x: x.getDistanceTo(spawnPoint))

    if lights[0].getDistanceTo(spawnPoint) > 50:
        for light in lights:
            tp = light.position.copy()
            tp.z -= 10
            if cam.pointInsideFrustum(tp) == cam.OUTSIDE \
            and light.getDistanceTo(car) > 20:
                light.position = spawnPoint
                light.position.z += 50
                topos = light.position.copy()
                topos.z -= 200
                ray = light.rayCast(topos)
                if ray[1]:
                    light.position = ray[1]
                    light.position.z += 10
                break




As you can see the current implementation basically puts the new lights about a 100 meters in front of the car, 10 meters above the road, if the car is close to the road ( so that this effect will not work on stretches of dirt in between roads, where everything should be dark ). โ†ฉ Reply

This is a bit basic and kind of stupid. It results in a lot of lights spawning in weird places. But for the proof of concept it is beyond amazing. Even with all those problems it already looks and feels fantastic. โ†ฉ Reply

Another problem is the huge reflection that the area lamp makes on the road itself. I like what it does to the car, but not what it does to the road. I'll have to mess around with light setting to make it look more properly proper. But again, this is beyond what I would expect. โ†ฉ Reply

I literally thought I was trying something that I wouldn't like and would completely discard immediately. But then it seems I did something I actually do like and want to develop further. So I guess you should mess around with your code ones in a while and go on ADHD tangents, because they might bring something good. โ†ฉ Reply

Happy Hacking!!! โ†ฉ Reply


[icon unlike] 0
[icon left]
[icon right]
[icon terminal]
[icon markdown]

Find this post on Mastodon

[avatar]  ็ฟ ๆ˜Ÿ็Ÿณ c:0


Most GNU/Linux users have extremely under-powered machines that barely run.
โคด View
Most of such users have an incredibly powerful machines, clocked at billions of Hz, with billions of bytes of RAM, it's just that software expands to use all resources.

into a different game called SuperTuxKart, where the user-base is even more limited with their hardware
โคด View
Supertuxkart is extremely resource intensive, but is at least playable on GNUbooted thinkpads at low settings.

On extremely fast cards like the 780 Ti, supertuxkart does run quite well (nouveau reclocking is still quite limited, but the developers has gone and fixed most pipeline stalls for that game).

The same is true for Xonotic, but sadly not minetest or xmoto.

... replies ( 1 )
[avatar]  Blender Dumbass c:1



@็ฟ ๆ˜Ÿ็Ÿณ Sadly the general public ( if we want to convince them ) expects billions of polygons and raytracing. They expect video games to compete graphically with Avatar movies.




[icon reply]
[avatar]  Blender Dumbass c:1


... c:0
[avatar]  ็ฟ ๆ˜Ÿ็Ÿณ c:0


Most GNU/Linux users have extremely under-powered machines that barely run.
โคด View
Most of such users have an incredibly powerful machines, clocked at billions of Hz, with billions of bytes of RAM, it's just that software expands to use all resources.

into a different game called SuperTuxKart, where the user-base is even more limited with their hardware
โคด View
Supertuxkart is extremely resource intensive, but is at least playable on GNUbooted thinkpads at low settings.

On extremely fast cards like the 780 Ti, supertuxkart does run quite well (nouveau reclocking is still quite limited, but the developers has gone and fixed most pipeline stalls for that game).

The same is true for Xonotic, but sadly not minetest or xmoto.


@็ฟ ๆ˜Ÿ็Ÿณ Sadly the general public ( if we want to convince them ) expects billions of polygons and raytracing. They expect video games to compete graphically with Avatar movies.

[icon reply]
[icon question]











[icon games]Dani's Race

  Pinned  

[thumbnail]

[avatar]  Blender Dumbass

๐Ÿ‘ 643



Continuing the saga of Moria and Dani, Dani's Race is a Free / Libre Software video game that aims to compete with AAA titles.


#DanisRace #MoriasRace #Game #UPBGE #blender3d #animation #GTAClone #programming #project


[icon articles]UPBGE - What is Depsgraph? And How to Optimize for Depsgraph?

[thumbnail]

[avatar]  Blender Dumbass

๐Ÿ‘ 192



You see things like "Physics", "Logic" and even "Rasterizer" and you immediately understand what you need to do to optimize you game. But "Depsgraph"?... It looks like a mysterious thing that nobody knows nothing about. Yet is it one the most problematic things there is in your game. And you are going mad just trying to figure it out.



#DanisRace #MoriasRace #Game #Gamedev #UPBGE #blender3d #animation #GTAClone #programming #python #project #performance #depsgraph


[icon videos]PeerTube | Bugs! How are they fixed? | Also First Person Mode | Dani's Race UPBGE Blender 3D on GNU / Linux

[thumbnail]

[avatar]  Blender Dumbass

๐Ÿ‘ 29 ๐Ÿ’ฌ 16



In this video I fix some bugs in Dani's Race. And also implement a first person mode.


#DanisRace #MoriasRace #Game #UPBGE #blender3d #animation #GTAClone #programming #project #gamedev #freesoftware #gnu #linux #opensource


[icon videos]PeerTube | Dani's Race | First Year of Development

[thumbnail]

[avatar]  Blender Dumbass

๐Ÿ‘ 37 ๐Ÿ’ฌ 1




The story of the First Year of development of Dani's Race.


#DanisRace #MoriasRace #Game #UPBGE #blender3d #animation #GTAClone #programming #project #gamedev #freesoftware #gnu #linux #opensource


[icon codeberg] Powered with BDServer [icon python] Plugins [icon theme] Themes [icon analytics] Analytics [icon email] Contact [icon mastodon] Mastodon
[icon unlock]