0/ 47/ /0

This time we will share several technical topics which are related to Program development. It is recommended to read for 15 minutes. Any unique insights or discoveries, please feel free to contact us or discuss.



Q1: In a model, there are two materials by default. At this time, if you use code to forcibly add a material, Unity will use the Mesh of the previous material in original material as Mesh of new material. So there are two problems:


1) Is it possible to assign Mesh to the shader;

2) How can I change the position of the original material but the effect is still displayed normally.


That is to say, make the two shaders in the picture below switch positions, and the effect is still displayed normally;

The first material is a color mapping material, and the second is a special effect wave material.

If your Mesh does not have Submesh, multiple shaders will be rendered multiple times, and the object used is the current Mesh. If there is Submesh, I set that the number of shaders are not allowed to be increased by default in Editor mode. I don’t know whether it is feasible through code, but if it can be added through the code but the Mesh cannot be assigned, it is quite strange.


Regarding the order, when the RenderQueue is the same, the order of opacity objects and transparency objects is different (the order of opaque objects is from near to far, so it may be considered that the array order should be reversed, the order of transparent objects is from far to near, according to the array order) . The material rendering order seems to be different for multi-material mesh. (Note that although RenderQueue is set into translucent queue, ZTest and ZWrite are still enabled)

So, if you want to control the rendering order of the two shaders, just adjust the RenderQueue of shader.

Finally, pay attention to the Warning given by Unity:

It can be optimized with multiple Pass, even control it by a macro in a Pass (of course, pay attention to the problem that too many macro switches cause the number of variants change).

Thanks to Jia Weihao for providing the answer above.


Q2: Can the SpriteRenderer in a 3D scene fill the entire screen? I use an orthogonal camera to take this background image specifically. This background image is placed in the scene. Can this background image adaptively fill the entire screen?

There are two types of adaptation, one is stretched (the picture will be deformed), and the other is not stretched (the picture will be cut).

Thanks to 雨松MOMO for providing the answer above.


Q3:How to export Log under iOS? We write Log file under Application.persistentDataPath, how to find this file on iPhone?

We are using the tool “iOSLogInfo”, which is convenient for viewing iOS logs on Windows.

Thanks to 雨松MOMO for providing the answer above.


Q4: I use the LowPolyWaterv2 plug-in, and make a water surface effect for a Shader in the scene. Then I meet the following problems:


1) When this Shader is not packaged into a separate AssetBundle package, the water surface is displayed normally after loading the scene;


2) When this Shader is packaged into a separate AssetBundle package, the water effect is abnormal after loading the scene, but Shader is not lost.


Is there any different logic between these two situations?

The main difference is the collection of Shader variants. Packing Shader separately requires manual selection of variants. Using Unity automatic collection will result in loss.

Thanks to Zheng Xiao for providing the answer above.


Q5: I use a model in the project, the version is Unity 2018.3.7. After the release, it cannot be displayed normally on Huawei P30, mate10, etc. In subsequent tests, I try modifying the model normal and rebind, but this problem is still not be solved. According to many solutions which have been tried, I find the following rules:

PS: The material used is Standard (Specular setup)


1) If the model is imported separately in the case of binding, then it can be displayed normally;

2) After the model is added with binding, it cannot be displayed normally;

3) After importing binding model into Unity, select “none” for Normals in the Model page of the Inspector interface to display the overall outline of the model;

4) After importing binding model into Unity, select “import” or “Calculate” for Normals in the Model page of the Inspector interface; neither can display normally

5) The Unity export settings are set as follows: Player Settings-> “Use 32-bit Display buffer” and “Disble Depth and Stencil” in Resolution and Presentation are all checked or unchecked, and they cannot be displayed normally;

6) Changing the material, but it cannot display normally;

7) Reduce the version, try it in Unity 5.2.3, the displayed model is all black, there is no mapping effect, and the color given by the material itself is not displayed (in the best case, the display is still abnormal).

The problem has been solved temporarily, but the specific reason is not particularly clear.


About the model:

1) For the model in question, a key frame is set on the rotation of the model before skinning;

2) For the model in question, there is non-zero data on the rotation of the model before skinning;


About setting:

Unity2018.3.7f1, GPU Skinning is checked when packaging by default.


Temporary solution:

Select invert GPU Skinning in Unity.


Current suppose:

It seems that GPU of Mali-G7X GPU used by Huawei has an error when calculating the initial bound pose for this model, and it doesn’t calculate the rotation information of the model skin.


Problems which still exist:

Un-skinning the model in 3D software, clearing all the information of the model, and then performing the binding animation, there are still problems. The reason is not clear for the time being. I will update it later if I know the reason.

Thanks to Xi Guoliang for providing the answer above.

This is the 66th UWA Technology Sharing for Unity Development. As we all know, Our life has a limit but knowledge has none. These problems are only the tip of the iceberg and there are more technical problems during our program development which deserve to discuss. Welcome to join UWA Q&A community, let‘s explore and share knowledge together!




Post a Reply