1 / 26

RenderMan - Writing RenderMan Shaders - Checking the Homework

RenderMan - Writing RenderMan Shaders - Checking the Homework. Homework. 태극기 Shader flag.rib, flag.sl, flag.tif mailto:blue@cglab.cse.cau.ac.kr 다음주 수요일까지. Homework. Shader Parameters. . . . Declare "frame" "float" Declare "c1" "color" Declare "c2" "color" Declare "c3" "color"

frieda
Download Presentation

RenderMan - Writing RenderMan Shaders - Checking the Homework

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. RenderMan - Writing RenderMan Shaders - Checking the Homework

  2. Homework • 태극기 Shader • flag.rib, flag.sl, flag.tif • mailto:blue@cglab.cse.cau.ac.kr • 다음주 수요일까지

  3. Homework • Shader Parameters

  4. . . . Declare "frame" "float" Declare "c1" "color" Declare "c2" "color" Declare "c3" "color" Declare "th" "float" Declare "stripeNum" "float" Surface "rollingCyl" "frame" 0 "c1" [1.000000 0.000000 0.000000] "c2" [0.000000 0.000000 1.000000] "c3" [1.000000 1.000000 1.000000] "th" 5.000000 "stripeNum" 3 Patch "bilinear" "P" [-1 1 0 1 1 0 -1 -1 0 1 -1 0] . . . RIB file surface rollingCyl( float frame = 0; color c1 = color "rgb" (1, 0, 0); color c2 = color "rgb" (0, 0, 1); color c3 = color "rgb" (1, 1, 1); float th = 3.141592/4.; float stripeNum = 3; ) { . . . Shader source file

  5. RenderMan - Writing RenderMan Shaders (3)-

  6. Stochastic Patterns • Noise • Signed noise • Uniformly distributed noise • Turbulence • Pure stochastic patterns • Perturbed regular patterns • Bombing

  7. Noise • Irregular patterns have stochastic components • Stochastic functions appear random but actually aren't random at all. Rather, they are pseudo-random • Functions which appear to have random output but are actually repeatable given the same input • The basic tool for building stochastic functions is the noise function

  8. Noise • One-dimensional noise • Two-dimensional noise • (float output) Ci = float noise(s * 5, t * 5) • (color output) Ci = color noise(s * 5, t * 5) • Manipulation of noise function • noise(x * frequency + offset) * amplitude

  9. Noise • Signed Noise • The snoise function produces a 1D (input and output) noise function with output values in the range [-1,1] #define snoise(x) (noise(x) * 2 - 1) #define snoise2(x,y) (noise(x,y) * 2 - 1) • Uniformly Distributed Noise • The noise function has a tendency to generate output values which lie near the value 0.5. #define udn(x,lo,hi) (smoothstep(.25, .75, noise(x)) * ((hi) - (lo)) + (lo)) #define udn2(x,y,lo,hi) (smoothstep(.25, .75, noise(x,y)) * ((hi)-(lo))+(lo))

  10. Turbulence • A commonly used mechanism in stochastic patterns is turbulence • Turbulence is created by summing multiple noise functions with varying amplitude and frequency • Usually, we make the amplitude inversely proportional to the frequency which provides a fractal or 1/f power spectrum

  11. Turbulence for (f = 1; f < maxfreq; f *= 2) turb += abs(snoise(PP * f)) / f;

  12. Pure Stochastic Patterns • Patterns which appear to have no regularity or shape are deemed "pure" stochastic functions. • They include clouds, marble, fire, stone, granite, etc.

  13. surface rmarble(float veining = 0.5; float Ks = 0.4, Kd = 0.6, Ka = 0.1, roughness= 0.1; color specularcolor = 1) { color surface_color, layer_color; color layer_opac; point PP; point V, Nf ; float width, cutoff, fade, f, turb, maxfreq = 16; /* init */ surface_color = 0; Nf = faceforward(normalize(N), I); V = -normalize(I); /* compute turbulence */ PP = transform("shader", P) * veining; width = filterwidth_point(PP); cutoff = clamp(0.5 / width, 0, maxfreq); turb = 0; for (f = 1; f < 0.5 * cutoff; f *= 2) turb += abs(snoise(PP * f)) / f; fade = clamp(2 * (cutoff - f) / cutoff, 0, 1); turb += fade * abs(snoise(PP * f)) / f; turb *= 0.5; /* to match original rmarble turbulence value */ /* use turb to index into spline for layer color */ layer_color = spline(turb, color (0.8, 0.2, 0.05), color (0.8, 0.2, 0.05), color (0.8, 0.5, 0.3), color (0.6, 0.594, 0.58), color (0.3, 0.3, 0.4), color (0.05, 0.05, 0.1), color (0.8, 0.8, 0.79), color (0.8, 0.8, 0.79)); layer_opac = 1; surface_color = blend(surface_color, layer_color, layer_opac); /* plastic illum for all layers */ surface_color = surface_color * (Ka * ambient() + Kd * diffuse(Nf)) + specularcolor * Ks * specular(Nf, V, roughness); /* output */ Oi = Os; Ci = Os * surface_color; }

  14. #define MINFILTERWIDTH 1e-7 #define snoise(x) (noise(x) * 2 - 1) #define filterwidth_point(p) (max(sqrt(area(p)), MINFILTERWIDTH)) displacement dturb(float Km = 0.1, freq = 10, flatness = 1) { float magnitude, layer_mag; point PP; float width, cutoff, fade, f, turb, maxfreq = 16; /* compute turbulence */ PP = transform("shader", P) * freq; width = filterwidth_point(PP); cutoff = clamp(0.5 / width, 0, maxfreq); turb = 0; for (f = 1; f < 0.5 * cutoff; f *= 2) turb += abs(snoise(PP * f)) / f; fade = clamp(2 * (cutoff - f) / cutoff, 0, 1); turb += fade * abs(snoise(PP * f)) / f; /* raise to power to create flat areas */ magnitude = pow(turb, flatness); /* output */ P += Km * magnitude * normalize(N); N = calculatenormal(P); }

  15. Perturbed Regular Patterns • Randomized Rings noi = noise(s * noifreq, t * noifreq); ss = s + snoise(noi + 912) * noiscale; tt = t + snoise(noi + 333) * noiscale;

  16. Perturbed Regular Patterns • Wood Solid Texture • 1) to vary the shape of the rings by adding noise to P • 2) to vary the width of the rings by adding noise to the computed distance from the central axis.

  17. Bombing • Bombing generates random placement patterns • regular patterns or features which are "dropped" at random positions or orientations in texture space

  18. Bombing • Key idea:the shifting is based on the tile coordinates (column & row of the tile) and not the texture coordinates. • By using the tile coordinates as the seed (input) to noise, we get the same pseudo-random value (ouput) for every point inside that tile.

  19. Bombing • several attributes might be randomly chosen • location; • orientation (degrees rotated); • shape (e.g. the number of points on a star); • color; or • existence (e.g. only generate a tile 30% of the time).

  20. Homework • Analyze shaders • RenderMan Repository • http://www.renderman.org/

  21. http://www.renderman.org/RMR/Shaders/LGShaders/index.htm LGRustyMetal.sl (황용호) http://www.renderman.org/RMR/Shaders/TLShaders/index.html TLRing.sl (강재구) TLTerranNwhite.sl (강재구) TLSaturn.sl (황용호)

  22. http://www.renderman.org/RMR/Shaders/AKShaders/index.html AK_StainedTexture.sl (장석) http://www.renderman.org/RMR/Shaders/DPShaders/index.html DPBlueMarble.sl (장석) http://www.renderman.org/RMR/Shaders/DPShaders/index.html DPStar.sl (강준식)

  23. http://www.renderman.org/RMR/Shaders/DPShaders/index.html DPBrick.sl(김세진) http://www.renderman.org/RMR/Shaders/IDShaders/index.html IDhair.sl (김세진) http://www.renderman.org/RMR/Shaders/LGShaders/index.htm LGAntialiasedChecks.sl (우경훈) LGBrick.sl (우경훈)

  24. http://www.renderman.org/RMR/Shaders/TLShaders/index.html TLShiftedMoonTile.sl (강준식) TLShiftedD_RTile.sl (강준식) http://www.renderman.org/RMR/Shaders/BMRTShaders/index.html screen.sl, screen_aa.sl (지현경) http://www.renderman.org/RMR/Shaders/EMShaders/index.html EM_paper.sl (지현경)

More Related