How to Actually optimize your game in Unity - Complete Game Optimization Guide
Summary
TLDRThis tutorial video guides viewers on optimizing Unity scenes for high performance without sacrificing quality. It starts with basic settings adjustments, such as shadow quality and graphics presets, and progresses to more advanced techniques like static batching, UI element raycast disabling, and shader optimization for mobile devices. The video also covers Unity's lighting settings, demonstrating the use of mixed lighting modes and light baking to achieve significant FPS improvements. Additional tips include physics settings, material adjustments, and the use of subjective lighting mode for dynamic shadow effects.
Takeaways
- π₯ The video is a tutorial on optimizing performance in Unity without sacrificing visual quality.
- π The tutorial uses a nature scene with trees and stones downloaded from the Unity Asset Store.
- π Default settings on the directional light are kept for simplicity, with a minor change to the skybox color.
- π Initial performance metrics show 30-40 FPS, indicating the need for optimization.
- π Shadows are optimized by changing the shadow type to 'Hard Shadows' and reducing shadow strength.
- π§ Graphic settings are adjusted to a medium preset to improve performance without significant visual loss.
- ποΈ Texture compression and mip maps are utilized to reduce texture size and improve rendering efficiency.
- π The far plane of the main camera is adjusted to limit the view distance and reduce the number of objects rendered.
- π¨ Static batching is applied to static objects in the scene to reduce draw calls.
- π UI elements that are not interactive have raycasting disabled to save on processing time.
- π‘ For mobile devices, vertex lit shaders are recommended for better performance, with the option to include shadows.
- πΉοΈ Physics settings are optimized by setting collision detection to 'Discrete' and disabling auto-sync transforms.
- π Lighting is optimized by using mixed or baked lighting, adjusting light map settings, and using GPU for light baking.
- β¨ Materials are simplified by disabling smoothness, specular highlights, and reflections to reduce rendering complexity.
- π GPU instancing is enabled to improve performance by reducing the computational load on the CPU.
- ποΈ Unnecessary light maps are disabled for objects not in 3D space to save memory.
- π The subjective mode in Unity is highlighted as useful for dynamic objects that require real-time lighting updates.
Q & A
What is the main focus of the video?
-The video focuses on teaching viewers how to optimize their scenes in Unity to improve performance without losing visual quality.
What is the nature of the 'nature take light' mentioned in the video?
-The 'nature take light' is a lighting asset downloaded from the Unity Asset Store, which the tutorial uses to enhance the scene's environment.
What is the initial FPS of the scene before optimization?
-The initial FPS of the scene is around 30 to 40, which is considered low for the scene.
How does the video suggest optimizing shadows in Unity?
-The video suggests changing the shadow type of the directional light to 'Hard Shadows' and reducing the shadow strength to achieve a softer shadow effect.
What graphic settings changes are recommended in the video to improve performance?
-The video recommends using the 'Medium' preset in the graphic settings, disabling anisotropic textures, setting shadow types to 'Hard Shadows Only', adjusting shadow resolution to 'Medium', and disabling VSync.
What is the purpose of adjusting texture maps in Unity as suggested in the video?
-Adjusting texture maps helps in optimizing the scene by enabling only necessary texture maps, playing with the max size, and using grunge compression to reduce overall size whenever possible.
Why is adjusting the far plane distance of the main camera suggested in the video?
-Adjusting the far plane distance reduces the number of objects that need to be rendered, which can improve performance by not rendering objects that are too far away from the camera.
What is the benefit of using static batching in Unity as mentioned in the video?
-Static batching reduces the number of draw calls by combining multiple static objects into a single draw call, which can significantly improve performance.
How does the video suggest optimizing UI elements for performance?
-The video suggests disabling raycasting on UI elements that are not interactive and setting the Canvas to sleep when not in use to reduce unnecessary checks and calculations.
What shader is recommended for mobile devices in Unity according to the video?
-The video recommends using the 'Vertex Lit' shader with 'Mobile' selected for better performance on mobile devices.
What is the final FPS achieved after all the optimization steps in the video?
-After all the optimization steps, the video achieves more than 500 FPS.
What is the purpose of the 'Subjective Mode' in Unity lighting?
-The 'Subjective Mode' in Unity lighting is useful for cases where static objects do not move, and it allows the shadows to stay in place while dynamic objects like players move around, using different lighting calculations.
Outlines
π Unity Optimization Basics
This paragraph introduces the video's focus on optimizing Unity scenes for performance without sacrificing quality. The creator thanks the audience for reaching 500 subscribers and uses a nature scene from the Unity Asset Store as a practical example. The scene includes trees, stones, and a directional light with default settings, except for a change to the skybox color. The initial FPS is around 30-40, which is considered low, and the tutorial aims to improve this through various optimization techniques.
π§ Adjusting Graphics and Shadow Settings
The second paragraph delves into optimizing graphics settings by adjusting shadow types and strengths on the directional light, and selecting medium preset quality settings to improve performance. It also covers disabling vsync, managing texture maps with compression, and adjusting the main camera's far plane distance. The goal is to maintain visual quality while significantly increasing the frame rate, which is achieved by reducing shadow quality, optimizing texture settings, and limiting the camera's view distance.
π Advanced Performance Enhancements
In this paragraph, the focus shifts to more advanced optimization techniques, such as static batching to reduce draw calls, disabling unnecessary UI element raycast checks, and adjusting physics settings for better performance. The tutorial also touches on shader selection for mobile devices and disabling reflections and specular highlights to save on rendering resources. The use of GPU instancing is introduced to further boost performance. The result is a substantial increase in FPS, demonstrating the effectiveness of the applied optimizations.
π‘ Lighting and Final Touches
The final paragraph discusses the lighting settings, explaining the use of mixed lighting for dynamic objects and baked lighting for static elements. It guides through the process of baking lightmaps and adjusting their resolution and size for performance. The tutorial also addresses the subjective lighting mode, which allows for dynamic lighting on static objects, and suggests further optimizations like disabling auto-sync transforms and reducing texture map generation for non-3D objects. The video concludes with a call to action for deeper exploration of lighting settings and support through Patreon.
Mindmap
Keywords
π‘Optimizing
π‘Unity
π‘Shadows
π‘Quality Settings
π‘Texture Maps
π‘Farplane
π‘Static Batching
π‘UI Elements
π‘Rigidbodies
π‘Shaders
π‘Lighting Settings
π‘GPU Instancing
π‘Subjective Lighting Mode
Highlights
Introduction to optimizing performance in Unity without losing quality, celebrating 500 subscribers.
Use of a nature sky light from the Unity Asset Store for realistic environment lighting.
Default settings on the directional light for simplicity and chaining the source from a skybox to color.
Optimizing shadow quality by changing the shadow type to hard shadows and adjusting strength for a soft effect.
Adjusting graphic settings to medium preset for better performance without significant visual compromise.
Disabling vsync to improve performance in Unity projects.
Optimizing texture maps with compression and size adjustments for reduced memory usage.
Setting the far plane distance on the main camera to limit the view distance and reduce rendering load.
Increasing performance through static batching of static scene objects.
Disabling raycast targets and masks on UI elements to prevent unnecessary checks.
Using mobile shaders for Android devices to enhance performance on mobile platforms.
Adjusting light map resolution and size for optimized lighting performance.
Baking lighting with mixed mode for scenes with dynamic objects.
Matching the ambient color for dynamic objects to blend with the baked lighting.
Disabling auto sync transforms in physics settings to save on processing power.
Reducing the use of smoothness, specular highlights, and reflections for performance gains.
Enabling GPU instancing to offload some of the CPU workload.
Disabling light map generation for objects not in 3D space to save resources.
Using crunched textures with reduced size for memory optimization.
Explanation of subjective lighting mode for dynamic and static objects in Unity.
Invitation for further exploration of lighting settings and support through Patreon.
Transcripts
in this video I'm going to teach you
everything that you need to know about
optimizing your again inside of unity
to make it super performant without
losing inequality and before we get
started I just want to thank you all for
your love and support as we hit 500
subscribers and with that said let's get
started
so for this tutorial I'm gonna be using
this nature take light that I downloaded
from the unity asset store and if you
guys want to check it out I'll put a
link in the description so here's how it
looks with a bunch of trees and stones
and I've just set them all inside of
this environment game object here
I've kept default settings on the
directional light to make things easier
for you and also for the man camera here
and also for the Lighting's except for
one little change here and I've chained
the source from a skybox to color here
also if we go to edit project settings
quality
I've also capitis to its default
settings as you can see here alright
alright so now if we hit play
let's hit play and open up the stats
here you can see we get around 30 to 40
FPS which is very low considering of our
scene also we can reduce these are post
calls and matches here so let's just
start optimizing the game firstly ever
seen has too many shadows as you can see
here and they're all at the highest
quality level
so let's first like the direction light
and we can just go ahead and change the
shadow type to hard shadows here and we
can reduce the strength to like 0.75 to
get there soft shadow effect alright so
the next thing we can do is go to our
graphic settings let's go to edit
project settings and here we can see our
scene is kind of too perfect so we can
reduce the quality a little bit so
instead of changing the settings we can
choose this medium preset and it will do
just fine so let's first get rid of this
n isotropic textures and also make sure
the and the other thing is said to
resemble now let's go down and here make
sure the shadows type are set to hard
shadows only also you can just bump up
the resolution
to medium also make sure they're the
shadow cascades is said to no cost kids
alright and let's also disable this
vsync here because we won't be needing
it so let's see how it looks and it
looks awesome still so we haven't lost
any quality yet also to improve the
performance make sure your texture maps
let's get the texture Maps here instead
of textures and I only have one so make
sure you enable just 200 MIT Maps on
your texture maps come we could also
play around with the make size here so
let's see let's keep it at 512 for now
and also enable this use grunge
compression it will help reduce the
overall size whenever possible and now
let's try this out let's hit apply and I
don't think it should change any quality
here so we can go maybe a bit too though
and it starts to lower the quality so
let's just keep it at 512 awesome so now
we can select the main camera and here
as you can see we don't need to look
much far ahead it will just increase the
number of objects to welder so let's
keep the farplane 8 around 300 let's try
300 for now or maybe we could go a
little less so 200 yeah I think 200 will
do just fine
alright so now it's time to test things
out so let's see how we're doing and as
you can see we are already 50 frames up
then 4 but there is still so much we can
do to improve the performance like
producing the batches here by static
batching as most of our scene is pretty
much steady so let's like the
environment so this is all static so
let's like the environment here now
either we can select some of them or
just mark all of them as a static for
everything
so hit yes and now there will be marked
as a static let's hit play and as you
can see there are only 78 witches now
and we saved 260 by static bitching cool
so if we were to have many static
objects in our scene we could do the
same for them alright so another cool
thing that you could do is let's exit
play mode let's lick the canvas here and
here select all the UI elements that are
not going to be click on so like all the
images here and inside the image
component does that those degrees rakers
targets and masks able to if you want to
so the community doesn't keep checking
for raycast on these objects every
single firm alright and also we could
sleep the canvas and disable this pixel
perfect here because it doesn't make any
difference whatsoever and if we were to
have like rigid bodies in our scene so
let's add rigid bodies two of our
players here so if we had like these
rigid bodies up I'm just gonna set them
to is kinematic for now what you need to
check is you have these collision
detection mode set to discreet and not
continuous which will save a lot of
physics calculation time for unity
anyways I don't need them right now so
I'm just gonna remove them next thing
you could do is if you're building for
Android devices go for these shaders and
select the mobile shaders and select
this vertex lid it is supposed to be one
of the most performant shaders in unity
for mobile devices and also you could
use this for PC if you want to but if
you want to keep the shadows you might
want to try the vertex lit with
directional light which renders the
shadows also and if we hit play
as you can see it improves the
performance a bit more but for this I'm
gonna use these standard shaders so
let's get rid of this and also you could
get rid of the reflections on these
materials because we don't want them to
be reflective awesome and now for the
most important and the frustrating part
there's lighting settings
so first let's like the directional
light here and we will change the mode
so if we could either select baked or
mixed here so in our case we will select
the mix because we have some dynamic
objects like these players which will
kindly move around in the scene
vertically and we only have one light
and it weighs less like mixed and leave
everything as is go back to the lighting
step first let's slide the players here
and just disable them for now because we
don't need them in the baking process so
firstly let's change the lighting mode
to subtractive so let's change this from
shadow mask to subtractive and I'll just
show you what it does in a moment then
we have our players in the scene now we
can play around with all these settings
here I'm gonna keep this light map
resolution to as low as 10 or maybe 20
will do just fine so you would just play
around with all these settings if you
want and also I'll set the light map
size to 512 pixels for now and make sure
the compressed light map is enabled
because it will affect the overall size
of the light Maps after being pegged and
also let's change the light mapper from
progressive CPU to GPU here for faster
baking time you can play Iran with all
these settings if you want I'm gonna
leave them as is for now and hit
generate it will take a while so don't
worry and when it's finished it kind of
looks a bit weird it's because they
don't have the light my view is but oh
we can generate them inside of unity so
let's select the models here just right
all of them go to inspector panel and
inside the models layer
scroll down and you will see this
generate light my view is enable this
and you can see a bunch of settings here
so you can play around with them if you
wanted they are good as default so their
supply and I will just import everything
back here and nothing changed so yeah
that's because we have to regenerate the
lighting so let's just go ahead and
leave everything as is and hit generate
lighting and it will take a while and
voila here goes
so it looks awesome but our player
character here seem a bit off they are
more bright than the rest of the scene
and in order to fix that and go to the
lighting step find ambient color and it
will only affect of our players cut and
cuz they are the only dynamic objects
here so let's keep this somewhere around
here so the player matches the
background that's it play now oh that's
crazy fast we are now hitting around 500
FPS but there's still some changes to be
made so let's close this go to physics
and make sure the auto sync transforms
is disabled because we don't need it all
right and also let's light key materials
and if possible get rid of the
smoothness set to zero and also both
these specular highlights and
reflections too so let's remove them
because we don't need them anyway and
also let's enable this GPU instancing to
serve some CPU power and I've done the
same for this one let's hit play again
and here you can see we are getting more
than 500 FPS now which is awesome
lastly you could select all these parts
and make sure you and make sure you
disable the generate map map map maps
for them because we don't need them
because they are not in 3d space and
also we could enable this use crunch
impressions and play around with just
make size let's try to keep this as low
as possible so I'm gonna go up to as low
as 128 pixels without losing much
quality and it would save us a lot of
memory and if you want to check this out
let's hit play open up the profiler
control 7 and here if we click on
rendering click on this rendering tab
here and you can see all the sides their
textures take up so you can see all the
stuff here how many batches are there
and how many did we save and everything
you need to know and here you could see
the CPU usage works using more of the
CPUs power by using deep their loop top
down and not worry about the editor loop
because and if you want me to go deeper
into this let just let me know in the
comment section and finally let's talk
about the subjective mode so if I move
over play around the scene you can see
the shadow move with it but if we I
select one of these static objects and
try to move it the shadows stay where it
is because it's using the backlighting
while the player uses the via lighting
that's why the subjective lighting mode
is useful in cases like these and if you
want me to go deeper into lighting
settings let me know in the comment
section also and also if you want to
help me making these videos support me
on patreon and until next time see ya
you
Browse More Related Video
ΠΠΠ ΠΠΠΠ«Π‘ΠΠ’Π¬ FPS Π CS 2! ΠΠΠ Π£ΠΠ ΠΠ’Π¬ ΠΠΠΠ£Π’ ΠΠΠ?
π§ NVIDIA CONTROL PANEL: BEST SETTINGS TO BOOST FPS FOR GAMING π₯ | Optimize NVIDIA βοΈ
Flash photography for beginners part 1
iOS 18 Settings To Turn OFF Now! (Important!)
NEW Adjustment Brush in Photoshop. the advanced tutorial
10 Lighting Setups for Your Animated Shots
5.0 / 5 (0 votes)