When trying to optimize my game the biggest problem seems to be the device.present. Been going through some forums and i couldnt really find any useful answers. What is usually the main problem associated with this?
There are just many things that could cause this but the main reason is because the Thread is blocked by the graphics driver in a way to let the GPU catch up.
These are the specific reasons:
1.Image Effects
Check your camera. If you have Image Effects such as Flare Layer, Anti-aliasing and others, disable them.
2.UI Effects
Check all your Images, RawImages and Texts. If you have an Outline, Shadow or Position As UV1 component attached to the Images, RawImages and Texts, this could cause the problem. Usually when you have multiple of this attached to one
Image, RawImage and Text.
3.Bad Light Settings
Select your light and make sure that the Resolution under the Shadow Type is not set to Very High Resolution.
4.In the Quality Setting change the V Sync Count to Don't Sync.
5.Check for Sprites and Images with 0 alpha then disabled them
6.From the Player Settings, disable Auto Graphics API then change the Graphics API to OpenGLES2.
7.Custom Shaders
Are you using custom shaders (non standard shaders)? Disable it temporary. An expensive or bad written shaders could cause this problem.
Those are the usual problems. It is very possible that yours is a different problem. I suggest you enable/disable items one by one and you will likely find the problem.
If not, then consider creating new project and scene. Save out your old game as prefabs or assets then import them one by one into the new project. Don't import them at the-same time because the problem might appear again. Import then test then import again and test until you find the problem. If the problem is no longer there then it's likely an Editor Settings problem.
Related
I've been working on a fairly large project in Unity. Until recently, we weren't using universal render pipeline (URP) and made that change. When we did, all the bloom effect we already had in place to create a neon glow look for our game disappeared, and everything looks opaque. All the tutorials I found say that it's fairly simple to add this effect, but I can't make it work. I'm starting to get suspicious of the Cinemachine in the main camera, since it's brought us problems in the past. I'll just state some of the things I've tried:
The post processing checkbox is ticked in the camera view.
My materials have emission turned on with colors that used to work before URP.
The camera has the volume component, with an override of bloom and the values of intensity and threshold super high.
I've also dropped a global Volume in the scene with a volume component with bloom effect (one solution suggested I do that)
I think that's everything. Please let me know of any suggestions!
pink build
blue build
To preface this, we are using Unity 2019.3.0f6 and URP 7.2.1.
About 1/3 of the time we load a scene of our game (in build only) it is tinted pink with an orange strip at the top (pictured in “pink build”) or blue with a green strip at the top (pictured in “blue build”), until you enter the next scene. The other 2/3 of the time the screen is fine.
After looking through the shader compilation in the log, it appears that all of them are loading (nothing in the output changes between when pink/blue build happens and when it doesn’t). We then tried turning on and off different components on the camera just to isolate what might be causing the problem, (as the tint effect only happens below the Unity canvas so we thought it might be a problem with the camera/postprocessing).
We’ve narrowed the problem down to the Bloom Override on our Volume Profile on the Volume Component for Post Processing. Turning off the Bloom Override makes the problem go away in build, but we would like to keep the Bloom effect.
the volume component
We’ve tried printing all of the values under the Bloom Override to see if there is an anomaly when it does the pink/blue v.s. when it doesn’t, but there is no difference. Literally nothing is different in our logs when it works and doesn’t work. The only thing we know for sure is that turning off the Bloom fixes the problem. If anybody has run into this, this is a desperate call for help, because we have absolutely no idea where to go from here.
graphics settings screenshot 1
graphics settings screenshot 2
This is probably, a rather individual problem. Since people with a similar problem have not yet answered, I will advise a general and simple solution. Create a new project, where there will be new settings URP, and already add a bloom effect in it. If everything works well and bloom works, then transfer these settings to your project (preferably create a backup, just in case).
If that doesn't help, then as an option, try changing other settings that appear before 2/3 of the game works well. Maybe it's some individual effects, that create a problem. Or according to my assumptions, in a vignette. It can also be in a sprite, that is drawn on top of the bloom (It is advisable to do all this, in a separate backup, so as not to accidentally break the project). Also, the problem may be in the camera, if the URP settings, sprites, etc. work well, and the bloom effect should not fail.
As a last resort, if this also does not work, then try to send a complaint to Unity support. There is a possibility, that this may be a mistake in the bloom effect itself.
Although I will assume that bloom removes the problem. But the error is in something else, and is displayed at the moment when the bloom effect is turned on. But since the URP is quite new, I do not exclude that this is a mistake of the bloom effect itself.
I had a similar problem in the past, it fixed by changing LUT size to (16 or 32 or 64...), in urp asset settings/ post-processing.
Before I explain my situation, it's important that I mention I'm using an older version of Unity, 2017.42f2 (for PSVITA support). for this reason, I'm also using the old Post-Processing Stack.
I'm making a game in which I want a lot of bloom on the UI, but not as much for the rest of the game. I used a camera to render the UI, gave it Post-Processing (Screen Space - Camera on Canvas),
and another one to render the rest of the game
Each is given a different profile to use different effects.
My expectation is that the UI renderer camera would only apply it's effects to the Canvas. Instead, it also applies them to the camera beneath it; the game renderer camera.
As you can see I used Don't Clear clear flags. I also tried Depth-only, to see if it would make a difference.
I'm lost as to what I could do. Grain and bloom get applied to everything
yet the profile for those effects is only given to the UI renderer Camera's Post Processing Behavior Script.
Does anyone have any suggestions or ideas? I'm lost.
I have finished my game in Unity already.
But whenever I'm trying to build the game, it stops at the point as shown below. Does anyone know the reason why it happens? It always stops at the same point....
It's a problem with baking the lightmaps on your scene.
Unity doesn't like huge objects when it comes to baking lightmaps on them and it can certainly kill the light transport on a build.
You can try to open the Window menu from the main Unity menubar and search for the "Continues baking" checkbox under Lightning and uncheck it.
Or you can just split your bigger objects on your scene which may cause this problem.
Here's a thread detailing the issue a bit.
I've also seen people working around this problem by disabling Global Illumination altogether so that may be a solution for you as well if you are using it and you are willing to give up on that feature.
Edit: Another thread about this sort of thing with a decent solution - not sure why I didn't remember it for first but it's a good idea before trying to split your huge objects to mess with their "Scale In Lightmap" property as well to reduce the lightmaps' size.
You can also try the "Advanced Parameter" options.
I have models created with 3D Studio Max.
When I save as .FBX and import into Unity 3D they become grey. What's the reason of this and how can i solve it?
Also i have huge troubles with performance of model on mobile. What's the best approach to get app faster?
When I save as .FBX and import into Unity 3D they become grey. What's the reason of this and how can i solve it?
I've gone through the same issue when importing the following 3D Data Visualization model
The model was created using Cinema4D and exported as .fbx.
When i imported into Unity using drag and drop, I got the following result
As we can see from looking at the Inspector (image above) the material is grey and can't be edited, the textures were not imported. The materials of the default assets cannot directly be edited but there's a way to go around it.
I've created a new material (right click in assets > Create > Material)
Gave it a new name (green) and changed Albedo to green.
And dragged the material to the cube
The end result now looks like expected
Also i have huge troubles with performance of model on mobile. What's the best approach to get app faster?
It can be tricky to develop mobile VR apps but the game window has an info panel that displays useful live information (Use Stats button in the Game window to enable it)
There we can read how many SetPass calls, Batches and polygons are being drawn. Aim for 50 SetPass calls, that's a good number accordingly to Unity experts.
About optimizing performance, some very good developers already explain in detail how to optimize your scenes. I suggest the following links
Understanding VR Performance
Profiler window
1) all models gray- this means the texture was lost in the import. You can create materials and drag them onto the mesh. But Unity can import your max files directly, you dont have to export to .fbx. Maybe if you try that your textures and materials will be setup automatically.
2) performance on mobile- can be various causes. maybe too much detail in your models. Or more likely too many drawcalls, or maybe too heavy cpu upsage . hard to say. the unity docs have pointers on optimizing for mobile.