【NoisyHeart的炼成】Part5:Perlin噪声的HLSL实现
来源:互联网 发布:sql怎么导入数据 编辑:程序博客网 时间:2024/06/03 13:24
bug时时有,MS不例外。
HLSL自带的noise()出了点问题,迫使我自己实现一个,借此机会我也调整了一下,缔造一个适合自己的鲁棒noise()。
噪声在图像的作用非常重要,而且Perlin的思想非常简单,至于Perlin的说明,我是不会在这说明的(这里只会写其它地方找不到的内容)。
#define PI 3.141592653589793240float Perlin(int n) { n = (n << 13) ^ n; return 1.0 - ((n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff) / 1073741824.0; }float CosineInterpolate (float a, float b, float x) { float f = (1.0 - cos (x * PI)) * 0.5; return a * (1.0 - f) + b * f;}float SmoothedNoise(int v) { return Perlin(v) / 2 + Perlin(v-1) / 4 + Perlin(v+1) / 4;}int FastFloor (float v) { return (int) (v < 0) ? v - 1 : v; }float InterpolatedNoise (float v) { int i = FastFloor(v); float v1 = SmoothedNoise (i); float v2 = SmoothedNoise (i + 1); return CosineInterpolate(v1, v2, v - i);}float PerlinNoise(float v){float total = 0;float amplitude = 1.0f;float frequency = 1.0f;for( int i = 0 ; i < 2; i++){total += InterpolatedNoise (v * frequency) * amplitude; frequency *= 2.0f; amplitude *= 0.666f;}return total;}(注意:这也是HLSL代码)
0 0
- 【NoisyHeart的炼成】Part5:Perlin噪声的HLSL实现
- 【NoisyHeart的炼成】Part0:效果预览
- 【NoisyHeart的炼成】Part1:ModelViewerCamera
- 【NoisyHeart的炼成】Part2:Beam效果
- 【NoisyHeart的炼成】Part4:顶点计算
- 【NoisyHeart的炼成】Part 8:总结
- 【NoisyHeart的炼成】Part3:Beam的平滑问题
- 【NoisyHeart的炼成】Part6:FacetoCamera 的Beam光束
- 【NoisyHeart的炼成】Part7:Beam头尾相连
- billboard公告板技术与perlin噪声的实现
- perlin 噪声
- BGRABitmap图像操作8:生成纹理,基本的Perlin噪声地图
- 柏林噪声 perlin noise
- 柏林噪声(Perlin Noise)
- perlin噪声函数
- perlin噪声函数
- [柏林噪声(Perlin Noise)(译)]
- [算法]柏林噪声 Perlin Noise
- 为什么你还一直在穷打工?
- Java swing 之 标签控件 和 图标控件的使用
- POJ 2823 Sliding Window (单调队列)
- JNI小结
- 符号释意字典
- 【NoisyHeart的炼成】Part5:Perlin噪声的HLSL实现
- hdu4763(KMP的应用)
- POJ3278 Catch That Cow(BFS入门)
- textblock 实现滚动条和自动换行
- 莱斯大学Python课程Mini-project#5 - Memory
- 黑马程序员_Java技术博客书写规范
- 大家来写2048 。。。控制台版
- cocos2d-x3.0 RenderTexture(二)
- windows下tomcat的安装与配置及eclipse的tomcat服务器搭建