def value(self, u: float, v: float, p: Vector3) -> Vector3: sines = math.sin(10 * p.x()) * math.sin(10 * p.y()) * math.sin( 10 * p.z()) if sines < 0: return self._texture0.value(u, v, p) else: return self._texture1.value(u, v, p)
def noise(self, p: Vector3): u = p.x() - math.floor(p.x()) v = p.y() - math.floor(p.y()) w = p.z() - math.floor(p.z()) i = math.floor(p.x()) j = math.floor(p.y()) k = math.floor(p.z()) # return self._ranvector[self._perm_x[i] ^ self._perm_y[j] ^ self._perm_z[k]] # c = [[[self._ranfloat[self._perm_x[(i + ii) & 255] ^ self._perm_y[(j + jj) & 255] ^ self._perm_z[(k + kk) & 255]] for kk in range(2)] for jj in range(2)] for ii in range(2)] c = list() for ii in range(2): for jj in range(2): for kk in range(2): c.append(self._ranvector[self._perm_x[(i + ii) & 255] ^ self._perm_y[(j + jj) & 255] ^ self._perm_z[(k + kk) & 255]]) return self.trilineart_interp(c, u, v, w)
def value(self, u: float, v: float, p: Vector3): # return Vector3(1, 1, 1) * 0.5 * (1 + self._noise.turb(p=self._scale * p)) # return Vector3(1, 1, 1) * self._noise.turb(self._scale * p) return Vector3(1, 1, 1) * 0.5 * ( 1 + math.sin(self._scale * p.z() + 10 * self._noise.turb(p)))