Procedural Textures. Noise in glman  glman automatically creates 2D and 3D textures (with default sizes 64x64 and 64x64x64) named  Noise2  Noise3 

Slides:



Advertisements
Similar presentations
Fragment level programmability in OpenGL Evan Hart
Advertisements

16.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 16 – Some Special Rendering Effects.
RenderMan - Writing RenderMan Shaders (2)-. Transforming Tiles Transforming texture coordinates has an "inverse" effect on the appearance of the pattern.
Exploration of advanced lighting and shading techniques
POST-PROCESSING SET09115 Intro Graphics Programming.
13- 1 Chapter 13: Color Processing 。 Color: An important descriptor of the world 。 The world is itself colorless 。 Color is caused by the vision system.
Week 8 - Friday.  What did we talk about last time?  Radiometry  Photometry  Colorimetry  Lighting with shader code  Ambient  Directional (diffuse.
Texture Mapping. Texturing  process that modifies the appearance of each point on a surface using an image or function  any aspect of appearance can.
Week 7 - Monday.  What did we talk about last time?  Specular shading  Aliasing and antialiasing.
Copyright © 2010, 2007, 2004 Pearson Education, Inc. All Rights Reserved. Lecture Slides Elementary Statistics Eleventh Edition and the Triola.
Non-photorealistic Rendering.  a longtime goal of graphics research has been to render a scene that is indistinguishable from a photograph of the scene.
CHAPTER 10 Alpha Blending and Fog © 2008 Cengage Learning EMEA.
HUE Hue is color.. Hue Hue is the name of a distinct color of the spectrum—red, green, yellow, orange, blue, etc. It refers to the particular wavelength.
Diffuse Illumination Diffuse illumination is associated with specific light sources but is reflected uniformly in all directions. A white sheet of paper.
1Ellen L. Walker Edges Humans easily understand “line drawings” as pictures.
Informationsteknologi Monday, October 29, 2007Computer Graphics - Class 21 Today’s class Graphics programming Color.
Fur and hair are not typically uniform in color but instead are many slightly different shades. We wanted to simulate this using a single texture map.
Introduction to Computers and Programming Lecture 4: Mathematical Operators New York University.
CS 4731: Computer Graphics Lecture 6: Points, Scalars and Vectors Emmanuel Agu.
Skin Rendering GPU Graphics Gary J. Katz University of Pennsylvania CIS 665 Adapted from David Gosselin’s Power Point and article, Real-time skin rendering,
Twelve painting with procedures. Overview Making shaded images with procedures Making a more elegant language Making textures with noise functions.
Texture mapping. Adds realism to computer graphics Texture mapping applies a pattern of color Bump mapping alters the surface Mapping is cheaper than.
Eighteen painting with procedures. Review [bitmap-from-procedure procedure width height] Returns a bitmap width pixels by height pixels Obtains colors.
Chapter 3 (cont).  In this section several basic concepts are introduced underlying the use of spatial filters for image processing.  Mainly spatial.
Image Processing.  a typical image is simply a 2D array of color or gray values  i.e., a texture  image processing takes as input an image and outputs.
1 Texture. 2 Overview Introduction Painted textures Bump mapping Environment mapping Three-dimensional textures Functional textures Antialiasing textures.
Interactive Terrain Synthesis
Procedural Textures.
Queensland University of Technology CRICOS No J INB382/INN382 Real-Time Rendering Techniques Lecture 13: Revision Ross Brown.
Geometry Shaders. Visualizing Normal Vectors  textbook calls this a “hedgehog plot” but (I think) that this is a misuse of the term  a hedgehog plot.
Locating Points on a Circle Sine Cosine Tangent. Coordinates Systems Review There are 3 types of coordinate systems which we will use: Absolute Incremental.
Noise and Procedural Techniques John Spitzer Simon Green NVIDIA Corporation.
Lecture 12 Modules Employing Gradient Descent Computing Optical Flow Shape from Shading.
A Non-Photorealistic Fragment Shader in OpenGL 2.0 Bert Freudenberg Institut für Simulation und Graphik University of Magdeburg, Germany.
Ch 9 Infinity page 1CSC 367 Fractals (9.2) Self similar curves appear identical at every level of detail often created by recursively drawing lines.
Shading CMSC 435/634. RenderMan Light Displacement Surface Volume Imager.
Shading CMSC 435/634.
Lecture by: Martin Deschamps CSE 4431
Slide 9- 1 Copyright © 2006 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
© 2010 Delmar, Cengage Learning Chapter 2 Working with Text and Gradients.
CSE 381 – Advanced Game Programming GLSL Lighting.
More on Environment Mapping Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Wednesday, December 10, 2003.
03/28/03© 2005 University of Wisconsin NPR Today “Comprehensible Rendering of 3-D Shapes”, Takafumi Saito and Tokiichiro Takahashi, SIGGRAPH 1990 “Painterly.
Realtime NPR Toon and Pencil Shading Joel Jorgensen May 4, 2010.
Computer Graphics Blending CO2409 Computer Graphics Week 14.
Shading in OpenGL Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E.
Introduction to Computer Graphics
Global Illumination. Local Illumination  the GPU pipeline is designed for local illumination  only the surface data at the visible point is needed to.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
02/05/2002 (C) University of Wisconsin 2002, CS 559 Last Time Color Quantization Mach Banding –Humans exaggerate sharp boundaries, but not fuzzy ones.
Ch 4 Fluids in Motion.
Cel shading By jared brock.
Day 06 Vertex Shader for Ambient-Diffuse-Specular Lighting.
Machine Vision Edge Detection Techniques ENT 273 Lecture 6 Hema C.R.
Lighting and Reflection Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
An Image Synthesizer- Perlin Noise. Outline Noise Introduction Noise Algorithm Noise Texture Example.
1 CSCE 441: Computer Graphics Lighting Jinxiang Chai.
Processing Images and Video for An Impressionist Effect Automatic production of “painterly” animations from video clips. Extending existing algorithms.
Computer Graphics: Achromatic and Coloured Light.
CSE 681 Texture Mapping: Solid Texturing. CSE 681 Texture Mapping Visual complexity on demand Vary display properties over object Location on object used.
Ying Zhu Georgia State University
Computer Graphics Imaging
1-Introduction (Computing the image histogram).
Shading CMSC 435/634.
Day 05 Shader Basics.
Chapter IX Bump Mapping
Additive and Subtractive Color
Computer Animation Texture Mapping.
Chapter XIV Normal Mapping
Presentation transcript:

Procedural Textures

Noise in glman  glman automatically creates 2D and 3D textures (with default sizes 64x64 and 64x64x64) named  Noise2  Noise3  stores 4 octaves, 1 each in the R, G, B, A components

Noise in glman ComponentTermRangeLimits 0nv.r 0.5 ± –1.0 1nv.g 0.5 ± –0.75 2nv.b 0.5 ± – nv.a 0.5 ± – sum 2.0 ± –3.0 sum – ± –2.0 (sum – 1) / ± –1.0 (sum – 2) 0.5 ± –1.0 Table 10.1

Clouds 1  vertex shader outputs  modelling coordinates of each vertex (scaled so that the values are suitable for use as texture coordinates)  light intensity (from ADS lighting or other)  fragment shader  retrieves a 3D noise texture value using the incoming modelling coordinate  computes a noise value from the retrieved texture value  blends a sky color with a cloud color using the noise value and modulates the incoming light intensity

Clouds 1 uniform sampler3D Noise3; uniform vec4 uSkyColor; uniform vec4 uCloudColor; in vec4 vColor; in vec3 vModelPosition; out vec4 fFragColor; void main(void) { vec4 nv = texture(Noise3, vModelPosition); float cloudIntensity = (nv.r + nv.g + nv.b + nv.a - 1) / 2.0; vec3 color = mix(uSkyColor.rgb, uCloudColor.rgb, cloudIntensity) * vColor.rgb; fFragColor.rgb = color; fFragColor.a = 1.; }

Clouds 1

Clouds 2a  you can choose to emphasize the large scale structure by increasing the contribution of the first octave float cloudIntensity = (3 * nv.r + nv.g + nv.b + nv.a - 2) / 2.0;

Clouds 2a

Clouds 2b  you can emphasize the effect by modifying the cloud intensity with a cosine function float cloudIntensity = (3 * nv.r + nv.g + nv.b + nv.a - 2) / 2.0; cloudIntensity = (1. + cos( * cloudIntensity)) / 2.;

Clouds 2b

Turbulence  the term “turbulence” is used when discussing noise textures to mean absolute value noise  suppose you have noise functions f and g that both have range [-1, 1] ; then the noise function h = abs(f) + abs(g) is called a turbulence noise function  the absolute value function causes discontinuities in the gradient of the noise which produces a visual effect similar to turbulent flow

Turbulence  for glman noise, you subtract the middle of the range (0.5) from each of the components and take their absolute values float turbulence(in vec4 nv) { return abs(nv.r - 0.5) + abs(nv.g - 0.5) + abs(nv.b - 0.5) + abs(nv.a - 0.5); }

Clouds 3  using turbulence instead of normal fbm noise

Clouds 4  vorticity can be emulated by rotating the texture coordinates by an amount that varies with the distance from the center of the vortex

Clouds 4 void main(void) { const float TWIST = 3.5; const float MAX_RADIUS = 0.5; float radius = length(vModelPosition.xy); vec3 stp; if (radius < MAX_RADIUS) { float dist = pow(MAX_RADIUS - radius, 3); float angle = PI + TWIST * 2 * PI * (MAX_RADIUS - dist) / MAX_RADIUS; float c = cos(angle); float s = sin(angle); stp = vec3(dot(vec2(c, -s), vModelPosition.xy), dot(vec2(s, c), vModelPosition.xy), vModelPosition.z); }

Clouds 4 else { stp = vModelPosition; } vec4 nv = texture(Noise3, stp); float cloudIntensity = turbulence(vec4(nv.r*2,nv.gba)); vec3 color = mix(uSkyColor.rgb, uCloudColor.rgb, cloudIntensity) * vColor.rgb * 1.5; fFragColor.rgb = color; fFragColor.a = 1.; }

Clouds  techniques described here produce the illusion of clouds  there is a large body of literature describing the modeling of real clouds  see Chapter 9 of “Texturing and Modeling: A Procedural Approach, 3 rd Edition”  a volume rendering approach a volume rendering approach

Marble  marble (sort of) has the appearance of alternating color veins  a marble effect can be achieved by using noise to modify a periodic function such as sin  the choice of function to modify can be used to change the relative thickness of the bands

Marble uniform sampler3D Noise3; uniform vec4 uMarbleColor; uniform vec4 uVeinColor; uniform float uNoiseScale; uniform float uNoiseMag; in vec4 vColor; in vec3 vModelPosition; out vec4 fFragColor;

Marble void main(void) { vec4 nv = texture(Noise3, vModelPosition * uNoiseScale); float noise = clamp(turbulence(nv) * uNoiseMag, 0.0, 1.0); float sineval = sin(vModelPosition.y * noise * 12.0); vec3 color = mix(uVeinColor.rgb, uMarbleColor.rgb, sineval) * vColor.rgb; fFragColor = vec4(color, 1.0); }

Marble sinabs(sin)

Marble

Granite  high frequency black and white patches with low frequency pink patches

Granite  to model the high frequency black and white patches we can use one or more of the high frequency noise components (shifted and scaled appropriately) void main(void) { vec4 nv = texture(Noise3, vModelPosition * uNoiseScale); float intensity = clamp((nv.a ) * 32.0, 0., 1.); vec3 bw = vec3(intensity * vColor.rgb); fFragColor = bw; }

Granite

 to model the low frequency patches of rose we add in the lower frequency components to generate a noise value and multiply it by a rose color intensity = (nv.r + nv.g + nv.b + nv.a - 1.) / 2.; vec3 rose = intensity * vec3(0.95, 0.6, 0.8); fFragColor = rose;

Granite

 this is not quite what we want  we want a small number of large islands of rose  only the “strongest” patches of rose color should remain with the rest of the texture becoming darker  two other primitive functions we can implement and use  bias  gain

Bias  0 and 1 are mapped to themselves  all other values shifted  down if bias < 0.5  up if bias > 0.5 bias(0.8, x) bias(0.2, x)

Bias float bias(in float b, in float x) { return pow(x, log(b)/log(0.5)); }

Gain  0, 0.5, and 1 mapped to themselves  above and below 0.5 the function consists of scaled down bias curves forming an S gain(0.8, x) gain(0.2, x)

Gain float gain(in float g, in float x) { if (x < 0.5) { return bias(1 - g, 2 * x) / 2; } else { return bias(1 - g, * x) / 2; }

Granite  we want to bias the results strongly towards zero intensity = (nv.r + nv.g + nv.b + nv.a - 1.) / 2.; intensity = clamp(bias(0.005, intensity * 1.5), 0., 1.); vec3 rose = intensity * vec3(0.95, 0.6, 0.8); fFragColor = rose;

Granite

 mixing the two results vec3 color = mix(bw, rose, 0.8); fFragColor = vec4(color, 1.);