Unity interview questions daily 5 questions 06

26. How to achieve fog of war

Will share after Unity implements it later


27. Unity optimization method, Draw call (cpu gpu)

Concept: Draw call is a command. Its initiator is the CPU and the receiver is the GPU. This command will only point to a list of primitives that need to be rendered, and will not contain any material information. When given a Draw Call, the GPU starts calculations based on the rendering state and all input vertex data. The CPU and GPU work in parallel, and they are connected through a command buffer. The CPU sends rendering commands to it, and the GPU receives and executes the corresponding rendering commands.

If there are too many Draw Calls, the CPU will spend a lot of time submitting Draw Calls, causing CPU overload and affecting the frame rate.

What methods can reduce the number of draw calls:

1) Use Solid Color mode when the Solid Color mode can meet the needs.

2) Minimize the use of multiple Canvas

3) Try to put components of the same type together (because if a Text and an Image are mixed like this, each Text and Image will generate a Drawcall)

4) Try to use atlases to combine multiple small pictures (if each Image displays different pictures, then each Image will generate a Draw call)

5) Reduce the use of real-time lighting and bake it into a light map to replace real-time lighting.


28. The most important parameters of Pbr, several equations

reflectance equation

Lo(p,you)=∫Ω(kdcπ+ksDGF4(you)(win))Li(p,you)(win)dwi

The specific content is too complicated. Please refer to the supplement of Daily Question 06 for specific reprints.


29. How to build a pbr workflow

PBR workflows are mainly divided into two types, one is based on metal (Metal-Roughness), and the other is based on specular reflection  (Specular-Glossiness). Unity supports both workflows, while UE4 only supports metallic workflow.

The process is as follows: Basic model->High-poly production->Topology->Expand UV->Baked texture->SP texture production->Import engine

The author has used PBR workflow, corresponding software MAYA, Z-brush, Substance Painter, Unity (UE)


30. Topk problem and its variants and various solutions

The topK problem is a classic algorithm problem. Its main idea is to find the smallest (large) k numbers from a sequence. The easiest way to face this problem is of course to sort first and then take the first k numbers, but this is a waste of time. , the more classic method is to use the ideas of quick sort and stack sort.

Reference topic:

215. The Kth largest element in an array

Specific solutions can include brute force, quick sort, bubble sort, merge sort, depth first search, divide and conquer, etc.

Share JAVA bubble sort here:

class Solution {
    public int findKthLargest(int[] nums, int k) {
        for(int i = 0;i < k;i++){
            int max = i;
       
            for(int j = i+1;j < nums.length;j++)
                if(nums[j] > nums[max])
                    max = j;
 
            if(max!= i){
                int temp = nums[i];
                nums[i] = nums[max];
                nums[max] = temp;
            }
        }
        return nums[k-1];
    }
}

For more solutions, you might as well go to Likou Problem Solution

Unity interview questions daily 5 questions 07

Guess you like

Origin blog.csdn.net/Anyo1n/article/details/126809903