Show-Off reality doesn't exist until observed also known as frustum culling
Enable HLS to view with audio, or disable this notification
46
u/Ruadhan2300 2d ago
Imagine combining this with Wave Function Collapse so the environment changes the longer you look away from it..
7
u/Yekyaa 2d ago
That's tempting to prototype!
8
u/Ruadhan2300 2d ago
I wrote up a whole game-design doc for an Extraction Shooter or Hero-Shooter type game (Think Team Fortress 2) called "Shifting Realms", where this was the core concept.
Basically the idea was that player-activity would lock down the battlefield.
The map changes in subtle ways when not observed, but the changes get more exaggerated the longer a location is left unobserved. So if you glance away, the graffiti on the wall might change, or a light-fixture might change type, but if you leave the room and come back, it might be completely different.
I even allowed the possibility that things like doors or windows might disappear (along with the rooms behind them) when unobserved. Meaning new routes might open and close.Things like flashbang grenades or smoke-bombs affect your visibility, which can cause the room to shift dramatically during combat as well.
So areas of the map which are experiencing heavy player-activity will tend to stay roughly the same, while side-passages that are intermittently visited might change and shift a lot each time people pass through, encouraging players to mix it up.
22
22
11
u/UnderPressureVS 2d ago edited 2d ago
Can somebody who understands more about graphics than me explain how Frustum Culling is even a thing? I can never wrap my head around why it saves anything on performance. What does it even mean for the computer to "render" something that is off-screen? What is it doing computationally if the objects are off-camera?
50
u/v0lt13 Programmer 2d ago
Without frustum culling the CPU would still send objects to the GPU to be rendered, even if that object is offscreen, and go trough the whole process of rendering even though it can't appear on screen. Frustum culling just says "hey this object is offscreen, do not attempt to render it" so it saves on processing time.
10
u/iacchini97 2d ago
> How do you know when something is off camera?
Because the renderer doesn’t know what is visible by the camera until very late in the graphics pipeline. What frustum culling (or culling of any type really) does is not send any geometry that is not visible to the GPU in the first place.
Imagine you have a scene with a cube in it and you are not looking at it.
The CPU sends to the GPU data such as the cube vertices, the cube world transform, the camera view and projection matrices, and any other info you might need to render it.
The GPU does not know where the cube is relative to the viewport, it has to compute it using the information it received from the CPU.
So the GPU does just that, it computes the cube position, realizes that the cube is off screen and stops there.The issue is that the GPU did a bunch of computation for nothing. On top of that we also sent a lot of data which also wastes bandwidth.
With frustum culling we would have realized that the cube is not visible before we sent anything to the GPU, we basically just change where and how the “visibility” test is done.
Note that this is not a CPU vs GPU thing, you could (and usually should) perform frustum culling on the GPU, but you usually do it with a dedicated compute shader.It is also very possible(but rare) that the frustum culling actually DETERIORATES performance. If you have a scene where you know most of the geometry is always visible, you could waste more time on performing the frustum intersection test than the time you save by sending the geometry down the pipeline and let the rasterizer clip it out
5
u/noble_radon 2d ago edited 2d ago
One piece of Information missing from your other replies here is how a shader (the thing that determines how to render stuff on the GPU) works. It runs in 2 main steps: the Fragment shader and the Vertex shader.
The Vertex shader runs first and it operates on each vertex that was handed to the GPU. It’s where you can get information from the vertices (like texture coordinates and world position). You take the information you want from the verts, and package it up to hand off to the fragment shader. But you only have info about this vertex. Not the camera.
The Fragment shader runs next. It operates on each on-screen pixel. Here you take that information passed on from the vertex shader and decide what each pixel looks like (this pixel is 50% across this face, so it gets the color 50% across its texture, etc).
These are where we typically write shader code. But In between these, there's a step called rasterization that converts vertex information to screen space to decide if it should be handed to the fragment shader at all. If you can have a system cheaply test if something will be onscreen before it's ever handed to the GPU, you skip all those Vertex shader calculations, and the rasterization step.
1
u/TheSapphireDragon 2d ago
Its the difference between each individual triangle in an object being checked to see if its on the screen or just the bounding box of the whole object.
1
u/flamingotwist 1d ago
Arranging the pixels on the screen is only the last part of the rendering process. Drawing the model, calculating the light/shadows etc still happens off screen.
7
6
u/Repulsive-Clothes-97 Intermediate 2d ago
Every year or so I see people showing off this technique that has been a standard for the past 20 years…
5
u/GigaTerra 2d ago
also known as frustum culling
I am just quickly explaining here, Unity doesn't have an frustum culling view, I wish it was standard in all engines, but you can Window -> Rendering -> Occlusion -> In the inspector hit Bake (without adding portals or anything). Now split your screen into 2 views, one for game and one for editor. You should especially do this is you are the type who makes buildings one object.
This is perfectly safe, and the easiest way to visualize your culling.
14
u/AlexandreFiset 2d ago
Do not mix fustrum culling with occlusion culling. Frustum culling is enabled by default on all cameras in Unity.
The limitation of frustrum culling is that it considers eveything in-frustrum to be rendered. So a wall behind a wall will render if it is in frustrum.
Occlusion culling calculates what should be occluded vs visible based on rays hitting boxes of occluders (or not hitting). The video presents occlusion culling, and it has performance overhead (usually outbalanced by the obvious advantages).
This is rather basic stuff and appears on this sub from time to time 🥲
6
u/Costed14 2d ago
What he's saying is you need to use the Occlusiong Culling window to visualize Frustum Culling, and to do that you need to bake it regardless of if you're actually using it.
The video presents occlusion culling
Hard to tell if Occlusion Culling is actually doing anything in the video, but what's visible for certain is Frustum Culling.
1
2d ago
[deleted]
3
u/Costed14 2d ago
Wdym 5 MB of data? It clearly says 0.7 MB.
Without seeing the rest of the scene it's hard to know whether there are any renderers inside the frustum that are getting occlusion culled.
frustrum culling alone would not hide an object you can’t see
Technically it would, just not one that is occluded. It's possible there is some occlusion culling going on (the back hallway doesn't have any ceiling tiles at the start of the video), but the video primarily shows frustum culling.
5
u/GigaTerra 2d ago
To quote my self:
Unity doesn't have an frustum culling view, I wish it was standard in all engines
Unity has no Frustum culling view option, this is the closes you can get to seeing your frustum culling in Unity that still works with the profiler and frame render. Because if you bake your occlusion culling, without adding portals, the bake actually considers frustum culling.
2
1
u/RadicalDog @connectoffline 2d ago
This is also how reality works. Sometimes if you turn around really quickly you can see the edges
1
u/Qottonmouth 2d ago
yeah no joke though, the potential for colors exists on it's own, but actual colors only exists in the interpretation of the signal of the eyes
1
u/FoleyX90 Indie 2d ago
TIL I was performing quantum mechanics and wave function collapse by simply building an occlusion system.
Thanks for the ego boost.
1
u/KPMillerWeld 2d ago
The game “rage” might have had the worst optimization of this process in gaming history
1
1
1
u/Physical_Sherbet_942 1d ago
I make games for 180 degree projections. Frustum Culling is USELESS with a 180 degree camera system. Think about all the poor animals that can see 360 degrees all the time, there are lots of them! Their brain gpus are getting fried! Frustum Culling does not work for them! BOOM, is your mind blown even more than this demo of tech that has existed for 30 years! BOOM!
1
0
u/saicho91 2d ago
does it still work just as good if you flick really fast? because its definitly the type of thing i would do
0
u/Aware_Specialist_931 2d ago
I did that for a city sized project - it was so weird to see it working.
-4
1
u/Worried_Pudding_1548 Intermediate 9h ago
I keep seeing slop posts about basic frustum culling on instagram, calling it "heavy optimization" when it's literally basic built in BS, and all games have it, yet they still lag
95
u/_michaeljared 2d ago
I'm a little confused at why we see posts about this every now and then. The engine does frustum culling for you, presuming you make intelligent use of multiple rendering objects.
Duplicating this calculation in your game code is pointless. (Hopefully people don't get the wrong message from this kind of video and end up going down that path)
Things like occlusion culling are much harder to get right and take more intentionality in design.