ShaderGraph introductory tutorial

0x00 Preface

In this article, we have selected several representative questions in the Unity official community exchange group and UUG community group in the past few weeks, and summarized them here to share with you. It mainly covers ** Scripting, Assetsbundle, Tilemap, Graphic, UGUI, Asset, Profiler, App, Shader, Timeline, Lighting** and other fields, which will focus on topics related to LWRP and mixed lighting.

At the same time, everyone is welcome to join our official technical group discussing dry goods to exchange views and share experiences.
Unity official community exchange group: 629212643

0x01 Scripting

Q: Unity2018.2 creates a new project, and then creates a new script. It prompts when it opens . Unity has not generated sln files. Where should I set it?

2F40BAC6D11DE0D5610A43D5402B5FFB.png

 

A: First, let's check if you used Visual Studio 2017 when creating a new project in Unity 2018? Unity2018 no longer supports Visual Studio 2015. In order to solve this problem, please download the latest version of Visual Studio 2017. In addition, you can also use Visual Studio Code, which is a faster, lighter, script editor suitable for Unity.

0x02 Assetsbundle

Q: Have you ever encountered a situation where the MD5 and Unity's own HASH values ​​of most of the AssetBundle files from different computers in the same project updated from SVN are different from those of Unity's own HASH?
A: Did you miss uploading meta files? ? We tried the project once, and a colleague missed uploading the .meta file, and when other colleagues updated it, because there was no meta file for him, unity was automatically generated locally, so that different people generated their own meta files from the svn update. , And then it's empty when compared to md5. The meta file is for Unity to record the GUID. If it is different, there seems to be a problem to calculate the MD5 in the AssetBundle. ( Guangzhou-Wood Snake Stick )

0x03 Tilemap

Q: When drawing the tilemap, in the scene, a tile cannot fill the unit blocks in the scene. May I ask what's going on?

E10511BC94C5BAFA248E576E599A6B01.jpg

 

A1: It is the size I cut, one piece is 64 x 64. I set the pixels oer unit of sprite to 100, and I set it to 64.

Screen shot 2018-08-12 at 2.46.30 pm.png


( Chengdu—mid )
A2: In addition to checking the Pixels Per Unit property of Sprite, you can also check whether the Scale property of the TileMap component is 1. The setting here may also cause a mismatch between the tile and the unit block in the scene.

Screenshot 2018-08-12 at 2.48.06.png in the afternoon

 

0x04 Graphic

Q: @慕容小匹夫 How do you change the range of this reflection? They don't match up. Thanks a lot.

0493DD5F3397B22D6A46614905E62B34.jpg

 

A: This is a problem caused by incorrect sampling. If you are using reflect probe, check box projection for indoor or small-scale scene reflection. This is because corresponding to the same Reflection Probe, objects in different positions should have different reflection effects. The general Cubemap is more suitable for simulating the reflection of objects in a large outdoor scene. If you use a cubemap in a small indoor area, it may be confused. Tick ​​box projection can be used to correct this error.

0x05 UGUI

Q: The ugui font is displayed normally in the editor, but it cannot be displayed when the packaged pc is running. Has anyone encountered this situation? The editor is normal whether it is loaded from resources or from AssetBundle. It's all normal, but it can't be displayed after packing the pc.

70A4F77BC434BD0EF34D6B05D12CC1F1.png

 

A: It lacks the shader of the UI part built in Unity. I downloaded it and included it in Graphics. ( Beijing-Rabbit 2 )

0x06 Asset

Q: I 'm asking for help. I am crazy to output this when I package it, and I can't see which file it is.

5FF8D3C255F139310F50283B05B4E406.png

 

A: It looks a bit like an error from PVRTexTool. Unity will call PVRTexTool's command line tool to compress the texture, so we can narrow the scope of the error file to texture resources.
First of all, you can check whether there is a compressed texture in pvrtc format. You can also look at the texture format of your etc2_x and make an exclusion method for the texture in the project.
For the discussion of related bugs, please check the related topics in the imgtec community:
https://forums.imgtec.com/t/pvrtextoolcli-bug-encoding-etc2-rgb-a1-etc2-rgb-a1-ubn-srgb/2365

0x07 Profiler

Q: Check the Unity profiler on windows. Is it normal that the "total system memory usage" has been increasing indefinitely?

image.png

 

A: It looks abnormal. This value is obtained by using PROCESS_MEMORY_COUNTERS_EX on windows. You can take a look to see if the Reserved Total in your project has continued to grow. If it is all rising, just optimize it.

0x08 App

Q1: I now want to make a loading window, and then display the game content after loading. But I hope that the loaded window does not have a border (not closed and minimized, etc.). Now call Win32 API to set up, you will always see one with a border first, and then quickly to no border. It's just that there is a process of jumping, and it's uncomfortable to watch.
A: You can call SetWindowLong. code show as below:

EC50EB11D30DA6F05EF7D2444B68F4A8.png


If there are still jumps, you can consider adding popupwindow to the program startup parameters. ( Beijing-Rabbit 2 )

 

Q2: An error of "Unable to Convert classes into dex format" appears during Android packaging. For help.

ECC8F2256A92294FDDC24A77E3F7772A.jpg


A: This problem is usually caused by plug-ins. You can check whether there are duplicate jars in the project, and delete them if there are duplicates. If you don't want to search one by one, you can also consider deleting the "plugins" folder of the project, and then re-import all the plugins.

 

0x09 Shader

Q: Using "UsePass" in Shader to refer to the Pass of another SubShader of the same Shader will cause a crash. Is this a bug or is it impossible to write this way? The version I use is 2017.4.6f1. For example:

Screenshot 2018-08-10, 4.40.10 PM.png

 

A: UsePass is mainly used to implement code reuse in different shaders. You can also see related descriptions when you check the documentation:

Some of the shaders could reuse existing passes from other shaders, reducing code duplication

So don't use UsePass to refer to Pass in the same Shader.

0xA Timeline

Q: I would like to ask you a question about timeline. Why does the position of the middle adjustment of timeline shift after running?

87E1A3BD8204E7405791575D9A00B21A.png

 

8F6CDF66FBEB4FB011A6E5EC783AEBA2.png

 

A: Does the Animator component on your model have a Controller? You can remove the Controller on the Animator and completely control the action by Timeline. Because its animation affects the upper layer incrementally in the running phase, it overwrites the upper layer data in the editing phase. So it may be different.

0xB Lighting

Q : This is the light probe of the default pipeline. You can see that the dynamic objects enter the shadow range and become darker.

4828DF83-2D02-4D3C-A5C2-9CE3481B72DE.gif


This is the effect of LWRP, the light prob shadow will not have any effect on dynamic objects after baking

20F2494B-77DF-477E-A119-E9CA2677DD85.gif


The baking mode is Mix subtractive, and the lighting is a Directional light in a mixed mode. Please tell me, does the subtractive baking mode of lwrp make the light probe ignore the influence of shadows?
A : This is not the reason for lightprobe, but the current lwrp support for mixed light is not perfect. More support for mixed light is still under development. Under the lwrp pipeline, if mixed is not used, only bake light is used, and the light probe can correctly act on dynamic objects.

BDF45290-563B-423C-BDAC-7C2C131EB20C.png


The picture above is a comparison between the traditional rendering pipeline and LWRP in terms of the function of lighting mode.

Guess you like

Origin blog.csdn.net/mango9126/article/details/104055118