# 1 Texture. 2 Overview Introduction Painted textures Bump mapping Environment mapping Three-dimensional textures Functional textures Antialiasing textures

• View
223

2

Embed Size (px)

### Text of 1 Texture. 2 Overview Introduction Painted textures Bump mapping Environment mapping...

• Slide 1
• 1 Texture
• Slide 2
• 2 Overview Introduction Painted textures Bump mapping Environment mapping Three-dimensional textures Functional textures Antialiasing textures OpenGL details
• Slide 3
• 3 Introduction Few real objects are smooth Textures can handle large repetitions Brick wall Stripes Textures can handle small scale patterns A bricks roughness Concrete Wood grain Textures are typically two dimensional images of what is being simulated
• Slide 4
• 4 Painted Textures A mapping of locations on the object into locations in the texture The value from the texture replaces the diffuse component in the shading calculations If the texture is larger than the object, only part of the texture is used or the texture is shrunk If the object is larger than the texture, the texture is repeated across the object or the texture is stretched
• Slide 5
• 5 Painted Textures If the object location maps between texture locations, a value between them can be interpolated f 1 = fract(u) f 2 = fract(v) T 1 = (1.0 f 1 ) * texture[trunc(u)][trunc(v)] + f 1 * texture[trunc(u)+1][trunc(v)] T 2 = (1.0 f 1 ) * texture[trunc(u)][trunc(v)+1] + f 1 * texture[trunc(u)+1][trunc(v)+1] result = (1.0 f 2 ) * T 1 + f 2 * T 2
• Slide 6
• 6 Repeating Textures A texture can be repeated across an object with the equations:
• Slide 7
• 7 Repeating Textures A repeated texture must be continuous along its edges to prevent obvious seams
• Slide 8
• 8 Painted Texture Problem The texture values dont alter the specular highlights Specular highlighting may be inconsistent with the texture appearance
• Slide 9
• 9 Bump Mapping For a real bump, the surface normal changes when moving across the bump A similar appearance can be created if a similar change is made to the surface normal for a plane
• Slide 10
• 10 Bump Mapping In this case, the texture image is called a bump map The bump map is used to alter the surface normal The altered surface normal is used for the color calculations N B = bump(u, v, N) R B = 2 * N B * (N B V) V C r = k ar + I L * [k dr * L N B + k s * (R B V) n ] C g = k ag + I L * [k dg * L N B + k s * (R B V) n ] C b = k ab + I L * [k db * L N B + k s * (R B V) n ]
• Slide 11
• 11 Bump Mapping The bump function is based on the gradient of the bump map The gradient is a measure of how much the bump map values change at the chosen location The modified normal is calculated using the gradients in two directions (B u and B v ) and two vectors tangent to the surface in those directions (S u and S v ) The parenthesized expression can also be multiplied by a factor to control the appearance of the size of the bumps
• Slide 12
• 12 Bump Mapping Examples For the examples, the bump map is based on the product of the sine taken of the two coordinates: sin(10*u*/1024) *sin(10*v*/1024)
• Slide 13
• 13 Bump Mapping Examples A bump mapped plane using factors of 1.0, 0.5, and 2.0
• Slide 14
• 14 Bump Mapping Problem Because the surface shape is not changed, bumps near the silhouette will not change the silhouette shape If a bump mapped object is rotated, bumps will disappear when they reach the object profile
• Slide 15
• 15 Displacement Mapping In displacement mapping, the object is subdivided into many very small polygons The texture values cause the vertices to be displaced in the direction of the surface normal In this case, the texture actually changes the object shape
• Slide 16
• 16 Environment Mapping Environment mapping simulates reflective objects An environment map is a rendering of the scene from inside the reflective object The environment map is used to determine what would be seen in the reflection direction
• Slide 17
• 17 Environment Mapping The environment map can either be spherical or cube shaped Spherical environment maps require a calculation to convert the direction through the sphere into a two- dimensional matrix location
• Slide 18
• 18 Environment Mapping A cube shaped environment map renders the scene from the center of the object onto the faces of a cube The component of the reflection vector with the largest absolute value determines the face the reflection vector goes through
• Slide 19
• 19 Environment Mapping
• Slide 20
• 20 Environment Mapping The location on the correct face is calculated by: Where a is the component of the reflection vector shown on the horizontal axis, b is the component shown for the vertical axis, and c is the component for the chosen face
• Slide 21
• 21 Three-Dimensional Textures It is very difficult if not impossible to create a texture that can be wrapped around any irregularly shaped object without a visible discontinuity Where a two-dimensional texture is applied to the surface, an object can be thought to be carved out of a three-dimensional texture The storage requirements for a three- dimensional texture are extremely large Thus, three-dimensional textures are closely related to functional textures
• Slide 22
• 22 Functional Textures Instead of using a stored image as a texture, a functional texture uses a calculation based on the texture location Because the function will be continuous in every direction, the texture is continuous in every direction Instead of requiring space, these functional textures require computation time By changing how the texture is calculated, many different textures can be created
• Slide 23
• 23 Noise The beginning step to many functional textures is a noise function True white noise is highly random For graphics, pseudo random noise that is repeatable is important With truly random noise, the texture would change every time the image is rendered or for every scene of an animation
• Slide 24
• 24 Perlin Noise Perlin developed a noise function this is used in many Hollywood movies This noise function has: No statistical variance when rotated No statistical variance when translated A narrow range of values
• Slide 25
• 25 Turbulence Typically the second step in functional textures is to build a turbulence function on top of the noise function The functional textures are then built on top of the turbulence function The turbulence function takes multiple samples of the noise function at many different frequencies Different researchers will frequently develop their own turbulence function
• Slide 26
• 26 Peachys Turbulence Function float turb(float x, float y, float z, float minFreq, float maxFreq) { float result = 0.0; for (float freq = minFreq; freq < maxFreq; freq = 2.0*freq) { result += fabs( noise(x*freq, y*freq, z*freq ) / freq ); } return result; }
• Slide 27
• 27 Peachys Turbulence Results These samples have frequency ranges of [1.0, 4.0], [1.0, 16.0], and [1.0, 256.0]
• Slide 28
• 28 Perlins Turbulence Function float turb(float x, float y, float z, float minFreq, float maxFreq) { float result = 0.0; x = x + 123.456; for (float freq = minFreq; freq < maxFreq; freq = 2.0*freq) { result += fabs( noise(x, y, z ) ) / freq; x *= 2.0; y *= 2.0; z *= 2.0; } // return the result adjusted so the mean is 0.0 return result-0.3; }
• Slide 29
• 29 Perlins Turbulence Results These samples have frequency ranges of [1.0, 4.0], [1.0, 16.0], and [1.0, 256.0]
• Slide 30
• 30 Marble Texture The Perlin/Ebert marble function uses a turbulence value to determine a color for the location void marble(float x, float y, float z, float color[3]) { float value = x + 3.0 * turb(x, y, z, minFreq, maxFreq); marbleColor( sin( * value), color ); } There are variations in how the marbleColor function is implemented Linear interpolation between a light and dark color Spline based interpolation between a light and dark color
• Slide 31
• 31 Linear Interpolation Marble Examples These samples have frequency ranges of [1.0, 4.0], [1.0, 16.0], and [1.0, 256.0]
• Slide 32
• 32 Spline Interpolation Marble Examples These samples have frequency ranges of [1.0, 4.0], [1.0, 16.0], and [1.0, 256.0]
• Slide 33
• 33 Spline Interpolation Marble Examples These samples have a frequency range of [1.0, 256.0] and have no multiplier and multipliers of 3 and 7
• Slide 34
• 34 Cosine Textures Based on summations of cosine curves Parameters in the equation provide control on result The two dimensional equation is:
• Slide 35
• 35 Cosine Texture Parameters The value of N controls the number of cosine terms Typically between 4 and 7 The constants Gx Gy are global phase shifts that move the pattern The C i terms change the amplitude of the various cosine components The A 0 terms shift the pattern but are related to the C i terms The x1 and y1 determine the number of times the pattern repeats The x i and y i are phase values that are interdependent with the base periods of x and y
• Slide 36
• 36 Number of Cosines These examples show the results of using 1, 4, and 7 cosines
• Slide 37
• 37 Global Phase Shift These examples with x global phase shifts of 0 and 150 show tha

Recommended

Documents
Documents
Documents
Documents
Documents
Documents
Documents
Documents
Documents
Documents
Documents
Documents