码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • 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_CSharp
        
        public 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;
            }
        }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
  • 相关阅读:
    大数据培训—DolphinScheduler(三)
    HTML5期末大作业:游戏网站设计与实现——基于bootstrap响应式游戏资讯网站制作HTML+CSS+JavaScript...
    裸机 lwip,客户端断开连接后,无法重新连接server端
    Python---练习:求世界杯小组赛的总成绩(涉及:布尔类型转换为整型)
    Python语言开发学习之使用Python预测天气
    AutoLabel(自动标签)
    C#向RichTextbox中复制内容时去除源文本格式
    Docker从认识到实践再到底层原理(五)|Docker镜像
    金仓数据库KStudio使用手册(3. 数据库管理)
    一篇五分生信临床模型预测文章代码复现——Figure 4-6 临床模型构建(二)
  • 原文地址:https://blog.csdn.net/asd123pwj/article/details/133678205
  • 最新文章
  • 沪漂五周年了:我越来越迷茫了
    Agentic Skill Routing 实战:别再把所有 Skill 塞进 AI Agent 上下文
    MySQL-Seconds_behind_master的精度误差
    [MAF预定义ChatClient中间件-03]CachingChatClient——利用缓存省钱省时间
    AI的至暗历史:从万众期待到被政府撤资,AI的两次死亡徘徊
    Agent OS :五种驯服不确定性的范式
    PortSwigger SQL注入LAB11
    数据库即时编译JIT
    [Begin]AI Learn Data Day 0
    深度学习进阶(二十七)现代 LLM 的核心架构设计其二:SwiGLU
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
小工具 小游戏
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1

京公网安备 11010502049817号