Home Technical Talk

Do engines end up rendering what we can't see?

Topics like this have been on my mind since I got into video game art, as I've been dreaming of the perfect engine toolset since I started. Anywho, I have always wondered if game engines do indeed render faces/textures/lighting, etc. that the camera cannot see. If so, why? I mean, at a single time, sure, thousands of polys can be in the scene, many lighting situations, many textures, but obviously it isn't necessary to render what can't be seen, so why would a scene with thousands of unseen polygons and a small amount in view run slower than a scene with only a few in view at all (if that is the case of course, I'm not too certain or educated as to how engines go about rendering polygons or what happens under the hood.)

Replies

  • ZacD
    Options
    Offline / Send Message
    ZacD ngon master
  • gray
    Options
    Offline / Send Message
    nope. they don't. there are a few different kind of 'culling' stuff you do not see in the camera. here is a good Wikipedia overview of culling.

    http://en.wikipedia.org/wiki/Hidden_surface_determination#Viewing_frustum_culling
  • Av7xrocker97
    Options
    Offline / Send Message
    Okay, this definitely makes more sense. Do engines that utilize this render the full unshown object though, or do they also cull unseen faces (like backface culling)?
    And on that note, what other engines than unity implement this as a stock feature? Sorry if I sound a little naive, I'm just trying to better understand the inner workings of things before I tackle a personal project.
  • ZacD
    Options
    Offline / Send Message
    ZacD ngon master
    Most engines automatically have backface culling, and most have some form of culling.

    Here's what CryEngine has to say about culling
    http://freesdk.crydev.net/display/SDKDOC4/Culling+Explained

    UDK
    http://udn.epicgames.com/Three/VisibilityCulling.html
  • Av7xrocker97
    Options
    Offline / Send Message
    Okay, awesome. Now, what is the difference in computational strain on rendered faces and ones the computer just kinda knows are there in this situation? I would assume most of the strain of rendered faces is put on the gpu while not-yet rendered faces are just kinda resting on thee cpu?
  • gray
    Options
    Offline / Send Message
    Sorry if I sound a little naive, I'm just trying to better understand the inner workings of things before I tackle a personal project.

    its a good thing your thinking about theses things. it will give you an advantage to know how things work under the hood. if nothing else it gives you a better intuition of why stuff happens the way it does.

    edit:
    once the renderer/engine knows what it needs to render and what it does not it stops calculating the hidden stuff. so no computation is done at all on occluded geometry in general.


    @ZacD
    those are some good links. i always say RTFM :), because 90% of the answers to the questions people have are right there on your hard drive.
  • ZacD
    Options
    Offline / Send Message
    ZacD ngon master
    I always like linking people to wiki's, that way, they know where they can look next time. Game engines are pretty well documented now, and I know I wont be able to answer some of the tech related questions as well as a good article.
  • Av7xrocker97
    Options
    Offline / Send Message
    Okay, thank you very much! So, theoretically, and I know nothing works perfectly, but one could say that in a distant future, once a machine with enough memory to hold all of the data for a lot of high-density meshes is built, and has the graphical power to render enough polys show on screen to effectively suit our desires of realism, if the rest is culled and not rendered, wouldn't this put a relative end to fighting for more polys? I mean, if that was the case, imagine the things we could put our focus on once that's out of the way :D
  • ZacD
    Options
    Offline / Send Message
    ZacD ngon master
    We are nearing that point already, with basically 8 gigs of vram on the PS4, I don't see artists really wishing they had more tris to work with. Characters in Killzone Shadow Fall will have 40,000 polys.

    It's possible now with tessellation to have enviroments with almost a triangle per pixel, [ame="http://www.youtube.com/watch?v=RfpGViB-jjs"]Stone Giant DirectX 11 Technology Demo - YouTube[/ame]
  • gray
    Options
    Offline / Send Message
    i'm going to disagree. 40,000 polys for a character is just at the very tip of the low end of poly count that starts to make things interesting. you will easily see poly counts of a few hundred thousand k in the future for base cages. and thats not going to be the render geometry. render geometry will be in the millions done with subdivision/tessellation. and that will be driven by displacement maps.

    the other thing to keep in mind is that its not 'just geometry' its lighting, effects, post prossessing etc. all of these things are improving also. dynamic ray traced lights with soft shadows, real time reflections, etc. all of these things take computation. so even if you can render 5 million polygons in real time can you do it in a scene with all the effects just mentioned? its hard to get your head around but real time graphics are just at the beginning of what is possible. it will take a long time yet to get there, and once your there you have not even scratched the surface of the physics that will bring life like environments.
  • ZacD
    Options
    Offline / Send Message
    ZacD ngon master
    I still wouldn't consider the realism peak to be a distant feature, at least in terms of effective polycount from an artist perspective. We are still VERY far away in terms of realism with real time lighting. We are very close to seeing cars that couldn't be anymore detailed.
  • gray
    Options
    Offline / Send Message
    just for comparison from film you need about 40-60k for a head to get the kind of facial deformation that look believable at close distance. thats still a ways off. and so is the facial systems to do that in real time.

    but i get your point. i think things are right about at the point where the choppy polygon look is no longer an issue and you can concentrate on the 'actual' limit surface. and the base cage as apposed to trying to fake a polygon model into looking organic. thats a huge step and is definitely a major hurdle to have jumped over.
  • CrazyButcher
    Options
    Offline / Send Message
    CrazyButcher polycounter lvl 18
    On PC it is not so typical to cull on face level. Backface culling is basically a hardware feature, but frustum/occlusion culling not, you have to code your own algorithms leveraging GPU/CPU to do that. The static geometry of say good old quake/halflife levels indeed are culled on face level by CPU, prior sending to GPU, but nowadays it's more popular to have the geometry resident on the GPU (saving transfer costs). Instead culling is more done on a per-object/zone basis.

    Then there is specialized systems such as terrain/particles which generate their render geometry a bit different from regular characters/objects in the scene.

    Traditionally you'd want to minimize the data you move from CPU to GPU memory, in future architectures (ps4...) this likely becomes less of an issue with general full-speed access to common memory. But at some point it's just cheaper to draw "invisible" stuff than finding out what is visible exactly and only render that.

    There are several bottlenecks that you have to balance when rendering, just to name a few:
    - the CPU/GPU transfer mentioned above
    - draw calls and state changes: you'd want to maximize work to do for the GPU, few big jobs, vs many small. Otherwise you risk GPU waiting for CPU to create work for it.
    - vertex/transform boundedness: the amount of vertices being transformed when rendering an object. Can become a problem when the same scene has to be rendered multiple times albeit simple fragment shaders being used
    - fragment boundedness: too heavy shading per pixel, or too many pixels are overdrawn by surfaces occluding, wasting time. This is typically avoided with the "deferred" style approaches or depth pre-pass
    - ...

    Agreeing with you, the hardware is pretty decent when it comes to poly performance, so we get much better silhouettes/shapes, but shading complexity is still tough, and animation is another big task complex.
  • gray
    Options
    Offline / Send Message
    in future architectures (ps4...) this likely becomes less of an issue with general full-speed access to common memory.

    can you elaborate on this 'full-speed access to common memory' or provide a link to info? i have not heard much about it, but it sounds interesting.
  • Norman3D
    Options
    Offline / Send Message
    Norman3D polycounter lvl 14
    gray wrote: »
    can you elaborate on this 'full-speed access to common memory' or provide a link to info? i have not heard much about it, but it sounds interesting.

    Here you go:
    http://www.gamasutra.com/view/feature/191007/
    "The 'supercharged' part, a lot of that comes from the use of the single unified pool of high-speed memory," said Cerny. The PS4 packs 8GB of GDDR5 RAM that's easily and fully addressable by both the CPU and GPU.
  • SHEPEIRO
    Options
    Offline / Send Message
    SHEPEIRO polycounter lvl 17
    in my experience culling is about balancing the cost on gpu of rendering un-needed geometry vs the cost of knowing what is needed to be rendered either in production costs or cpu costs. there are a fair few ways of generating data so that visibility per object can easiliy be worked out but these still cost and the more you split the scene up into objects so they can be better culled the greater the overall expense of working out the visibility... ive not seen a non-generic mesh based system that culls polys based on visibility... is there any?

    although saying that i think most engines do pretty well to only fill the pixels that are visible (excluding alpha) BUT you still need to store/transform the verts and polys to get to that point

    forgive me if im talking shit this is written with a massive hangover
  • Ben Cloward
    Options
    Offline / Send Message
    Ben Cloward polycounter lvl 18
    To clarify what Shepeiro said and answer the original question of why things get rendered that can't be seen - sometimes it's more expensive and costs more performance to figure out exactly what can't be seen than to just go ahead and render it. Sure you might render stuff that doesn't get seen, but the engine runs faster overall because it's not doing all the extra work to be precise.
  • passerby
    Options
    Offline / Send Message
    passerby polycounter lvl 12
    even know there is culling now, i still think starting with goldsrc and source engines teaches a lot about optimization, since since you had manually setup hint brushes for vis, it made you really think about your sight lines, and how to optimize ares as you made your levels.
  • cman2k
    Options
    Offline / Send Message
    cman2k polycounter lvl 17
    There are other crazy things sometimes too...like dynamic shadows. If you have a scene lit by dynamic shadows, many of the triangles are often re-drawn in a shadow pass, and stuff that is off-screen can still get drawn. Think about it - if something behind you is casting a shadow that falls in front of you, it has to still be getting drawn in the shadow pass. That doesn't mean it draws everything...just that the frustum is different, it's usually not from the camera, it originates from the light.
  • Ashaman73
    Options
    Offline / Send Message
    Ashaman73 polycounter lvl 6
    The count of tris is not as important as it was 10 years back. Occlusion culling will be done on a very crude level of detail (e.g. a whole characters). The most basic and efficient culling approaches are still zbuffer (early z-buffer hardware + z-pre pass) and backface culling. Keeping this in mind and that pixel shaders are often more beefier and need to process a lot more (compare a 70k vertex character to a 2 mio full screen rendering post processing pass at 1920x1080 with a much heavier pixel shader), tri count isn't as important.

    ... but it is always better to see the whole picture. Even if you want to make a character out of 2 mio vertices, you suddenly have the problem of sub-pixel triangles. That is, from father away suddenly 100 triangles need to be rendered at the same position of a single pixel, which introduces new challanges in real-time rendering (maybe dynamic tesselation will be the future).

    Some thought about PS4 and 8 gig of shared memory: yes, it is really cool to access memory by CPU/GPU at the same time, still you need to consider, that memory bandwitdh is a very limiting factor. There's no great benefit of having lot of memory if you can't access it effeciently in a single frame.
  • ZacD
    Options
    Offline / Send Message
    ZacD ngon master
    Ashaman73 wrote: »
    Some thought about PS4 and 8 gig of shared memory: yes, it is really cool to access memory by CPU/GPU at the same time, still you need to consider, that memory bandwitdh is a very limiting factor. There's no great benefit of having lot of memory if you can't access it effeciently in a single frame.

    The memory bandwidth on the PS4 is huge, so that will be a nice advantage of the Xbox One.
  • Ashaman73
    Options
    Offline / Send Message
    Ashaman73 polycounter lvl 6
    ZacD wrote: »
    The memory bandwidth on the PS4 is huge, so that will be a nice advantage of the Xbox One.
    From a hardware and developer point of view the PS4 is very attractive compared of what the XB1 provides so far, but I fear, that the lowest common denominator will be choosen and that will make the games most likely look the same on both plattforms, much like the current gen games, considering that the hardware is very similar in the PS4/XB1.
Sign In or Register to comment.