Docsity

Advanced Image Synthesis: Radiosity and Oak Texture Shader - Prof. Pradeep Sen, Lab Reports of Computer Science

Toggle sidebar
bg1
1
ECE/CS 512 Advanced Image Synthesis
Pradeep Sen Class 8 โ€“ September 22, 2008
ECE/CS 512
Advanced Image Synthesis
Pradeep Sen
Advanced Graphics Lab
Class 8
September 22, 2008
ECE/CS 512 Advanced Image Synthesis
Pradeep Sen Class 8 โ€“ September 22, 2008
Today
๎šƒFinish up Renderman
๎šƒRadiosity
ECE/CS 512 Advanced Image Synthesis
Pradeep Sen Class 8 โ€“ September 22, 2008
Shader antialiasing
๎šƒAlthough antialiasing is done in the image
plane after shading is complete, this is only
to eliminate artifacts from pixel sampling
๎šƒIt does not remove aliasing from shading
samples
ECE/CS 512 Advanced Image Synthesis
Pradeep Sen Class 8 โ€“ September 22, 2008
Useful built-in functions
๎šƒDu(x) returns the derivative of arbitrary
expression x with respect to parameter u
๎šƒDv(x) returns the derivative of arbitrary
expression x with respect to parameter v
๎šƒdu is the change in surface parameter u
between adjacent samples
๎šƒdv is the change in surface parameter v
between adjacent samples
ECE/CS 512 Advanced Image Synthesis
Pradeep Sen Class 8 โ€“ September 22, 2008
Example filtered step
float filteredstep (float edge, float x, float w) {
return clamp ((x + w/2 โ€“ edge), 0, 1);
}
๎šƒBut how is the size w computed?
๎šƒUse the derivatives!
#define filterwidth(x)
max( abs(Du(x)*du) + abs(Dv(x)*dv), MINFILTWIDTH);
ECE/CS 512 Advanced Image Synthesis
Pradeep Sen Class 8 โ€“ September 22, 2008
Oak texture shader
float oaktexture (point Pshad; float dPshad;
float ringfreq, ringunevenness, grainfreq;
float ringnoise, ringnoisefreq;
float trunkwobble, trunkwobblefreq;
float angularwobble, angularwobblefreq;
float ringy, grainy;)
{
/* We shade based on Pshad, but we add several layers of
warping: */
/* Some general warping of the domain */
vector offset = vfBm(Pshad*ringnoisefreq,
dPshad*ringnoisefreq, 2, 4, 0.5);
point Pring = Pshad + ringnoise*offset;
/* The trunk isn't totally steady xy as you go up in z */
Pring += trunkwobble *
vsnoise(zcomp(Pshad)*trunkwobblefreq) *
vector(1,1,0);
source: Apodaca and Gritz
pf3
pf4

Partial preview of the text

Download Advanced Image Synthesis: Radiosity and Oak Texture Shader - Prof. Pradeep Sen and more Lab Reports Computer Science in PDF only on Docsity!

ECE/CS 512 Advanced Image Synthesis Pradeep Sen Class 8 โ€“ September 22, 2008

ECE/CS 512

Advanced Image Synthesis

Pradeep Sen Advanced Graphics Lab

Class 8 September 22, 2008

ECE/CS 512 Advanced Image Synthesis Pradeep Sen Class 8 โ€“ September 22, 2008

Today

ยƒ Finish up Renderman

ยƒ Radiosity

ECE/CS 512 Advanced Image Synthesis Pradeep Sen Class 8 โ€“ September 22, 2008

Shader antialiasing

ยƒ Although antialiasing is done in the image

plane after shading is complete, this is only

to eliminate artifacts from pixel sampling

ยƒ It does not remove aliasing from shading

samples

ECE/CS 512 Advanced Image Synthesis Pradeep Sen Class 8 โ€“ September 22, 2008

Useful built-in functions

ยƒ Du(x) returns the derivative of arbitrary

expression x with respect to parameter u

ยƒ Dv(x) returns the derivative of arbitrary

expression x with respect to parameter v

ยƒ du is the change in surface parameter u

between adjacent samples

ยƒ dv is the change in surface parameter v

between adjacent samples

ECE/CS 512 Advanced Image Synthesis Pradeep Sen Class 8 โ€“ September 22, 2008

Example filtered step

float filteredstep (float edge, float x, float w) {

return clamp ((x + w/2 โ€“ edge), 0, 1);

}

ยƒ But how is the size w computed?

ยƒ Use the derivatives!

#define filterwidth(x)

max( abs(Du(x)du) + abs(Dv(x)dv), MINFILTWIDTH);

ECE/CS 512 Advanced Image Synthesis Pradeep Sen Class 8 โ€“ September 22, 2008

Oak texture shader

float oaktexture (point Pshad; float dPshad; float ringfreq, ringunevenness, grainfreq; float ringnoise, ringnoisefreq; float trunkwobble, trunkwobblefreq; float angularwobble, angularwobblefreq; float ringy, grainy;) { /* We shade based on Pshad, but we add several layers of warping: / / Some general warping of the domain / vector offset = vfBm(Pshadringnoisefreq, dPshadringnoisefreq, 2, 4, 0.5); point Pring = Pshad + ringnoiseoffset;

/* The trunk isn't totally steady xy as you go up in z / Pring += trunkwobble * vsnoise(zcomp(Pshad)trunkwobblefreq) * vector(1,1,0);

source: Apodaca and Gritz

ECE/CS 512 Advanced Image Synthesis Pradeep Sen Class 8 โ€“ September 22, 2008

Oak texture shader (cont)

/* Calculate the radius from the center. */ float r2 = sqr(xcomp(Pring)) + sqr(ycomp(Pring)); float r = sqrt(r2) * ringfreq;

/* Add some noise around the trunk / r += angularwobble * smoothstep(0,5,r) * snoise (angularwobblefreq(Pring)*vector(1,1,0.1));

/* Now add some noise so all rings are not equal width / extern float du, dv; float dr = filterwidth(r); r += ringunevennessfilteredsnoise(r,dr);

float inring = smoothpulsetrain (.1, .55, .7, .95, 1, r);

point Pgrain = Pshadgrainfreqvector(1,1,.05); float dPgrain = filterwidthp(Pgrain); float grain = 0; float i, amp=1; source: Apodaca and Gritz (^) ECE/CS 512 Advanced Image Synthesis Pradeep Sen Class 8 โ€“ September 22, 2008

Oak texture shader (cont)

for (i = 0; i < 2; i += 1) { float grain1valid = 1-smoothstep(.2,.6,dPgrain); if (grain1valid > 0) { float g = grain1valid * snoise (Pgrain); g = (0.3 + 0.7inring); g = pow(clamp(0.8 - (g),0,1),2); g = grainy * smoothstep (0.5, 1, g); if (i == 0) inring = (1-0.4grain1valid);

grain = max (grain, g); }

Pgrain *= 2; dPgrain *= 2; amp = 0.5; } return mix (inringringy, 1, grain); } source: Apodaca and Gritz

ECE/CS 512 Advanced Image Synthesis Pradeep Sen Class 8 โ€“ September 22, 2008

Oak shader

surface oak ( float Ka = 1, Kd = 1, Ks = .25, roughness = 0.2;DEFAULT_PSHAD_PARAMS; float ringfreq = 8, ringunevenness = 0.5; float ringnoise = 0.02, ringnoisefreq = 1; float grainfreq = 25; float trunkwobble = 0.15, trunkwobblefreq = 0.025; float angularwobble = 1, angularwobblefreq = 1.5; float divotdepth = 0.05; color Clightwood = color (.5, .2, .067); /* light wood color */ color Cdarkwood = color(0.15, 0.077,0.028); float ringy = 1, grainy = 1; float truedisp = 0; ) { source: Apodaca and Gritz (^) ECE/CS 512 Advanced Image Synthesis Pradeep Sen Class 8 โ€“ September 22, 2008

Oak shader (cont)

GET_PSHAD;

normal Nf = faceforward(normalize(N),I);

float wood; wood = oaktexture (Pshad, dPshad, ringfreq, ringunevenness, grainfreq, ringnoise, ringnoisefreq, trunkwobble, trunkwobblefreq, angularwobble, angularwobblefreq, ringy, grainy); color Cwood = mix (Clightwood, Cdarkwood, wood);

Nf = faceforward(Displace (Nf, "shader", -wooddivotdepth, truedisp), I); / Illumination model - just use plastic / Ci = MaterialPlastic (Nf, Cwood, Ka, Kd, Ks(1-0.5*wood), roughness); Oi = Os; Ci *= Oi; } source: Apodaca and Gritz

ECE/CS 512 Advanced Image Synthesis Pradeep Sen Class 8 โ€“ September 22, 2008

source: Apodaca and Gritz (^) ECE/CS 512 Advanced Image Synthesis Pradeep Sen Class 8 โ€“ September 22, 2008

Renderman re-cap

ECE/CS 512 Advanced Image Synthesis Pradeep Sen Class 8 โ€“ September 22, 2008

SelfSelf--emittedemitted radiosityradiosity

reflectivityreflectivity totaltotal radiosityradiosity

Form factor source: Dutrรฉ et al. (^) ECE/CS 512 Advanced Image Synthesis Pradeep Sen Class 8 โ€“ September 22, 2008

The classic radiosity algorithm

ยƒ Discretize the input geometry into patches

ยƒ Compute form factors Fij for every pair i,j of

patches

ยƒ Solve the linear system of equations for the

radiosity

ยƒ Display the solution

ECE/CS 512 Advanced Image Synthesis Pradeep Sen Class 8 โ€“ September 22, 2008

Problems with classical radiosity

ยƒ Scene discretization

ยƒ Form factor computation

ECE/CS 512 Advanced Image Synthesis Pradeep Sen Class 8 โ€“ September 22, 2008

Discretization artifacts

flat Gouraud (^) source: Dutrรฉ et al.

ECE/CS 512 Advanced Image Synthesis Pradeep Sen Class 8 โ€“ September 22, 2008

Reading

ยƒ Radiosity paper by Goral et al.