• 검색 결과가 없습니다.

RenderMan for Artist 03 – Let’s shade a sphere.: “Flat” to “Plastic

N/A
N/A
Protected

Academic year: 2021

Share "RenderMan for Artist 03 – Let’s shade a sphere.: “Flat” to “Plastic"

Copied!
45
0
0

로드 중.... (전체 텍스트 보기)

전체 글

(1)

RenderMan For Artists #03

Wanho Choi

(wanochoi.com)

(2)

RenderMan for Artists wanochoi.com

(3)

(Review) RIB Generation from Maya (Method#1)

(4)

RenderMan for Artists wanochoi.com

(Review) RIB Generation from Maya (Method#1)

Display "result.jpg" "file" "rgb" Projection "perspective" "fov" 30 WorldBegin

ReadArchive "./sphere.rib" WorldEnd

(5)

rman genrib  perspShape_Final.0001.rib

(6)

RenderMan for Artists wanochoi.com

Sine & Cosine Function

30

60

1

3

2 3 3 ) 30 tan( 2 1 ) 30 sin( 2 3 ) 30 cos(       3 ) 60 tan( 2 3 ) 60 sin( 2 1 ) 60 cos(      

45

45

1

1

2

1 ) 45 tan( 2 2 ) 45 sin( 2 2 ) 45 cos(         cos  sin    cos sin tan 

(7)
(8)

RenderMan for Artists wanochoi.com

Scalar vs Vector

Scalar

Only has magnitude

Ex. Mass: 1Kg, Temperature: 25 ºC, Speed: 100 km/h

Vector (2D, 3D, 4D, …)

Has magnitude & direction (=arrow, ≠point)

(9)

Addition

Subtraction

Multiplication with scalar

Resultant vector is

a

times as long.

Basic Operations of Vectors

-A

B

=

C

A

×

2

=

C

+

A

B

=

C

C

) , , ( ) , , ( ) , , (Ax Ay AzBx By BzAxBx AyBy AzBz   A B C ) , , ( ) , , ( ) , , (Ax Ay AzBx By BzAxBx AyBy AzBz   A B C

ABBA

ABBA

) 1 , 1 ( ) 1 , 0 ( ) 0 , 1 (     A B C ) 0 , 1 ( ) 1 , 0 ( (1,1) ) 1 , 1 ( ) 1 , 0 ( ) 0 , 1 (      A B C ) 0 , 1 ( ) 1 , 0 ( ) 1 , 1 (  ) 1 , 1 ( ) 1 , 1 ( 1 1 ) 5 . 0 , 5 . 0 ( ) 1 , 1 ( ) 5 . 0 ( ) 5 . 0 ( ) 2 , 2 ( ) 1 , 1 ( 2 2                  A D A D A C ) 0 , 1 ( ) 1 , 0 ( ) 1 , 1 ( ) 2 , 2 ( ) 1 , 1 (  ) 5 . 0 , 5 . 0 ( ) , , (AxAyAz    A C

(10)

RenderMan for Artists wanochoi.com

Example – Vector Subtraction

3,1,0

1,3,0

5,1,0

3,3,0

2,2,0

x y 0

2,2,0

2,2,0

(11)

Length & Normal of Vectors

2 2 2 2 / 1 2 2 2 ) (AxAyAzAxAyAzA                 2 2 2 2 2 2 2 2 2 , , / z y x z z y x y z y x x n A A A A A A A A A A A A A A A

Length (=magnitude)

Normal

※ normalize, normalization

2 1 1 ) 1 , 1 (  2 2   A ) 0 , 1 ( ) 1 , 0 ( (1,1) 2         2 1 , 2 1 / A A An ) 0 , 1 ( ) 1 , 0 ( (1,1)       2 1 , 2 1

(12)

RenderMan for Artists wanochoi.com

Dot Product (=Inner Product, 내적)

cos

B

A

B

A

)

(

2

1

2 2 2

C

B

A

)

(

2

1

2 2 2

B

A

B

A

 

2 2 2 2 2 2 2 2 2

)

(

)

(

)

(

)

(

)

(

2

1

z z y y x x z y x z y x

a

a

b

b

b

b

a

b

a

b

a

a

z z y y x x

b

a

b

a

b

a

B

A

C

B

A

B

A

2

2 2 2

(13)

Dot Product (=Inner Product, 내적)

Result: scalar

When A & B are unit vector, .

When A & B are orthogonal, .

When A & B are in same direction, .

When A & B are in opposite direction, .

“Dot Product” is useful for the shading, collision detection, etc.

cos

B

A

B

A

z z y y x x

b

a

b

a

b

a

cos

B

A

A

B

A

B

arccos

cos

1

0

B

A

0

90

cos

cos

0

B

A

0

B

A

(14)

RenderMan for Artists wanochoi.com

Shader

A small program to be used to determine the final surface properties.

(15)

shader

myShader.sl

myShader.slo

prman

test.rib

result.jpg

Display "result.jpg" "file" "rgb" Projection "perspective" "fov" 30 Translate 0 0 5

WorldBegin

LightSource "ambientlight" 1 "intensity" [0.1]

LightSource "pointlight" 2 "from" [-2 2 -2] "intensity" [7] Color [1 1 1] Surface "myShader" Sphere 1 -1 1 360 WorldEnd surface myShader() { Oi = Os; Ci = Oi * Cs; }

2-01_sphere_basic

test.rib myShader.sl

(16)

RenderMan for Artists wanochoi.com

(17)

.rib File Structure (Example #1)

Display “sphere.tiff” “file” “rgb” Projection “perspective”

WorldBegin Translate 0 0 2

Surface “myShader” “color surfaceColor” [1 0 0] Sphere 1 -1 1 360

WorldEnd

.rib

surface myShader(

color surfaceColor = color(1,1,1); color surfaceOpacity = color(1,1,1); ) { Oi = surfaceOpacity; Ci = Oi * surfaceColor; } .sl

Setup Part

Drawing Part

(18)

RenderMan for Artists wanochoi.com

Surface Shader – Basic Structure

O

is for opacity

Os

: opacity input provided by the RIB stream

Oi

: opacity output, which are then used by the renderer in the rest of its processing

C

is for color

Cs

: color input provided by the RIB stream

Ci

: opacity output, which are then used by the renderer in the rest of its processing

Globals

Predefined shader variables

Os, Oi, Cs, Ci, ….

myBasic.slo

Os

Cs

Oi

Ci

(19)
(20)

RenderMan for Artists wanochoi.com

(21)

Display "result.jpg" "file" "rgb" Projection "perspective" "fov" 30 Translate 0 0 5

WorldBegin

LightSource "ambientlight" 1 "intensity" [0.1]

LightSource "pointlight" 2 "from" [-2 2 -2] "intensity" [7] Color [1 1 1]

Surface "myShader" "color surfaceColor" [1 0 0]

Sphere 1 -1 1 360 WorldEnd

surface myShader( color surfaceColor = color(1,1,1);

color surfaceOpacity = color(1,1,1); ) { Oi = surfaceOpacity; Ci = Oi * surfaceColor; }

2-02_sphere_constant

.rib .sl

(22)

RenderMan for Artists wanochoi.com

(23)

Illumination

Global illumination

Considers the interaction of light

between all surfaces

in a scene

Local illumination

Considers the interaction of light between

one light source

and

one object surface

.

Usually, it is approximated as the summation of three components.

:

Ambient, Diffuse, Specular

Ambient reflection

Crude approximation to global effects of light

Accounts for the general brightness from light scattering in all directions from all surfaces.

Diffuse reflection

Due to the „roughness‟ of a surface at the microscopic level

Accounts for the light hitting a surface and then scattering evenly in all directions

Depends on “surface normal”

Specular reflection

Due to the „shininess‟ of a material

Accounts for the highlights

(24)

RenderMan for Artists wanochoi.com

Ideal diffuse reflection

An

ideal diffuse reflector

, at the microscopic level, is a very rough surface.

(real-world example: chalk)

Because of these microscopic variations, an incoming ray of light is equally likely to be

reflected in any direction over the hemisphere.

What does the reflected intensity depend on?

(Lambert‟s cosine law)

The energy reflected by a small portion of a surface from a light source in a given direction

is proportional to the cosine of the angle between that direction and the surface normal.

These are often called

Lambertian surfaces

Note that the reflected intensity is independent of the viewing direction, but does

depend on the surface orientation with regard to the light source.

I

diffuse

= k

d

I

light

cos

= k

d

I

light

(n • l)

(25)

Phong Shading Model

= Phong reflection model = Phong illumination model = Phong Ligting model

An empirical model of local illumination

K

a

: ambient reflection constant

K

d

: diffuse reflection constant

K

s

: specular reflection constant

α : shininess constant for this material (=1/roughness)

lights

i

s

s

d

d

a

a

p

k

I

k

I

N

L

k

I

R

V

I

(26)

RenderMan for Artists wanochoi.com

Specular Shiness

lights

i

s

s

d

d

a

a

p

k

I

k

I

N

L

k

I

R

V

I

(27)

Blinn-Phong Shading Model

(28)

RenderMan for Artists wanochoi.com

surface myShader( uniform float Ka = 1.00;

color surfaceColor = color(1,1,1); color surfaceOpacity = color(1,1,1); ) { Oi = surfaceOpacity; Ci = Oi * surfaceColor * ( Ka * ambient() ); }

2-03_sphere_ambient

.sl

(29)
(30)

RenderMan for Artists wanochoi.com

surface myShader( uniform float Kd = 1.00;

color surfaceColor = color(1,1,1); color surfaceOpacity = color(1,1,1); ) { normal Nn = normalize(N); color Cdiff = 0; illuminance( P, Nn, PI/2 ) { vector Ln = normalize(L); Cdiff += Cl * max( 0, Nn.Ln ); } Oi = surfaceOpacity; Ci = Oi * surfaceColor * ( Kd * Cdiff ); }

2-04_sphere_diffuse

.sl

(31)
(32)

RenderMan for Artists wanochoi.com

surface myShader( uniform float Kd = 1.00;

color surfaceColor = color(1,1,1); color surfaceOpacity = color(1,1,1); ) { normal Nn = normalize(N); Oi = surfaceOpacity; Ci = Oi * surfaceColor * ( Kd * diffuse(Nn) ); }

2-05_sphere_diffuse

.sl

(33)
(34)

RenderMan for Artists wanochoi.com

surface myShader( uniform float Ks = 1.00; uniform float roughness = 0.20;

color surfaceColor = color(1,1,1); color surfaceOpacity = color(1,1,1); color specularColor = color(1,1,1); ) { normal Nn = normalize(N); vector V = -normalize(I); color Cspec = 0; illuminance( P, Nn, PI/2 ) { vector Ln = normalize(L); vector H = normalize( Ln + V );

Cspec += Cl * pow( max( 0, Nn.H ), 1/roughness ); } Oi = surfaceOpacity; Ci = Oi * specularColor * ( Ks * Cspec ); }

2-06_sphere_specular

.sl

(35)
(36)

RenderMan for Artists wanochoi.com

surface myShader( uniform float Ks = 1.00; uniform float roughness = 0.20;

color surfaceColor = color(1,1,1); color surfaceOpacity = color(1,1,1); color specularColor = color(1,1,1); ) { normal Nn = normalize(N); vector V = -normalize(I); Oi = surfaceOpacity; Ci = Oi * specularColor * ( Ks * specular(Nn,V,roughness) ); }

2-07_sphere_specular

.sl

(37)
(38)

RenderMan for Artists wanochoi.com

surface myShader( uniform float Ka = 1.00; uniform float Kd = 0.85;

color surfaceColor = color(1,1,1); color surfaceOpacity = color(1,1,1); ) {

normal Nn = normalize(N); Oi = surfaceOpacity;

Ci = Oi * surfaceColor * ( Ka * ambient() + Kd * diffuse(Nn) ); }

2-08_sphere_lambert

(39)
(40)

RenderMan for Artists wanochoi.com

surface myShader( uniform float Ka = 1.00; uniform float Ks = 1.00; uniform float roughness = 0.20;

color surfaceColor = color(1,1,1); color surfaceOpacity = color(1,1,1); color specularColor = color(1,1,1); ) { normal Nn = normalize(N); vector V = -normalize(I); Oi = surfaceOpacity; Ci = Oi * ( surfaceColor * ( Ka * ambient() ) + specularColor * ( Ks * specular(Nn,V,roughness) ) ); }

2-09_sphere_metal

.sl

(41)
(42)

RenderMan for Artists wanochoi.com

surface myShader( uniform float Ka = 1.00; uniform float Kd = 1.00; uniform float Ks = 1.00; uniform float roughness = 0.20;

color surfaceColor = color(1,1,1); color surfaceOpacity = color(1,1,1); color specularColor = color(1,1,1); ) {

normal Nn = normalize(N); vector V = -normalize(I); Oi = surfaceOpacity;

Ci = Oi * ( surfaceColor * ( Ka * ambient() + Kd * diffuse(Nn) ) + specularColor * ( Ks * specular(Nn,V,roughness) ) ); }

2-10_sphere_plastic

(43)
(44)

RenderMan for Artists wanochoi.com

Surface Shader – Surface Normal (N vs Ng)

N

: surface shading normal

Ng

: Surface geometric normal

Surface shaders are evaluated after the displacement shaders.

This means that if the displacement shader altered the position of P and the direction

of N, then those values will be used by the surface shader.

(45)

References

Cook, Robert L., Loren Carpenter, Edwin Catmull, The Reyes Image Rendering Architecture, SIGGRAPH 87.

Saty Raghavachary, Rendering for Beginners: Image synthesis using RenderMan, Focal Press, 2004

Rudy Cortes, Saty Raghavachary, The RenderMan Shading Language Guide, Thomson Course Technology, 2007Ian Stephenson, Essential RenderMan Fast, Springer, 2003

Anthony A. Apodaca, Larry Gritz, Advanced RenderMan: Creating CGI for Motion Pictures, Morgan Kaufmann, 1999

http://en.wikipedia.org/wiki/Phong_shading

참조

관련 문서

The “Asset Allocation” portfolio assumes the following weights: 25% in the S&P 500, 10% in the Russell 2000, 15% in the MSCI EAFE, 5% in the MSCI EME, 25% in the

1 John Owen, Justification by Faith Alone, in The Works of John Owen, ed. John Bolt, trans. Scott Clark, "Do This and Live: Christ's Active Obedience as the

W Well, I like to discuss things with others, but I don’t think I’m fluent enough to take the class.. M Actually, the brochure says the class

Luminous flux: A monochromatic light source emitting an optical power of (1/683) Watt at 555 nm has a luminous intensity of 1 lm. :The photometric quantities are related

- draw normal to each faces from the center of the sphere - cut the surface of the sphere in the indicated points (pole) - great circles- circles whose radius is that of the

Hours later, the first artist finished

A source of light waves moving to the right with velocity 0.7c. The frequency is higher on the right, and lower

학생 본인이 농어촌 소재지 학교에서 중학교 입학 시부터 고등학교 졸업 시까지 교육과정을 이수하고 본인 및 부모가 농어촌 지역에 거주한 자. 학생 본인만