当前位置: 首页 > news >正文

Unity记录5.4-地图-带种子的柏林噪声

文章首发见博客:https://mwhls.top/4850.html。
无图/格式错误/后续更新请见首发页。
更多更新请到mwhls.top查看
欢迎留言提问或批评建议,私信不回。

汇总:Unity 记录

现在卡在了跨地图洞穴生成,没想到什么好的方法能够像地面一样随机连续洞穴块。

摘要:带种子的柏林噪声。

FastNoise_C#-2023/9/2
  • Auburn/FastNoise_CSharp: FastNoise C# Version
  • Feature:
    • Value Noise 2D, 3D
    • Perlin Noise 2D, 3D
    • Simplex Noise 2D, 3D, 4D
    • Cubic Noise 2D, 3D
    • Gradient Perturb 2D, 3D
    • Multiple fractal options for all of the above
    • Cellular (Voronoi) Noise 2D, 3D
    • White Noise 2D, 3D, 4D
    • Supports floats or doubles
带种子的柏林噪声-2023/9/1
  • Unity的柏林噪声设置不了种子,而后续我可能会需要通过固定输入来获取地图状态,因此改用FastNoise。
实现代码-2023/08/31-2023/9/1
  • 本来还包括一个地图块的类,但是我目前的边界点和周围是相关的,和随机生成有点冲突,考虑到用空间换计算量挺划算,所以也没实现计算边界点,因此这个类没什么信息量,没放。
    // Thanks to Auburn and other authers of FastNoise, I copied it in 2023/9/2 from https://github.com/Auburn/FastNoise_CSharppublic class Noise{public int seed;FastNoise _noise_generator;public Noise(int seed=-1){if (seed == -1) seed = System.DateTime.Now.Millisecond;this.seed = seed;_noise_generator = new(seed);}public float perlin(int x, int y, float scale){_noise_generator.SetNoiseType(FastNoise.NoiseType.Perlin);_noise_generator.SetFrequency(1/scale);float noise_value = _noise_generator.GetNoise(x, y);return noise_value;}public float perlin(int x, float scale){_noise_generator.SetNoiseType(FastNoise.NoiseType.Perlin);_noise_generator.SetFrequency(1/scale);float noise_value = _noise_generator.GetNoise(x, 0f);return noise_value;}static float perlin(int x, int y, float scale, int seed){FastNoise noise_generator = new(seed);noise_generator.SetNoiseType(FastNoise.NoiseType.Perlin);noise_generator.SetFrequency(1/scale);float noise_value = noise_generator.GetNoise(x, y);return noise_value;}static float perlin(int x, float scale, int seed){float noise_value = perlin(x, 0, scale, seed);return noise_value;}}
http://www.lryc.cn/news/185058.html

相关文章:

  • 阅读论文:Label-Free Liver Tumor Segmentation
  • leetcode64 最小路径和
  • 金盘图书馆微信管理后台信息泄露漏洞 复现
  • nginx实现负载均衡(三)
  • Android---深入理解ClassLoader的加载机制
  • 超自动化加速落地,助力运营效率和用户体验显著提升|爱分析报告
  • Linux posix_spawn和fork的区别
  • 聊聊分布式架构02——Http到Https
  • 1024 画跳动的爱心#程序代码 #编程语言 #计算机
  • 【排序算法】堆排序详解与实现
  • java Spring Boot整合jwt实现token生成
  • 如何使用Git和GitHub进行版本控制
  • 彻底解决 WordPress cURL error 28 错误
  • LLM项目代码改写
  • 小谈设计模式(14)—建造者模式
  • 【kubernetes】k8s中的选主机制
  • 学生选课系统基础版
  • redis no-appendfsync-on-rewrite
  • Spring Cloud Gateway2之路由详解
  • 阿里云RDS关系型数据库详细介绍_多版本数据库说明
  • Vue中的数据绑定
  • 前后端分离计算机毕设项目之基于SpringBoot的旅游网站的设计与实现《内含源码+文档+部署教程》
  • [JAVAee]Spring拦截器
  • 【nvm】Node Version Manager(NVM)安装配置以及使用(WIN版)
  • 【微服务】七. http客户端Feign
  • 【Spring Boot 源码学习】OnWebApplicationCondition 详解
  • 力扣之二分法
  • css图形化理解--扭曲函数skew()
  • 八、互联网技术——物联网
  • 聊聊MySQL的聚簇索引和非聚簇索引