I trying to figure out how can I optimize my project even more. I draw lots of object's I already manage to reduce draw calls almost to minimum with materials and material property block but still there is a huge overdraw in some scenes. I try some solutions with computed shaders and they just boost performance super high but problem is that my target platform is WebGL and WebGL support only OpenGL ES 3.0 so I cannot use computed shaders. I cannot use Unity Occlusion Culling becouse everything is genearted in realtime so I cannot bake occlusion.
Is there any way how can I reduce this overdraw or maybe some technique to make a realtime Occlusion Culling without raycasting.
Thank you for any advice
Related
I am new to Unity game development. I making a mobile game. In LWRP I made a custom shader graph (glow shader). It works fine in unity in my pc. But when I build a .APK and install and play on my android device it shows a plain block with no shaders.
Am I missing something?
This my shader graph.
After clear inspection, I noticed most of the shader works. Only the occlusion part doesn't work properly. I have set occlusion to 5. Normally what occlusion does in my graph is kind off saturates the material a little and gives a deep reflective glow kinda effect to the shader. It works on PC. But on the phone, I noticed the color did get saturated a little but didn't notice the occlusion glow at all.
(I know I can produce nearly similar results without using occlusion, but I really felt occlusion suits more for my taste :P and I will be using occlusion for other objects too)
quality settings:
Check your Graphics API in player setting, it should be under Other Settings
I have a pretty large scene, where I have 1 directional light (sun) set to mixed.
I mainly used realtime lighting during development in order to save time.
Now before release I want to bake, to improve performance for my users.
My questions are
Is there any rule of thumb for any of the values in light-settings?
which objects should I set to static (I set everything that doesnt move to static) and is something wrong if my bake takes 3-4 hours?
Should I use realtime GI since I have mixed lighting, or is Baked GI enough?
I use fairly high settings for my final bake because I want it to looks nice, and I bake everything that doesnt move in the scene (thousands of objects). While it does take hours, the light map size ends up at around 60mb after compression, which doesnt seem bad.
My settings are like the image below, except I've increased:
Direct samples: 200
Indirect samples: 1000
Resolution: 24
Parameters: Default High
The reason for increasing these values is simply because my objects did not look good in a bake with any lower settings.
I want to bake, to improve performance
Notes:
Baking usually improves visuals.
But this creates a lot of textures, so it may lower performance.
Using ONLY the baked lights, it's basically unlit - very good performance.
Mixed means you bake the indirect lights (because without realtime raytracing you won't have indirect lighting*) and still use realtime lights for some things like hard shadows.
If you don't want to rotate the directional light (sun) or move point lights around, there is no use in baking the realtime GI.
[*] : We can fake some realtime GI / soft indirect lighting by pre-baking this. So "Realtime GI" allows you to rotate the Directional Light (Sun) or even move lights around, but not objects. And you need to bake it, usually including some light-probes. So "realtime" doesn't mean it's bake-less. And it's not the same as real raytracing.
Duration:
Using 2018.3 or 2019.1 (not sure) you can try the GPU Lightmapper (preview) - it is a lot faster. However using CPU 3-4 hours is quite normal to me.
Static?
Marking things as static is always good for performance, but you can also mark non-static things as "Lightmap-static" if you want movable houses to be pre-baked for example.
Lightmap Debug Mode:
The reason for increasing these values is simply because my objects did not look good
In Scene view, you can select a "Lightmap" mode (not sure how it's called).
It displays basic chess/checker texture on all objects with lightmap-UVs. Use this view to scale lightmap UVs to increase details on close objects for example.
edit:
Mixed Lighting - Performance?
This will bake the light for all static (or at least lightmap-static) objects in the scene. During runtime, lighting is not computed for the static ones anymore.
At least that's what the Manual says:
Selecting the ‘Mixed’ baking mode, GameObjects marked as static will still include this light in their Baked GI lightmaps. However, unlike lights marked as ‘Baked’, Mixed lights will still contribute realtime, direct light to non-static GameObjects within your scene.
I just tested:
"Baked" - After Baking, rotating the sun didn't affect the scene until rebake.
"Mixed" - I can rotate the sun and affect shadows. Note: "static" objects still get some indirect light (reflecting from the surroundings) while non-static objects are not baked, and therefore completely black on the side which is not facing the sun.
The Lighting tab says
Mixed lights provide realtime direct lighting. Indirect lighting gets baked into lightmaps and light probes. [...]
Performance:
This is hard to answer without a test, as I am only relying on theoretical facts, and maybe assumptions.
I would say the Mixed Light mode is just to have better visuals (indirect lighting). This is precomputed, but the textures still need to be multiplied/added to the pixel lighting in the shader - this costs a bit performance.
And the direct light is still computed in realtime - so if I understood the docs correctly, Mixed is always worse than only realtime lighting in terms of performance.
But: If your sun doesn't even move - you can use it in "baked" mode instead of "mixed" - this will bake shadows to texture and save the calculation at runtime. This is the only option that for sure is better in performance. I'm not 100% sure about the mixed mode.
And realtime lights will still affect them. A torch for example.
However your non-static player will not get the sunlight lighting/shadow because it cannot be baked. You could try using an unlit shader on him, and add a fake shadow under it. Or you place a point light above it to fake the sun.
I am working on a mobile game in Unity, and we've reached the optimisation stage of development. We've been using realtime AA from the Post-Processing Stack, but I would like to switch to baked AA, because nothing except for the player moves in our game.
Here's the problem: we only use unlit materials in our game. This wasn't a problem for the Post-Processing Stack, but it does prevent baked ambient occlusion from being visible in-game. I've considered two possibilities.
Possibility 1: We use a lit shader, but disable all realtime lights and simply setup the baked lighting so it appears unlit. The main problem with this solution is that I believe this isn't as performant as we'd like.
Possibility 2: We edit our custom unlit shaders to include unity's baked lighting layers. I believe this is the best option, as it would maintain the performance of our custom shaders. The problem with this is that I can't find any documentation on what needs to be changed to make this happen.
So, my question is: which possibility is best? If it's possibility 1, will this severly hurt our performance? If it's possibilty 2, what do I need to do to make this work? Thank you for any help you can provide.
I'm working with Unity and C# making a platform game, i mostly used cubes/boxes of different scales to build the level and now i have to apply the texture, i played with the tiling but the texture obviously stretches to apply on different objects, making a different material for each object is too much, I heard that I should use shaders but I've never worked with them. Can anyone help me write a shader that can modify the tiling based on the size of the object? Thanks to everyone.
I am working on a VR app with Unity3d and I am making the scene rendering with Unity but I cannot achieve good image quality. Is it possible to import a full baked render from Maya, 3ds ( for example an .fbx ) with all the lightning and shading so that I can only work with Unity with the interactions ?
I need to get the highest image quality so I make it as realistic as possible.
Shaders will always be different, but in case your lighting conditions don't change, you can fully bake the result as albedo, and use unlit shader to just pass through the result. This will not work as expected if you want to move/rotate the resulting objects, however it might work for environments.
Have in mind that unlike max/maya, unity renders in realtime, in milliseconds per frame, not minutes per frame, so there are certain tradeoffs that are made to ensure speed, the reuslts will never be identical (as they are not identical between offline renderers).
Its probably best to just learn to use Unity shaders to its full, just as you had to learn max/maya.
you can bake lighting in unity3d too, which can give decent results