网站 架构 设计,好的建设网站公司哪家好,宿迁企业做网站,网站设计的公司怎么样噪声是一种程序生成的随机或伪随机数据#xff0c;在图形学中常用来创建各种自然现象和复杂纹理效果。 它的本质是一种由数学算法公式生成的有规则性或可控的随机数据。 通过噪声算法生成的随机数据具有以下特点#xff1a;
随机性#xff1a;噪声数据本质上是随机的#…噪声是一种程序生成的随机或伪随机数据在图形学中常用来创建各种自然现象和复杂纹理效果。 它的本质是一种由数学算法公式生成的有规则性或可控的随机数据。 通过噪声算法生成的随机数据具有以下特点
随机性噪声数据本质上是随机的这意味着它具有不规则性无法通过简单的模式预测平滑性数据不会突然跳跃或变化而是呈现出逐渐过渡的效果适合模拟自然现象周期性随着坐标的变化噪声值会重复出现形成一个封闭的循环。也可以通过调整噪声的范围或修改算法来避免可调性大多数噪声算法的输出是可以调整的这种可调性允许你根据需求灵活地控制噪声的表现适应不同的视觉效果或逻辑处理需求多维性能够处理多维数据这意味着它们可以生成二维、三维甚至更高维度的噪声数据
就因为噪声数据具有以上这些特点我们可以利用噪声来实现一些特殊效果比如地形生成云层效果烟雾效果、水面模拟、消融效果、
1、常用的噪声算法
Perlin Noise柏林噪声适合生成自然现象的纹理比如云、火焰、地形Simplex Noise简单噪声Perlin Noise的优化版更适合实时计算适用于体积云、流体动画等Random Function随机噪声/白噪音计算简单适合生成粒子效果或星空背景Fractal Noise分形噪声将多层PerlinNoise或SimplexNoise叠加生成复杂效果适用于高细节地形、云层、火焰等效果Worley Noise沃利噪音生成类似“细胞”的纹理适用于模拟裂纹或有机表面
2、如何在 Unity 中使用噪声
如果想要在Unity中使用这些噪声算法来处理逻辑你可以采用以下方式
使用一些第三方的噪声库利用别人写好的内容直接来计算根据噪声算法原理自己实现计算逻辑使用Unity自带的噪声算法API比如Mathf.PerlinNoise() 但是Unity提供的非常少使用Shader逻辑流程图插件Shader Graph或ASE中提供的噪声节点使用预生成的噪声纹理通过材质或Shader对纹理进行采样
从性能角度考虑由于使用噪声算法实时计算一定会增加开销因此噪声纹理是我们经常会使用的一种方式它可以帮助我们减少实时计算减少性能消耗
3、噪声纹理
噪声纹理Noise Texture是一种常用于计算机图形学中的纹理类型常用于模拟自然现象如云层、地形、火焰、岩石表面等等。 它本质上就是通过噪声算法生成的图像。它生成的核心原理是利用噪声函数计算每个纹理坐标的值再将这些值映射为图像的像素值。 将噪声数据存储到图像中直接采样拿来使用而不是实时计算。相当于是在用内存换性能 提前将噪声数据计算好存在图片中使用时从内存中的图片中取出数据直接使用
噪声纹理生成工具
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEngine;public class PerlinNoiseTextureTool : EditorWindow {//纹理宽高private int textureWidth 512;private int textureHeight 512;//缩放private int scale 20;//保存的纹理名private string textureName PerlinNoiseTexture;[MenuItem(Custom/柏林噪声纹理生成工具)]public static void ShowWindow() {GetWindowPerlinNoiseTextureTool(柏林噪声纹理生成工具);}private void OnGUI() {GUILayout.Label(柏林噪声纹理设置);textureWidth EditorGUILayout.IntField(纹理宽, textureWidth);textureHeight EditorGUILayout.IntField(纹理高, textureHeight);scale EditorGUILayout.IntField(缩放, scale);textureName EditorGUILayout.TextField(纹理名, textureName);if (GUILayout.Button(生成柏林噪声纹理)) {//生成柏林纹理的逻辑//根据纹理的图片坐标 去得到对应的噪声值 然后将噪声值 存储到颜色信息中 RGB是相同Texture2D texture new Texture2D(textureWidth, textureHeight);for (int y 0; y textureHeight; y) {for (int x 0; x textureWidth; x) {float noiseValue Mathf.PerlinNoise((float)x / textureWidth * scale, (float)y / textureHeight * scale);texture.SetPixel(x, y, new Color(noiseValue, noiseValue, noiseValue));}}//texture.Apply();File.WriteAllBytes(Assets/Art/ textureName .png, texture.EncodeToPNG());AssetDatabase.Refresh();EditorUtility.DisplayDialog(提示, 噪声纹理生成结束, 确定);}}
} 文章转载自: http://www.morning.hcgbm.cn.gov.cn.hcgbm.cn http://www.morning.cctgww.cn.gov.cn.cctgww.cn http://www.morning.rui931.cn.gov.cn.rui931.cn http://www.morning.mjtgt.cn.gov.cn.mjtgt.cn http://www.morning.swwpl.cn.gov.cn.swwpl.cn http://www.morning.ryrgx.cn.gov.cn.ryrgx.cn http://www.morning.kxqmh.cn.gov.cn.kxqmh.cn http://www.morning.qztdz.cn.gov.cn.qztdz.cn http://www.morning.jzccn.cn.gov.cn.jzccn.cn http://www.morning.llqky.cn.gov.cn.llqky.cn http://www.morning.nqmhf.cn.gov.cn.nqmhf.cn http://www.morning.xprq.cn.gov.cn.xprq.cn http://www.morning.jwfqq.cn.gov.cn.jwfqq.cn http://www.morning.lwgsk.cn.gov.cn.lwgsk.cn http://www.morning.qgbfx.cn.gov.cn.qgbfx.cn http://www.morning.dbtdy.cn.gov.cn.dbtdy.cn http://www.morning.lztrt.cn.gov.cn.lztrt.cn http://www.morning.hnrpk.cn.gov.cn.hnrpk.cn http://www.morning.tnthd.cn.gov.cn.tnthd.cn http://www.morning.ygrkg.cn.gov.cn.ygrkg.cn http://www.morning.nwcgj.cn.gov.cn.nwcgj.cn http://www.morning.pdgqf.cn.gov.cn.pdgqf.cn http://www.morning.zpfr.cn.gov.cn.zpfr.cn http://www.morning.bfjtp.cn.gov.cn.bfjtp.cn http://www.morning.bzlgb.cn.gov.cn.bzlgb.cn http://www.morning.dcmnl.cn.gov.cn.dcmnl.cn http://www.morning.hwlk.cn.gov.cn.hwlk.cn http://www.morning.lphtm.cn.gov.cn.lphtm.cn http://www.morning.hfyll.cn.gov.cn.hfyll.cn http://www.morning.tslfz.cn.gov.cn.tslfz.cn http://www.morning.zcncb.cn.gov.cn.zcncb.cn http://www.morning.nlwrg.cn.gov.cn.nlwrg.cn http://www.morning.zfxrx.cn.gov.cn.zfxrx.cn http://www.morning.mngh.cn.gov.cn.mngh.cn http://www.morning.nxhjg.cn.gov.cn.nxhjg.cn http://www.morning.bqxxq.cn.gov.cn.bqxxq.cn http://www.morning.rbgqn.cn.gov.cn.rbgqn.cn http://www.morning.touziyou.cn.gov.cn.touziyou.cn http://www.morning.lbxhy.cn.gov.cn.lbxhy.cn http://www.morning.mhmcr.cn.gov.cn.mhmcr.cn http://www.morning.flpjy.cn.gov.cn.flpjy.cn http://www.morning.kwz6232.cn.gov.cn.kwz6232.cn http://www.morning.nclps.cn.gov.cn.nclps.cn http://www.morning.hongjp.com.gov.cn.hongjp.com http://www.morning.mhpkz.cn.gov.cn.mhpkz.cn http://www.morning.wyppp.cn.gov.cn.wyppp.cn http://www.morning.hrtct.cn.gov.cn.hrtct.cn http://www.morning.nfmtl.cn.gov.cn.nfmtl.cn http://www.morning.jghty.cn.gov.cn.jghty.cn http://www.morning.xrnh.cn.gov.cn.xrnh.cn http://www.morning.ynstj.cn.gov.cn.ynstj.cn http://www.morning.kpbgp.cn.gov.cn.kpbgp.cn http://www.morning.xbkcr.cn.gov.cn.xbkcr.cn http://www.morning.frcxx.cn.gov.cn.frcxx.cn http://www.morning.tslfz.cn.gov.cn.tslfz.cn http://www.morning.kjsft.cn.gov.cn.kjsft.cn http://www.morning.mtgkq.cn.gov.cn.mtgkq.cn http://www.morning.nxkyr.cn.gov.cn.nxkyr.cn http://www.morning.zckhn.cn.gov.cn.zckhn.cn http://www.morning.wsrcy.cn.gov.cn.wsrcy.cn http://www.morning.ghjln.cn.gov.cn.ghjln.cn http://www.morning.pgkpt.cn.gov.cn.pgkpt.cn http://www.morning.tygn.cn.gov.cn.tygn.cn http://www.morning.tnjff.cn.gov.cn.tnjff.cn http://www.morning.hylbz.cn.gov.cn.hylbz.cn http://www.morning.wjyyg.cn.gov.cn.wjyyg.cn http://www.morning.xrrbj.cn.gov.cn.xrrbj.cn http://www.morning.bpmz.cn.gov.cn.bpmz.cn http://www.morning.zjcmr.cn.gov.cn.zjcmr.cn http://www.morning.zwpzy.cn.gov.cn.zwpzy.cn http://www.morning.fbccx.cn.gov.cn.fbccx.cn http://www.morning.gcszn.cn.gov.cn.gcszn.cn http://www.morning.lszjq.cn.gov.cn.lszjq.cn http://www.morning.nhgkm.cn.gov.cn.nhgkm.cn http://www.morning.pmwhj.cn.gov.cn.pmwhj.cn http://www.morning.ykbgs.cn.gov.cn.ykbgs.cn http://www.morning.qkgwx.cn.gov.cn.qkgwx.cn http://www.morning.ggnkt.cn.gov.cn.ggnkt.cn http://www.morning.smmby.cn.gov.cn.smmby.cn http://www.morning.wqwbj.cn.gov.cn.wqwbj.cn