본문 바로가기
유니티 엔진

Unity : Optimizing Graphics Performance

by 대마왕J 2012. 1. 31.

Good performance is critical to the success of many games. Below are some simple guidelines for maximizing the speed of your game's graphical rendering.
 좋은 퍼포먼스는 많은 게임의 성공을 위해 중요한 부분입니다. 아래 간단한 가이드라인이 있습니다. 당신의 게임 그래픽 렌더링 스피드를 올려줄 수 있는.

Optimizing Meshes 메쉬 최적화

You only pay a rendering cost for objects that have a Mesh Renderer attached and are within the view frustum. There is no rendering cost from empty GameObjects in the scene or from objects that are out of the view of any camera.
 당신은 뷰 프러스텀 영역 (주: 카메라가 보이는 영역) 안에 Mesh Renderer 가 붙여진 오브젝트의 렌더링 코스트만 걱정하면 됩니다. 씬의 빈 게임 오브젝트 (empty GameObjects) 이나 카메라에서 벗어난 오브젝트난 렌더링 코스트에 상관 없습니다.  

Modern graphics cards are really good at handling a lot of polygons but there is a significant overhead for each batch (ie, mesh) that you submit to the graphics card. So if you have a 100-triangle object it is going to be just as expensive to render as a 1500-triangle object. The "sweet spot" for optimal rendering performance is somewhere around 1500-4000 triangles per mesh.
 현대의 그래픽 카드들은 큰 용량의 버텍스를 잘 다룹니다. 그렇지만 거기엔 각각의 배치(batch) 를 위해 당신의 그래픽카드에서 제어 가능하게 하는 총체적으로 중요한 내용이 있습니다. 만약 당신이 100개의 삼각형 오브젝트를 가지고 있다면, 그것은 1500개 삼각형 오브젝트보다 더 비쌀 (무거울) 겁니다. 렌더링 퍼포먼스 최적화를 위한 '가장 좋은 영역' 은 대충 메쉬별로 1500개 ~4000 개 폴리곤입니다.

Usually, the best way to improve rendering performance is to combine objects together so that each mesh has around 1500 or more triangles and uses only one Material for the entire mesh. It is important to understand that combining two objects which don't share a material does not give you any performance increase at all. The most common reason for having multiple materials is that two meshes don't share the same textures, so to optimize rendering performance, you should ensure that any objects you combine share the same textures.
 보통, 렌더링 퍼포먼스를 올리기 위한 가장 좋은 방법은 1500개나 그 이상의 삼각형을 가지는 , 단 하나의 메터리얼만 가지는 하나의 메쉬를 컴바인 오브젝트로 서로 묶는 것읍니다. 중요한점은, 두 개의 메쉬를 컴바인 한다고 할 때 그 메쉬가 메터리얼을 공유하지 않으면 퍼포먼스에 아무런 이득이 되지 못한다는 것입니다. 여러 개의 메터리얼을 가지게 되는 상식적인 이유는 두 메쉬가 같은 텍스쳐를 사용하지 않는 것입니다. 그래서 렌더링 퍼포먼스를 올리려면 당신은 어떻게 해서든 컴바인하는 메쉬들이 몇 개더라도 같은 텍스쳐를 가지게 해야만 합니다.

However, when using many pixel lights in the Forward rendering path, there are situations where combining objects may not make sense, as explained below.

Pixel Lights in the Forward Rendering Path

Note: this applies only to the Forward rendering path.

If you use pixel lighting then each mesh has to be rendered as many times as there are pixel lights illuminating it. If you combine two meshes that are very far apart, it will increase the effective size of the combined object. All pixel lights that illuminate any part of this combined object will be taken into account during rendering, so the number of rendering passes that need to be made could be increased. Generally, the number of passes that must be made to render the combined object is the sum of the number of passes for each of the separate objects, and so nothing is gained by combining. For this reason, you should not combine meshes that are far enough apart to be affected by different sets of pixel lights.

During rendering, Unity finds all lights surrounding a mesh and calculates which of those lights affect it most. The Quality Settings are used to modify how many of the lights end up as pixel lights and how many as vertex lights. Each light calculates its importance based on how far away it is from the mesh and how intense its illumination is. Furthermore, some lights are more important than others purely from the game context. For this reason, every light has a Render Mode setting which can be set to Important or Not Important; lights marked as Not Important will typically have a lower rendering overhead.

As an example, consider a driving game where the player's car is driving in the dark with headlights switched on. The headlights are likely to be the most visually significant light sources in the game, so their Render Mode would probably be set to Important. On the other hand, there may be other lights in the game that are less important (other cars' rear lights, say) and which don't improve the visual effect much by being pixel lights. The Render Mode for such lights can safely be set to Not Important so as to avoid wasting rendering capacity in places where it will give little benefit.

Per-Layer Cull Distances

In some games, it may be appropriate to cull small objects more aggressively than large ones in order to reduce number of draw calls. For example, small rocks and debris could be made invisible at long distances while large buildings would still be visible. To accomplish this culling, you can put small objects into a separate layer and setup per-layer cull distances using the Camera.layerCullDistances script function.

Shadows

If you are deploying for Desktop platforms then you should be careful when using shadows because they can add a lot of rendering overhead to your game if not used correctly. For further details, see the Shadows page.

반응형

댓글