원문: http://http.developer.nvidia.com/GPUGems/gpugems_ch05.html
Chapter 5. Implementing Improved Perlin Noise
Ken Perlin
New York University
This chapter focuses on the decisions that I made in designing a new, improved version of my Noise function. I did this redesign for three reasons: (1) to make Noise more amenable to a gradual shift into hardware, (2) to improve on the Noise function's visual properties in some significant ways, and (3) to introduce a single, standard version that would return the same values across all hardware and software platforms.
이 챕터는 나의 잡음 함수의 새롭고 향상된 버전에 결정한 것에 초점을 맞춘다. 나는 3가지 이유로 이것을 재설계했다: (1) 하드웨어로의 점차적인 대체에 더 잘 따르는 잡음을 만들기 위해, (2) 몇몇 중요한 방식에서 잡음 함수의 시각적 특성을 개선하기 위해, (3) 모든 하드웨어와 소프트웨어 플랫폼에 걸쳐 같은 값을 반환하는 하나의 표준화된 버전을 도입하기 위해.
The chapter is structured as follows: First, I describe the goals of the Noise function itself and briefly review the original implementation. Then I talk about specific choices I made in implementing improved Noise, to increase its quality and decrease visual artifacts. Finally, I talk about what is needed for gradual migration to hardware. The goal is to allow Noise to be implemented in progressively fewer instructions, as successive generations of GPUs follow a path to more powerful instructions.
이 챕터는 다음과 같이 구성되어 있다: 우선, 잡음 함수 자체의 목표를 설명하고 기존의 구현을 간단히 리뷰한다. 그런 다음 품질을 높이고 시각적 결함을 줄이기 위해 개선된 잡음을 구현하는 구체적인 선택들에 대해 얘기한다. 마지막으로, 하드웨어로의 점차적인 이동에 무엇이 필요한지에 대해 얘기한다. GPU의 연속되는 세대가 더 강력한 명령어로 가는 경로를 따르는 것처럼, 진보적으로 더 적은 명령어에서 잡음을 구현하게 하는 것이 목표이다.
5.1 The Noise Function
The purpose of the Noise function is to provide an efficiently implemented and repeatable, pseudo-random signal over R3 (three-dimensional space) that is band-limited (most of its energy is concentrated near one spatial frequency) and visually isotropic (statistically rotation-invariant).
잡음 함수의 목적은 R3 (3-차원 공간) 에 걸친 효율적으로 구현되고 반복될 수 있는, 의사-랜덤 신호를 제공하는 것이다. 그 신호는 밴드-제한적(에너지의 대부분은 한 공간의 주파수 근처에 집중되어 있다)이고 시각적으로 등방성(통계상으로 회전-불변)이다.
The general idea is to create something that gives the same effect as a completely random signal (that is, white noise) that has been run through a low-pass filter to blur out and thereby remove all high spatial frequencies. one example is the gradually rising and falling hills and valleys of sand dunes, as shown in Figure 5-1.
일반적인 아이디어는 낮은-패스 필터를 적용하여 흐릿하게 해서 그로 인해 모든 높은 공간의 주파수를 제거해서 완전히 무작위적인 신호(즉, 화이트 잡음)와 같은 효과를 주는 것을 만드는 것이다. 한가지 예는 그림 5-1에서 보여지는 것과 같은 사막의 점차적으로 오르내리는 언덕과 계곡이다.
5.2 The Original Implementation
The initial implementation, first used in 1983 and first published in 1985 (Perlin 1985), defined Noise at any point (x, y, z) by using the following algorithm:
1993년에 처음 사용됐고 1985년에 처음 발표된(Perlin 1985) 최초의 구현은 다음의 알고리즘을 사용하여 임의의 점 (x, y, z)에서의 잡음을 정의했다.
- At each point in space (i, j, k) that has integer coordinates, assign a value of zero and a pseudo-random gradient that is hashed from (i, j, k).
- Define the coordinates of (x, y, z) as an integer value plus a fractional remainder: (x, y, z) = (i + u, j + v, k + w). Consider the eight corners of the unit cube surrounding this point: (i, j, k), (i + 1, j, k), . . . (i + 1, j + 1, k + 1).
- Fit a Hermite spline through these eight points, and evaluate this spline at (x, y, z), using u, v, and w as interpolants. If we use a table lookup to predefine the Hermite cubic blending function 3t 2 - 2t 2, then this interpolation requires only seven scalar linear interpolations: for example, four in x, followed by two in y, followed by one in z, as shown in Figure 5-2.
- 정수 좌표 (i, j, k)의 각 점에, 0의 값과 (i, j, k)로부터 해쉬된 의사-랜덤 증감을 지정한다.
- 정수값에 소수 부분을 더해서 (x, y, z)의 좌표를 정의한다: (x, y, z) = (i + u, j + v, k + w). 이 점 주위의 단위 입장체의 꼭지점 8개를 고려한다: (i, j, k), (i + 1, j, k), . . . (i + 1, j + 1, k + 1)
- 이 8개의 점을 통해 에르미트 스플라인 곡선에 맞추고, 보간자로 u, v, w을 사용하여 (x, y, z)에서 이 스플라인의 값을 구한다. 에르미르 입장체 블렌딩 함수 3t 2 - 2t 2를 미리 정의한 룩업 테이블을 사용한다면, 이 보간은 오직 7번의 스칼라 선형 보간만을 요구한다: 예를 들면, 그림 5-2에서 보여지는 것과 같이, x축으로 4번, y축으로 2번, z 축으로 한번 스칼라 선형 보간이 수행된다.
Figure 5-2 Steps Required to Interpolate a Value from Eight Samples in a Regular 3D Lattice
This approach worked reasonably well. A two-dimensional slice through the Noise function looks like Figure 5-3.
이 접근법은 상당히 잘 작동했다. 잡음 함수를 통한 2차원 조각은 그림 5-3처럼 보인다.
5.3 Deficiencies of the Original Implementation
Unfortunately, Noise had the following deficiencies:
불행히도, 잡음은 다음과 같은 결함이 있다.
- The choice of interpolating function in each dimension was 3t 2 - 2t 3, which contains nonzero values in its second derivative. This can cause visual artifacts when the derivative of noise is taken, such as when doing bump mapping.
- The hashing of gradients from (i, j, k) produced a lookup into a pseudo-random set of 256 gradient vectors sown on a 3D sphere; irregularities in this distribution produce unwanted higher frequencies in the resulting Noise function. See Figure 5-4.
- 각 차원에서 보간 함수의 선택은 두번째 도함수에 0의 값을 포함하는 3t 2 - 2t 3였다. 이것은 범프 맵핑을 수행할 때와 같이 잡음의 도함수가 사용될 때 시각적 결함을 일으킬 수 있다.
- (i, j, k)으로부터의 증감 해싱은 3D 구에 흩어진 256 증감의 의사-랜덤 세트로의 색인을 만들어낸다: 이 분포의 불규칙성은 잡음 함수의 결과에 원하지 않은 더 높은 주파수를 만들어낸다. 그림 5-4를 보라.
Figure 5-4 Irregular Distribution of Gradient Vectors
In retrospect, I realize I should have applied a relaxation algorithm in the preprocessing step that chooses the pseudo-random gradient directions, repulsing these points away from each other around the sphere to form a more even, Poisson-like distribution, which would have reduced unwanted high spatial frequencies, giving a result like the one visualized in Figure 5-5.
되돌아 보면, 의사-랜덤 증감 방향을 선택하는 전처리 단계에서 완화된 알고리즘을 적용하여, 원하지 않는 높은 공간의 주파수를 줄일수 있는, 포아송 분포 같은 형태로 구 주위에 있는 서로 다른 점들을 떨어트려놓아야했다는 것을 깨닫는다. 그 결과는 그림 5-5와 같다.
Recently I realized that such a large number of different gradient directions is not even visually necessary. Rather, it is far more important to have an even statistical distribution of gradient directions, as opposed to many different gradient directions. This is consistent with perceptual research demonstrating that although human pre-attentive vision is highly sensitive to statistical anomalies in the orientation of texture features, our vision is relatively insensitive to the granularity of orientations, because our low-level vision system will convert a sufficiently dense set of discrete orientations into the equivalent continuous signal (Grill Spector et al. 1995). The human vision system performs this conversion at a very early stage, well below the threshold of conscious awareness.
최근에 나는 그렇게 많은 수의 다른 증감 방향이 시각적으로 필요하지 않다는 것을 깨달았다. 오히려, 많은 다른 증감 방향과는 반대로 증감 방향의 통계적인 분포를 가지는 것이 훨씬 더 중요하다. 우리의 저수준 시각 체계는 충분히 밀집된 개별 방위의 세트를 상응하는 연속된 신호로 변환시킬 것이기 때문에, 이것은 인간의 전(pre)-주의 시각이 텍스쳐 형태의 방위에 있는 통계적인 변칙에는 매우 민감할지라도, 우리의 시각은 방위의 입도(구성 입자의 크기)에는 상대적으로 무감각하다는 것을 증명하는 지각 연구와 일관된 것이다(Grill Spector et al. 1995). 인간의 시각 체계는 의식적으로 인식하기 훨씬 이전 단계에서 이 변환을 수행한다.
Given a Noise implementation with a statistically even distribution of gradient directions, it is fairly straightforward to build procedural expressions that create complex-looking textures. For example, Figure 5-6 shows four successively more complex texture expressions built from Noise.
증감 방향이 통계적으로 균일하게 분포되어 있는 잡음 구현이 주어지면, 복잡하게 보이는 텍스쳐를 생성하는 절차적 수식을 만드는 것은 아주 수월하다. 예를 들면, 그림 5-6은 잡음으로부터 생성된 4개의 연속적인 더 복잡한 텍스쳐 수식을 보여준다.
Moving clockwise from the top left, these expressions are:
왼쪽 위부터 시계방향으로 해당 수식은 다음과 같다:
In each case, color splines have been applied as a postprocess to tint the results.
각 경우에, 색 스플라인은 후처리로 결과를 색칠하기 위해 적용되었다.
5.4 Improvements to Noise
The improvements to the Noise function are in two specific areas: the nature of the interpolant and the nature of the field of pseudo-random gradients.
잡음 함수의 개선은 보간법의 성질과 의사-랜덤 증감 필드의 성질, 2가지의 특정 부분에 좌우된다.
As I discussed in Perlin 2002, the key to improving the interpolant is simply to remove second-order discontinuities. The original cubic interpolant 3t 2 - 2t 3 was chosen because it has a derivative of zero both at t = 0 and at t = 1. Unfortunately, its second derivative is 6 - 12t, which is not zero at either t = 0 or at t = 1. This causes artifacts to show up when Noise is used in bump mapping. Because the effect of lighting upon a bump-mapped surface varies with the derivative of the corresponding height function, second-derivative discontinuities are visible.
Perlin 2002에서 내가 논의한 것과 같이, 보간법을 개선하는 열쇠는 단지 2차 불연속을 제거하는 것이다. 원래의 3차 보간법 3t 2 - 2t 3이 선택된 것은 t = 0, t = 1일 때 모두 도함수가 0이 되기 때문이였다. 불행히도, 2차 도함수 6 - 12t 는 t = 0 이나 t = 1 일 때 0이 되지 않는다. 이것은 잡음이 범프 맵핑에 사용됐을 때 나타나는 결함을 야기한다. 범프 맵핑된 표면 위의 조명 효과는 상응하는 높이 함수의 도함수에 따라 변하기 때문에, 2차 도함수의 불연속성이 보이게 된다.
This problem was solved by switching to the fifth-degree interpolator: 6t 5 - 15t 4 + 10t 3, which has both first and second derivatives of zero at both t = 0 and t = 1.
이 문제는 1, 2차 도함수가 모두 t = 0, t = 1일 때 0이 되는 5차 보간자 6t 5 - 15t 4 + 10t 3 로 바꿔서 해결할 수 있었다.
The difference between these two interpolants can be seen in Figure 5-7. The green curve is the old cubic interpolant, which has second-order discontinuities at t = 0 and t = 1. The blue curve is the new fifth-order interpolant, which does not suffer from second-order discontinuities at t = 0 and t = 1.
두 보간법의 차이는 그림 5-7에서 볼 수 있다. 녹색 곡선은 t = 0, t = 1에서 2차 불연속을 가지는 이전의 3차 보간법이다. 파란 곡선은 t = 0, t = 1 에서 2차 불연속이 발생하지 않는 새로운 5차 보간법이다
One nice thing about graphics accelerators is that you perform one-dimensional interpolations via a one-dimensional texture lookup table. When you take this approach, there is no extra cost in doing the higher-order interpolation. In practice, I have found that a texture table length of 256 is plenty, and that 16 bits of precision is sufficient. Even half-precision floating point (fp16), with its 10-bit mantissa, is sufficient.
그래픽 가속기에 대해 한가지 멋진 것은 1차 텍스쳐 룩업 테이블을 통해 1차 보간을 수행하는 것이다. 이 접근법을 사용하면 더 고차의 보간을 수행하는데 추가의 비용이 들지 않는다. 실제로, 나는 텍스쳐 테이블의 길이가 256이면 충분하다는 것을 발견했다. 즉, 16비트의 정밀도이면 충분하다. 10비트의 가수를 가지는 반-정밀도 플로팅 포인트(fp16)조차도 충분하다.
Figure 5-8 shows two different renderings of a Noise-displaced superquadric. The one on the left uses the old cubic interpolant; the one on the right uses the newer, fifth-order interpolant. The visual improvement can be seen as a reduction in the 4x4-grid-like artifacts in the shape's front face.
그림 5-8은 잡음을 나타낸 superquadric의 2가지 다른 렌더링을 보여준다. 왼쪽에 있는 것은 기존의 3차 보간법을 사용한 것이고, 오른쪽에 있는 것은 새로운 5차 보간법을 사용한 것이다. 모델의 앞면에 4x4 격자 같은 결함이 줄어든 것으로 시각적 개선을 볼 수 있다.
The other improvement was to replace the 256 pseudo-random gradients with just 12 pseudo-random gradients, consisting of the edge centers of a cube centered at the origin: (0, ±1, ±1), (±1, 0, ±1), and (±1, ±1, 0). This results in a much less "splotchy-looking" distribution, as can be seen in Figure 5-9's side-by-side comparison of a planar slice taken from implementations of Noise using the old and the new approach.
다른 개선은 원점을 중심으로한 입장체의 모서리 중심으로 구성된 12개의 의사-랜덤 증감, (0, ±1, ±1), (±1, 0, ±1), (±1, ±1, 0) 을 256개의 의사-랜덤 증감으로 교체하는 것이었다. 그림 5-9에서 이전의 접근법과 새로운 접근법을 사용한 잡음 구현으로 얻은 절단면을 나란히 비교해놓은 것에서 볼 수 있는 것과 같이, 이것은 “얼룩이 있는 것처럼 보이는” 분포를 훨씬 적어지게 한다.
The reason for this improvement is that none of the 12 gradient directions is too near any others, so they will never bunch up too closely. It is this unwanted bunching up of adjacent gradients that causes the splotchy appearance in parts of the original Noise implementation.
이 개선을 적용하는 이유는 12개의 증감 방향 중 어떤 것도 다른 것들에 너무 가까이 있지 않아서 그것들이 너무 가까이 뭉쳐지지 않을 것이기 때문이다. 원래의 잡음 구현에 있는 얼룩진 모양을 야기시키는 이런 인접 증감의 뭉침은 불필요한 것이다.
Another nice thing about this approach is that it makes it possible to avoid many of the multiplies associated with evaluating the gradient function, because an inner product of (x, y, z) with, say, (1, 1, 0) can be computed simply as x + y.
이 접근법의 또 다른 멋진 점은 증감 함수를 계산하는 것과 관련된 많은 곱셈을 줄이는 것이 가능하다는 것이다. 즉, (x, y, z)와 (1, 1, 0)의 내적은 간단히 x + y 로 계산할 수 있다.
In order to make the process of hashing into this set of gradients compatible with the fastest possible hardware implementation, 16 gradients are actually defined, so that the hashing function can simply return a random 4-bit value. The extra four gradients simply repeat (1, 1, 0), (-1, 1, 0), (0, -1, 1), and (0, -1, -1).
해싱 처리를 가장 빠르게 가능한 하드웨어 구현에 호환되는 증감의 세트로 만들기 위해, 실제로 16개의 증감이 정의된다. 그로인해 해싱 함수는 간단히 임의의 4비트 값을 반환할 수 있다. 4개의 여분의 증감은 간단히 (1, 1, 0), (-1, 1, 0), (0, -1, 1), (0, -1, -1)를 반복된다.
5.5 How to Make Good Fake Noise in Pixel Shaders
It would be great to have some sort of reasonable volumetric noise primitive entirely in a pixel shader, but the straightforward implementation of this takes quite a few instructions. How can we use the capabilities of today's pixel shaders to implement some reasonable approximation of Noise in a very small number of instructions? Suppose we agree that we're willing to use piecewise trilinear rather than higher polynomial interpolation (because today's GPUs provide direct hardware acceleration of trilinear interpolation), and that we're willing to live with the small gradient discontinuities that result when you use trilinear interpolation.
픽셀 쉐이더에서 완전히 어떤 종류의 적당한 부피 측정의 잡음 원형을 가지는 것은 멋진 것이다. 하지만 이것의 직접적인 구현은 아주 많은 명령어를 사용한다. 매우 적은 수의 명령어로 잡음의 어떤 적당한 근사를 구현하기 위해 어떻게 오늘날의 픽셀 쉐이더의 능력을 사용할 수 있을까? 더 높은 다항 보간법 대신에 기꺼이 구분적으로 삼선형 보간법을 사용할 것(오늘날의 GPU는 삼선형 보간법의 직접적인 하드웨어 가속을 제공하기 때문이다.)이라는 것에 받아들인다고 가정하라. 그리고 삼선형 보간법을 사용할 때 발생하는 작은 증감 불연속성을 기꺼이 감수할 것이라는 것을 받아들인다고 가정하라.
One solution would be to place an entire volume of noise into a trilinear-interpolated texture. Unfortunately, this would be very space intensive. For example, a cube sampling noise from (0, 0, 0) through (72, 72, 72), containing three samples per linear unit distance plus one extra for the final endpoint, or (3 x 72) + 1 samples in each direction, would require 217 x 217 x 217 = 10,218,313 indexed locations, which is inconveniently large.
한가지 해결책은 삼선형-보간된 텍스쳐 안에 전체 잡음 볼륨을 넣는 것이다. 불행히도, 이것은 매우 공간 집약적이다. 예를 들면, (0, 0, 0) 에서 (72, 72, 72)까지의 입방체 샘플링 잡음은 한 차원의 단위 거리당 3개에 마지막 끝점을 더한 만큼의 샘플, 즉 각 방향당 (3 x 72) + 1 만큼의 샘플을 가지고 있어서 217 x 217 x 217 = 10,218,313 만큼의 너무 많은 색인된 위치를 요구한다.
But the fact that today's GPUs can perform fast trilinear interpolation on reasonably small-size volumes can be exploited in a different way. For example, an 8x8x8 volume sampled the same way requires (3 x 8) + 1 samples in each direction, or only 25x25x25 = 15,625 indexed locations. What I've been doing is to define noise through multiple references into such modest-size stored volumes.
그러나 오늘날의 GPU가 알맞게 작은 크기의 볼륨에 삼선형 보간법을 빠르게 수행할 수 있다는 사실은 다른 방식에서 활용될 수 있다. 예를 들면, 같은 방식으로 샘플링된 8x8x8크기의 볼륨은 각 방향당 (3 x 8) + 1, 즉 25x25x25 = 15,625 만큼의 색인된 위치만이 필요하다. 내가 한 것은 그런 적당한 크기로 저장된 볼륨을 다중으로 참조하여 잡음을 정의하는 것이다.
So how do you get a 723 cube out of an 83 cube? The trick is to do it in two steps:
그러면 83입방체에서 어떻게 723입방체를 얻을까? 다음 2단계로 할 수 있다.
- Fill the space with copies of an 83 sample that is a toroidal tiling. In other words, construct this sample so that it forms an endlessly repeating continuous pattern, with the top adjoining seamlessly to the bottom, the left to the right, and the back to the front. When these samples are stacked in space as cubic bricks, they will produce a continuous but repeating, space-filling texture.
- Use this same sampled pattern, scaled up by a factor of nine, as a low-frequency pattern that varies this fine-scale brick tiling in such a way that the fine-scale pattern no longer appears to be repeating.
- 도넛형태의 타일인 83 샘플의 복사본으로 공간을 채운다. 바꿔 말하면, 바닥면에 윗면을 오른쪽면에 왼쪽면을 앞면에 뒷면을 끊임없이 서로 접하게 하여 끝없이 반복되어 이어지는 패턴을 형성하도록 이 샘플을 구성한다. 이 샘플들이 입방체 블록으로 공간에 쌓일 때, 연속되지만 반복되지는 않는 공간-채움 텍스쳐가 생성될 것이다.
- 이렇게 동일하게 샘플링된 패턴을 9의 인수로 확대하여 사용한다. 이런 잘-스케일된 블록을 타일링하여 만든 저주파 패턴은 잘-스케일된 패턴 방식과 같이 더이상 반복되어 보이지 않는다.
The details are as follows: Rather than define the values in this repeating tile as real numbers, define them as complex values. Note that this doubles the storage cost of the table (in this case, to 31,250 indexed locations). If we use a 16-bit quantity for each numeric scalar in the table, then the total required memory cost is 31,250x2x2 bytes = 125,000 bytes to store the volume.
자세한 것은 다음과 같다: 이 반복되는 타일에서 실제 수로 값을 정의하는 대신에, 그것들을 합성된 값으로 정의하라. 이것은 테이블에 저장된 값을 2배로 한다는 것을 주의하라(이 경우에는, 31,250개의 색인된 위치가 된다). 만약 테이블에 있는 스칼라 수에 16비트의 용량을 사용하면, 전체 메모리 요구량은 31,250x2x2 byte = 125,000 byte 가 된다.
Evaluate both the low-frequency and the high-frequency noise texture. Then use the real component of the low-frequency texture as a rotational phase shift as follows: Let's say we have retrieved a complex value of (lor , loi ) from the low-frequency texture and a complex value of (hir , hii ) from the high-frequency texture. We use the low-frequency texture to rotate the complex value of the high-frequency texture by evaluating the expression:
저주파와 고주파 잡음 텍스쳐를 모두 계산하라. 그런 다음 저주파 텍스쳐의 실제 성분을 회전 상 전환(phase shift)으로써 다음과 같이 사용하라: 저주파 텍스쳐에서 (lor , loi )의 합성값, 고주파 텍스쳐에서 (hir , hii )의 합성값을 구한다고 하자. 다음 식의 값을 구해 저주파 텍스쳐를 사용하여 고주파 텍스쳐의 합성값을 회전시킨다.
The three images in Figure 5-10 show, in succession, (a) the real component of a planar slice through the high-frequency texture, (b) the real component of a planar slice through the low-frequency texture, and (c) the final noise texture obtained by combining them.
그릠 5-10에 있는 3개의 그림은 연속해서, (a)고주파 텍스쳐 절단면의 실제 성분, (b) 저주파 텍스쳐 절단면의 실제 성분, (c) 이것들을 결합한 최종 잡음 텍스쳐를 보여준다.
Notice that the visible tiling pattern on the leftmost image is no longer visible in the rightmost image.
가장 왼쪽의 이미지에서 보이는 타일 패턴이 가장 오른쪽의 이미지에서는 보이지 않는 것을 주목하라.
5.6 Making Bumps Without Looking at Neighboring Vertices
Once you can implement Noise directly in the pixel shader, then you can implement bump mapping as follows:
일단 픽셀 쉐이더에서 잡음을 바로 실행할 수 있으면, 범프 맵핑은 다음과 같이 실행할 수 있다.
- Consider a point (x, y, z) and some function F(x, y, z) that you've defined in your pixel shader through some combination of noise functions.
- Choose some small value of e and compute the following quantities:
- This allows a good approximation of the gradient (or derivative) vector of F at (x, y, z) by:
- Subtract this gradient from your surface normal and then renormalize the result back to unit length:
N = normalize(N - dF)
- 잡음 함수의 얼마의 조합을 통해 픽셀 쉐이더에서 정의한 함수 F(x, y, z)와 점 (x, y, z)을 고려한다.
- 어떤 작은 수 e를 선택해서 다음의 양을 계산한다:
- 이것은 다음의 식을 통해 (x, y, z)에서 F 의 증감 (혹은 도함수) 백터의 괜찮은 근사를 얻을 수 있다.
-
표면 법선에서 이 증감을 빼서 단위 길이로 다시 정규화한다.
N = normalize(N - dF)
Figure 5-11 shows the result of applying exactly this approach to three different procedural bump maps on a sphere: a simple lumpy pattern, an embossed marble pattern, and a fractal crinkled pattern.
그림 5-11은 구에서 3가지의 절차적 범프맵에 이 접근법을 정확히 적용한 결과이다. 왼쪽부터 간단한 울퉁불퉁한 패턴, 양각의 대리석 무늬 패턴, 프랙탈 주름 패턴을 보여준다.
Assuming that the model is a unit-radius sphere, the expressions that implement these bump patterns:
모델이 단위-반지름의 구라고 가정하면, 이 범프 패턴을 수행하는 수식은 다음과 같다.
.03 * noise(x, y, z, 8); //LUMPY .01 * stripes(x + 2 * turbulence(x, y, z, 1), 1.6); //MARBLED -.10 * turbulence(x, y, z, 1); //CRINKLED
are defined atop the following functions:
// STRIPES TEXTURE (GOOD FOR MAKING MARBLE) double stripes(double x, double f) { double t = .5 + .5 * sin(f * 2*PI * x); return t * t - .5; } // TURBULENCE TEXTURE double turbulence(double x, double y, double z, double f) { double t = -.5; for ( ; f <= W/12 ; f *= 2) // W = Image width in pixels t += abs(noise(x,y,z,f) / f); return t; }
5.7 Conclusion
Procedural texturing using volumetric noise is extremely useful in situations where you want to create an impression of natural-looking materials, without the necessity of creating an explicit texture image. Also, rather than trying to figure out how to map a texture image parametrically onto the surface of your shape, the volumetric nature of noise-based textures allows you simply to evaluate them at the (x, y, z) locations in your pixel shader. In this way, you are effectively carving your texture out of a solid material, which is often much more straightforward than trying to work out a reasonable undistorted parametric mapping.
볼륨 잡음을 사용한 절차적 텍스쳐링은 정해진 텍스쳐 이미지를 만들 필요없이 자연스럽게 보이는 물질의 느낌을 만들기를 원하는 상황에 매우 유용하다. 또한, 모형의 표면 위에 매개변수적으로 텍스쳐 이미지를 맵핑하는 방법을 계산하려고 시도하는 대신에, 잡음 기반 텍스쳐의 볼륨적 성질은 픽셀 쉐이더에서 (x, y, z)위치에서의 그것들을 간단히 게산할 수 있게 한다. 이 방식으로, 효율적으로 고체 물질을 잘라내어 텍스쳐를 만들고 있고, 이것은 일그러짐없이 제대로된 매개변수적 맵핑을 계산하려고 하는 것보다 종종 훨씬 더 직관적이다.
Noise-based textures also allow you to work in a resolution-independent way: rather than the texture blurring out when you get nearer to an object, it can be kept crisp and detailed, as you add higher frequencies of noise to your texture-defining procedure.
잡음 기반 텍스쳐는 또한 해상도 독립적인 방식으로 작업할 수 있게 한다: 물체에 가까이 갈수록 텍스쳐가 흐릿해지는 대신에, 텍스쳐 정의 절차에서 더 높은 주파수의 잡음을 추가하여 텍스쳐가 또렷하고 자세하게 유지될 수 있다.
As is always the case with procedural textures, you should try not to add very high frequencies that exceed the pixel sample rate. Such super-pixel frequencies do not add to the visual quality, and they result in unwanted speckling as the texture animates.
절차적 텍스쳐를 사용하는 모든 경우에 있어서, 픽셀 샘플 레이트를 넘어서는 매우 높은 주파수를 추가하려고 하지 않아야 한다. 그런 극도의 픽셀 주파수는 시각적 질을 높이지 않고, 텍스쳐가 움직이는 것 같은 원하지 않은 얼룩을 유발한다.
The key to being able to use noise-based textures efficiently on GPUs is the availability of an implementation of noise that really makes use of the enormous computational power of GPUs. Here we have outlined such an implementation, and shown several examples of how it can be used in your pixel shader to procedurally define bump maps.
잡음 기반의 텍스쳐를 GPU에서 효율적을 사용하게 할 수 있는 주 요점은 GPU의 막대한 계산적 능력을 사용하여 잡음을 구현하는 유용성이다. 여기서 우리는 그러한 구현의 윤곽을 알아보고, 절차적으로 범프맵을 정의하는 픽셀 쉐이더에서 그것을 어떻게 사용할 수 있는지에 대한 여러 예제들을 보여주었다.
These sorts of volumetric noise-based procedural textures have long been mainstays of feature films, where shaders do not require real-time performance, yet do require high fidelity to the visual appearance of natural materials. In fact, all special-effects films today make heavy use of noise-based procedural shaders. The convincing nature of such effects as the ocean waves in A Perfect Storm and the many surface textures and atmosphere effects in The Lord of the Rings trilogy, to take just two examples, is highly dependent on the extensive use of the noise function within pixel shaders written in languages such as Pixar's RenderMan. With a good implementation of the noise function available for real-time use in GPUs, I look forward to seeing some of the exciting visual ideas from feature films incorporated into the next generation of interactive entertainment on the desktop and the console.
이런 종류의 볼륨 잡음 기반 절차적 텍스쳐는 쉐이더가 실시간 성능을 요구하진 않지만 실제 물질의 시각적 외형에 매우 비슷해야 하는 영화의 핵심으로 오랫동안 사용되었다. 사실, 오늘날의 모든 특수효과 영화들은 잡음 기반 절차적 쉐이더를 많이 사용한다. A Perfect Storm 에서의 바다의 물결과 The Lord of the Rings3 3부작에서의 많은 표면 텍스쳐와 대기 효과 같은 뛰어난 자연 효과는 Pixar의 RenderMan같은 언어로 작성된 픽셀 쉐이더 내부에서 광범위한 잡음 함수의 사용에 크게 의존한다. GPU에서 실시간으로 사용 가능한 잡음 함수를 잘 구현하는 것으로 인해, 멋진 시각적 아이디어들이 영화의 영역에서 다음 세대의 데스크탑과 콘솔에 의한 양방향 엔터테인먼트로 확대될 것이다.
5.8 References
Perlin, K. 1985. "An Image Synthesizer." Computer Graphics 19(3).
Perlin, K. 2002. "Improving Noise." Computer Graphics 35(3).
Copyright
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and Addison-Wesley was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals.
The authors and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein.
The publisher offers discounts on this book when ordered in quantity for bulk purchases and special sales. For more information, please contact:
U.S. Corporate and Government Sales
(800) 382-3419
corpsales@pearsontechgroup.com
For sales outside of the U.S., please contact:
International Sales
international@pearsoned.com
Visit Addison-Wesley on the Web: www.awprofessional.com
Library of Congress Control Number: 2004100582
GeForce™ and NVIDIA Quadro® are trademarks or registered trademarks of NVIDIA Corporation.
RenderMan® is a registered trademark of Pixar Animation Studios.
"Shadow Map Antialiasing" © 2003 NVIDIA Corporation and Pixar Animation Studios.
"Cinematic Lighting" © 2003 Pixar Animation Studios.
Dawn images © 2002 NVIDIA Corporation. Vulcan images © 2003 NVIDIA Corporation.
Copyright © 2004 by NVIDIA Corporation.
All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form, or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior consent of the publisher. Printed in the United States of America. Published simultaneously in Canada.
For information on obtaining permission for use of material from this work, please submit a written request to:
Pearson Education, Inc.
Rights and Contracts Department
One Lake Street
Upper Saddle River, NJ 07458
Text printed on recycled and acid-free paper.
5 6 7 8 9 10 QWT 09 08 07
5th Printing September 2007
'GPU Gems 1' 카테고리의 다른 글
Chapter 7. Rendering Countless Blades of Waving Grass (0) | 2009.03.27 |
---|---|
Chapter 6. Fire in the "Vulcan" Demo (0) | 2009.03.21 |
Chapter 4. Animation in the "Dawn" Demo (0) | 2009.02.05 |
Chapter 3. Skin in the "Dawn" Demo (0) | 2009.01.12 |
Chapter 2. Rendering Water Caustics (0) | 2009.01.02 |