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.
Related
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
In Unity is there a way to stop the camera rendering few objects or lets say far away objects so that it is more performant? I can achieve this with adjusting the far-clipping plane. But I also want the objects to be seen by camera. Such that the objects are visible in the scene but not rendered by the camera? This is specifically for VR purpose. Is there a way to achieve such an unusual thing?
If I understand correctly, you're asking for something to be visible but unrendered. This poses a conflicting problem, as rendering something is the process of making it visible.
Normally, you'd work with not rendering things outside of the viewport and LOD (level of detail).
LOD
Basically rendering things far away with low level of detail, making the game more performant. You can see how to set it up here: https://docs.unity3d.com/Manual/LevelOfDetail.html
Occlusion Culling
Culling is partly done by Unity, as can be read here: https://docs.unity3d.com/Manual/OcclusionCulling.html
There might be more answers than this, I'm not sure I fully understand what you wish and I am not a game designer by profession so my optimization skills are sub-par.
Vertex lights work fine on dynamic objects, but the second I make them static and bake lightmaps they're ignored.
I've tried changing to different "lightmodes" within the shader, but none has worked. Lightmode "ForwardBase" seems to really mess up, even though I would assume its the one to use given its description on https://docs.unity3d.com/Manual/SL-PassTags.html
Any suggestions would be very appreciated :)
My understanding of the question at hand
As I understand, when you bake a lightmap, the only light source that will change the light of the baked objects is a pixel light. But you would like to make it work with a vertex light.
I'm still not entirely sure whether you mean that the light simply won't bake into the baked map in the first place, or whether it cannot affect the light level of the object after it has been baked.
In any case, I did some searching.
Possible solution/explanation 1
When I searched I came across this tool and description.
https://assetstore.unity.com/packages/vfx/shaders/vertex-lit-shader-baked-shadows-realtime-light-75977
By default, using Unity’s built-in shader Mobile/VertexLit lighting
works only as either baked or realtime but you cannot display a
realtime light on a baked surface. This shader allows a baked surface
to also receive realtime lighting.
Note that the tool is free.
Possible solution/explanation 2
I also came across this tutorial: https://catlikecoding.com/unity/tutorials/rendering/part-16/
Where the author writes
When lightmaps are used, Unity will never include vertex lights. Their
keywords are mutually exclusive. So we don't need a variant with both
VERTEXLIGHT_ON and LIGHTMAP_ON at the same time.
Lastly please note that these solutions seem to be developed at earlier versions of Unity. Newer solutions more appropriate may exist.
Hope this helps you.
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
I'm generating a dungeon out of prefabs which means I design a room, save it in the resource folder and instantiate it at a random position with a random rotation while the game is running.
The problem I have is the lighting.
Because of the above mentioned generation process it has to be dynamic but it doesn't seem to work. Below you can see the comparison between a baked and realtime rendered room:
Baked (I also don't know where these strange lighting borders (on the walls), which are looking like someone painted the light with watercolors are coming from):
Realtime:
As you can see, the realtime room doesn't seem to reflect light in any way.
These are my lighting settings:
And this is my 'sun':
What am I doing wrong?
Your lighting settings have Ambient Light set to 0- with realtime lighting, this means nothing that can directly see the source of a light will be lit at all. The screenshot with baked lighting looks different because it has a baked lightmap.
If you're trying to get the real-time lighting to look exactly like the baked, soyy, but Unity refuses to bake lightmaps at runtime. The closest you can probably get is by setting your Ambient Light to a color and its intensity above zero. Playing around with Light Probes probably won't be much good, since you need to light an entire room in a vacuum.
An alternate solution, depending on how well you know Unity, would be to Frankenstein together different scenes, which is mentioned briefly in Unity's Intro to Global Illumination, though I can't find it anywhere else.
Relevant links:
Baked Lightmaps: http://docs.unity3d.com/Manual/GIIntro.html
Light Probes: http://docs.unity3d.com/Manual/LightProbes.html
Ambient Light: http://docs.unity3d.com/Manual/GlobalIllumination.html