[unity makes wheels] use PerlinNoise (Berlin noise) to achieve smooth light flickering effect

explain

Perlin noise is an algorithm for generating random numbers, which is often used in the generation of natural environments in games, such as terrain, clouds, water surfaces, etc. It can generate a continuous, natural sequence of random numbers, making the generated random numbers more realistic. In this code example, Perlin noise is used to generate a random number that is used to control the brightness of the light. Specifically, Mathf.PerlinNoise(Time.time, Time.time *5.0f) generates a random number between 0 and 1, and then uses Mathf.Lerp(min, max, noise) to map this random number to Between min and max, as the brightness value of the light.

the code

using UnityEngine;

//灯光闪烁
[RequireComponent(typeof(Light))

Guess you like

Origin blog.csdn.net/qq_36303853/article/details/130468910