- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我采用了定点柏林噪声实现:http://mrl.nyu.edu/~perlin/noise/INoise.java并对其稍作修改,以便在 c# 下编译。在这个版本中 1.0 由 2^16 表示。
当我传入输入坐标 (int x, int y, int z) 时,输出只是 x 和 z 坐标的总和。我的类或输入点有什么问题?以下是返回输出的示例:
for (int y = 0; y < 1; y++) {
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
Debug.Log(PerlinNoiseFixedPoint.Noise3D(x, y, z));
}
}
}
Output: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1, 2, 3, 4, 5, 6,
7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 4, 5, 6, 7,
8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 5, 6, 7, 8, 9, 10, 11, 12, 13,
14, 15, 16, 17, 18, 19, 20, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 23, 24, 25, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
26, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 14, 15, 16, 17, 18, 19, 20,
21, 22, 23, 24, 25, 26, 27, 28, 29, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
26, 27, 28, 29, 30
public class PerlinNoiseFixedPoint {
public static int Noise3D(int x, int y, int z) {
int X = x >> 16 & 255, Y = y >> 16 & 255, Z = z >> 16 & 255, N = 1 << 16;
x &= N - 1; y &= N - 1; z &= N - 1;
int u = Fade(x), v = Fade(y), w = Fade(z), A = p[X] + Y, AA = p[A] + Z, AB = p[A + 1] + Z,
B = p[X + 1] + Y, BA = p[B] + Z, BB = p[B + 1] + Z;
return Lerp(w, Lerp(v, Lerp(u, Grad(p[AA ], x , y , z ),
Grad(p[BA ], x-N , y , z )),
Lerp(u, Grad(p[AB ], x , y-N , z ),
Grad(p[BB ], x-N , y-N , z ))),
Lerp(v, Lerp(u, Grad(p[AA+1], x , y , z-N ),
Grad(p[BA+1], x-N , y , z-N )),
Lerp(u, Grad(p[AB+1], x , y-N , z-N ),
Grad(p[BB+1], x-N , y-N , z-N ))));
}
static int Lerp(int t, int a, int b) {
return a + (t * (b - a) >> 12);
}
static int Grad(int hash, int x, int y, int z) {
int h = hash & 15, u = h < 8 ? x : y, v = h < 4 ? y : h == 12 || h == 14 ? x : z;
return ((h & 1) == 0 ? u : -u) + ((h & 2) == 0 ? v : -v);
}
static int Fade(int t) {
int t0 = f[t >> 8], t1 = f[Math.Min(255, (t >> 8) + 1)];
return t0 + ( (t & 255) * (t1 - t0) >> 8 );
}
static int[] p = new int[512] {
151,160,137,91,90,15,
131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,
190, 6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,
88,237,149,56,87,174,20,125,136,171,168, 68,175,74,165,71,134,139,48,27,166,
77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,
102,143,54, 65,25,63,161, 1,216,80,73,209,76,132,187,208, 89,18,169,200,196,
135,130,116,188,159,86,164,100,109,198,173,186, 3,64,52,217,226,250,124,123,
5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,
223,183,170,213,119,248,152, 2,44,154,163, 70,221,153,101,155,167, 43,172,9,
129,22,39,253, 19,98,108,110,79,113,224,232,178,185, 112,104,218,246,97,228,
251,34,242,193,238,210,144,12,191,179,162,241, 81,51,145,235,249,14,239,107,
49,192,214, 31,181,199,106,157,184, 84,204,176,115,121,50,45,127, 4,150,254,
138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180,
151,160,137,91,90,15,
131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,
190, 6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,
88,237,149,56,87,174,20,125,136,171,168, 68,175,74,165,71,134,139,48,27,166,
77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,
102,143,54, 65,25,63,161, 1,216,80,73,209,76,132,187,208, 89,18,169,200,196,
135,130,116,188,159,86,164,100,109,198,173,186, 3,64,52,217,226,250,124,123,
5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,
223,183,170,213,119,248,152, 2,44,154,163, 70,221,153,101,155,167, 43,172,9,
129,22,39,253, 19,98,108,110,79,113,224,232,178,185, 112,104,218,246,97,228,
251,34,242,193,238,210,144,12,191,179,162,241, 81,51,145,235,249,14,239,107,
49,192,214, 31,181,199,106,157,184, 84,204,176,115,121,50,45,127, 4,150,254,
138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180,
};
static int[] f = new int[256] {
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3, 3, 4, 6, 7,
9, 10, 12, 14, 17, 19, 22, 25, 29, 32, 36, 40, 45, 49, 54, 60,
65, 71, 77, 84, 91, 98, 105, 113, 121, 130, 139, 148, 158, 167, 178, 188,
199, 211, 222, 234, 247, 259, 273, 286, 300, 314, 329, 344, 359, 374, 390, 407,
424, 441, 458, 476, 494, 512, 531, 550, 570, 589, 609, 630, 651, 672, 693, 715,
737, 759, 782, 805, 828, 851, 875, 899, 923, 948, 973, 998, 1023, 1049, 1074, 1100,
1127, 1153, 1180, 1207, 1234, 1261, 1289, 1316, 1344, 1372, 1400, 1429, 1457, 1486, 1515, 1543,
1572, 1602, 1631, 1660, 1690, 1719, 1749, 1778, 1808, 1838, 1868, 1898, 1928, 1958, 1988, 2018,
2048, 2077, 2107, 2137, 2167, 2197, 2227, 2257, 2287, 2317, 2346, 2376, 2405, 2435, 2464, 2493,
2523, 2552, 2580, 2609, 2638, 2666, 2695, 2723, 2751, 2779, 2806, 2834, 2861, 2888, 2915, 2942,
2968, 2995, 3021, 3046, 3072, 3097, 3122, 3147, 3172, 3196, 3220, 3244, 3267, 3290, 3313, 3336,
3358, 3380, 3402, 3423, 3444, 3465, 3486, 3506, 3525, 3545, 3564, 3583, 3601, 3619, 3637, 3654,
3672, 3688, 3705, 3721, 3736, 3751, 3766, 3781, 3795, 3809, 3822, 3836, 3848, 3861, 3873, 3884,
3896, 3907, 3917, 3928, 3937, 3947, 3956, 3965, 3974, 3982, 3990, 3997, 4004, 4011, 4018, 4024,
4030, 4035, 4041, 4046, 4050, 4055, 4059, 4063, 4066, 4070, 4073, 4076, 4078, 4081, 4083, 4085,
4086, 4088, 4089, 4091, 4092, 4092, 4093, 4094, 4094, 4095, 4095, 4095, 4095, 4095, 4095, 4095,
};
}
最佳答案
1.0 IS REPRESENTED BY 2^16
public static float Noise3D(float x, float y, float z)
{
//65536 = 2 ^ 16
return Noise3D((int)(x * 65536), (int)(y * 65536), (int)(z * 65536)) / 65536f;
}
导致以下噪音:
关于java - 定点柏林噪声返回输入点的总和作为输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31718221/
当我在定点 Z3Py 中启用解释生成选项时,我收到包含以下消息的核心转储。 Error setting 'DL_GENERATE_EXPLANATIONS', reason: unknown opti
我正在开发一些代码,可以从 HW 获取浮点或定点数据。目前我们将其作为 float 。 底层API都是定点的。所以我们必须将数据作为定点传回。我们使用的算法是 Cholesky。我想知道为什么我们必须
我有一个关于在 MATLAB 中为 Texas Instruments TMS320C64xx DSP 编写算法的问题: 我在 MATLAB 中草率地实现了我的过滤器。我的目标是使用 MATLAB E
我需要将 float 转换为Q31定点,Q31表示1个符号位,0位表示整数部分,31位表示小数部分。这意味着 Q31 只能表示 [-1,0.9999] 范围内的数字。 根据定义,从浮点转换为定点时,会
我正在使用第 3 方定点 antilog() 函数来计算分贝 out_mag = 10^( in_db/20 ) 的幅度。 antilog() 采用 Q6.25 格式作为输入,并在输出时提供 Q16.
我想将一个定点数(Q31/int32 表示具有 31 个小数位的小数)除以另一个 Q31/int32。我想计算z = y/x,知道abs(x)>abs(y)。因此,z<1,因此可以表示为另一个Q31/
我是一名优秀的程序员,十分优秀!