7 May 18, 2012 1 / 60
71 ( ) CG 3 ( ) 2 / 60
72 71 ( ) 3 (rendering) 1 / (hidden line/surface calculation) a (outer normal algorithm) b Z (Z-buffer algorithm) c (scan-line algorithm) 2 (shading) a (flat shading) (constant shading) b (smooth shading) i (Gourand) ii (Phong) 3 / 60
72 (cnt) 3 (texture mapping) a (surface texture mapping) b (bump mapping) c (environmental mapping) i (reflection mapping) ii (refraction mapping) d (solid texture mapping) 4 (ray tracing) 5 (volume visualization) a (volume rendering) b (surface rendering) 4 / 60
73 / 72 ( / ) / 1: / 5 / 60
731 73 ( ) ν R 3 e R 3 ν e 0 ν e < 0 ν p 0, p 1, p 2 ( ) ν = (p 1 p 0 ) (p 2 p 0 ) (p 1 p 0 ) (p 2 p 0 ) 6 / 60
731 (cnt) º e p 1 e e p 2 p 0 º º 2: 7 / 60
Z 732 Z 74 (Z ) z z Z Z / Z 8 / 60
Z 732 Z (cnt) ( ) 1 f(x, y) Z b(x, y) 2 (x, y) f(x, y) b(x, y) 3 Z (x, y) z z(x, y) If z (x, y) < b (x, y), then b (x, y) := z (x, y) and f (x, y) := b(x, y) f(x, y) Z 1 2 9 / 60
733 75 ( ) x e º y 3: 10 / 60
733 (cnt) ( ) 1 y : / y / y y 2 a x : / x x ( ) b z : z z 1 2 3 Z 11 / 60
74 OpenGL OpenGL Z void glutinitdisplaymode(glut DEPTH) Z ( ) void glclear(gl COLOR BUFFER BIT GL DEPTH BUFFER BIT) glenable(gl DEPTH TEST) gldisable(gl DEPTH TEST) 12 / 60
74 OpenGL (cnt) 4: 13 / 60
74 OpenGL (cnt) program7 1c glutinitdisplaymode(glut_double GLUT_RGB GLUT_DEPTH); /* DEPTH ON */ #if 0 glenable(gl_depth_test); #endif glclear(gl_color_buffer_bit GL_DEPTH_BUFFER_BIT); glutsolidtorus(05, 09, 50, 50);/* */ glrectf(-20, -20, 20, 20);/* */ 14 / 60
75 76 ( ) (shading) 1 RGB a (diffuse reflection): Lambert (Lambertian reflectance) b (specular reflection): Phong (Phong reflection model) c (ambient reflection) d (transmitted light) 2 a (flat shading) b Gouraud (Gouraud shading) c Phong (Phong shading) 15 / 60
751 1 ν R 3 l R 3 k d [0, 1], l ν 0 RGB i in i d = k d i in l ν (Lambert ) l º 5: 16 / 60
751 (cnt) 2 ν, l R 3 r R 3 ν l R 3 e R 3 k s, 0 k s 1, n > 0 l ν 0 RGB i in i s (α) = k s i in (r e) n (Phong ) cos α = r e 0 k s cos θ = l ν 0 17 / 60
751 (cnt) l º r e 6: 18 / 60
751 (cnt) 3 k a, 0 k a 1, i amb i a = k a i amb i d, i s 10 % 20 % i a 4 d, 0 d 1, i 0 i t = di 0 19 / 60
752 1 Gouraud Phong 7: 20 / 60
752 (cnt) 2 Gouraud 3 E N a j N E j E j i E j ν i ν j i E ν = j i E j j º j º i3 º i4 º i2 º i1 8: 21 / 60
752 (cnt) b ν j i j, j N, c Ω i, i E, ( x (α)i ) R 3, α N i, i (α)i, ϕ (α)i : Ω i R ϕ (α)i x (β)i = δ αβ, α, β N i, x Ω i i h (x) = ϕ (α)i (x) i (α)i α N i ϕ (α)i 22 / 60
752 (cnt) i (1)i Á (1)i 1 x (1)i i (3)i i h Á 3)i x (3)i i i (2)i Á (2)i x (2)i 9: Gouraud 23 / 60
752 (cnt) 3 Phong a j N E j E j ν i i E j ν j = i E j ν i E j j b Ω i, i E, ( x (α)i ) R 3, α N i, ν (α)i, ϕ (α)i : Ω i R ϕ (α)i x (β)i = δ αβ, α, β N i, x Ω i ν h (x) = α N i ϕ (α)i (x) ν (α)i c ν h (x) i (x) 24 / 60
752 (cnt) º (3)i º (1)i Á (1)i 1 x (1)i º h Á 3)i x (3)i i Á (2)i x (2)i º (2)i 10: Phong 25 / 60
76 OpenGL gllightfv() void gllightfv(glenum light, GLenum pname, const GLfloat *params) light (GL LIGHT0 GL LIGHT7) pname GL AMBIENT : RGBA GL DIFFUSE : RGBA GL SPECULAR : RGBA GL POSITION : (x, y, z, w) GL SPOT DIRECTION : (x, y, z) GL EXPONENT : GL SPOT CUTOFF : ( ) GL CONSTANT ATTENUATION : k c GL LINEAR ATTENUATION : k l GL QUADRATIC ATTENUATION : 2 k q param 26 / 60
76 OpenGL (cnt) d 1 k c + k l d + k q d 2 gllightfv() void glmaterialfv(glenum face, GLenum pname, const GLfloat *params); face GL FRONT: GL BACK : GL FRONT AND BACK : 27 / 60
76 OpenGL (cnt) pname GL AMBIENT (RGBA) : GL DIFFUSE (RGBA ) : GL SPECULAR (RGBA ) : GL EMISSION (RGBA ) : GL SHININESS (0 128) : GL AMBIENT AND DIFFUSE (RGBA, RGBA): GL SPECULAR (1 1 1 1) GL SHININESS GL SPECULAR GL DIFFUSE GL AMBIENT 0 28 / 60
76 OpenGL (cnt) program7 2c void display(void) /* */ gllightfv(gl_light0, GL_AMBIENT, light0_ambient); /* */ gllightfv(gl_light0, GL_DIFFUSE, light0_diffuse); /* */ gllightfv(gl_light0, GL_SPECULAR, light0_specular); /* */ /* */ glmaterialfv(gl_front, GL_SPECULAR, material_specular); glmaterialfv(gl_front, GL_SHININESS, shininess); /* */ 29 / 60
76 OpenGL (cnt) 71 ( ) program7 2c 1 2 30 / 60
77 3 (texture) 1 2 3 4 31 / 60
77 (cnt) 1 2 3 a b c d 11: 32 / 60
77 (cnt) 2 (bump mapping) 12: 33 / 60
77 (cnt) 3 (environment mapping) a (reflection mapping) 1 b (refraction mapping) 1 13: 34 / 60
77 (cnt) 4 3 (solid texture) 14: 35 / 60
78 OpenGL glpixelstorei() void glpixelstorei(glenum pname, GLint param); pname GL UNPACK ALIGNMENT param 1, 2, 4, 8 1 RGBA 1 4 1 RGB 1 1 3 36 / 60
78 OpenGL (cnt) gltexparameteri() void gltexparameteri(glenum target, GLenum pname, GLint param); target GL TEXTURE 2D 1 pname GL TEXTURE MAG FILTER param GL NEAREST GL LINEAR 37 / 60
78 OpenGL (cnt) pname GL TEXTURE MIN FILTER param GL NEAREST GL LINEAR GL NEAREST MIPMAP NEAREST GL NEAREST MIPMAP LINEAR GL LINEAR MIPMAP NEAREST GL LINEAR MIPMAP LINEAR MIPMAP pname GL TEXTURE WRAP S GL TEXTURE WRAP T param s t GL REPEAT GL CLAMP( ) 38 / 60
78 OpenGL (cnt) glteximage2d() void glteximage2d(glenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); Target GL TEXTURE 2D Level MIPMAP MIPMAP 0 internalformat GL RGB, GL RGBA, GL ALPHA, GL LUMINANCE, GL LUMINANCE ALPHA, GL INTENSITY 38 39 / 60
78 OpenGL (cnt) width, height border 0 format pixels GL RGB, GL RGBA, GL COLOR INDEX, GL RED, GL GREEN, GL BLUE, GL ALPHA, GL LUMINANCE, GL LUMINANCE ALPHA type pixels GL UNSIGNED BYTE unsigned char, GL BYTE, GL SHORT, GL UNSIGNED SHORT, GL INT, GL UNSIGNED INT, GL FLOAT, GL BITMAP pixels 40 / 60
78 OpenGL (cnt) gltexenvi() void gltexenvi(glenum target, GLenum pname, GLint param); target GL TEXTURE ENV pname GL TEXTURE ENV MODE param GL MODULATE ( ) GL DECAL ( ) GL BLEND ( ) GL REPLACE ( ) 41 / 60
78 OpenGL (cnt) program7 3c int main(int argc, char **argv) /* */ make_image(); init_texture(); void display(void) glenable(gl_texture_2d); gltexenvi(gl_texture_env, GL_TEXTURE_ENV_MODE, GL_MODULATE); 42 / 60
78 OpenGL (cnt) 15: 43 / 60
79 (ray tracing) 16: 44 / 60
79 (cnt) 1 2 a ( ) b (1) (2) 45 / 60
79 (cnt) ( 1 x 0 R 3 L i ) ( di x 0, i ) si x 0 i L x 0 x 0 ( ( idi x 0 ) ( + i si x 0 )) i ( x 0) = i L ( + k r x 0 ) i r (x r ( ) + k t x 0 ) ( i t x t ) x r x t k r, k t 46 / 60
79 (cnt) 2 x r x t i r (x r ) = (i di (x r ) + i si (x r )) i L + k r (x r ) i r (x rr ) + k t (x r ( ) i t x rt ) ( ( idi x t ) ( + i si x t )) ( i t x t ) = i L ( + k r x t ) ( i r x tr ) ( + k t x t ) ( i t x tt ) x rr,, x tt 3 4 i ( x 0) 47 / 60
710 3 3 (X CT X ) ( ) 1 3 Ω R 3 Ω i, i E, Ω i (voxel) 2 X CT X v : Ω R 3 v i : E i v R V = { v i} (voxel i E data) (volume data) 48 / 60
710 (cnt) v i i v i (a) Ω i (b) 17: Ω i v i 49 / 60
710 (cnt) 77 ( ) (volume visualization) 1 (volume rendering) 2 (surface rendering) (a) (b) 18: 50 / 60
7101 78 ( ) ( ) 3 (volume rendering) 1 v R c = (r (v), g (v), b (v)) α (v) (c, α) : R R 4 ( 19) Intensity of light r g b Intensity of light attribute value v attribute value v (a) (b) 19: 51 / 60
7101 (cnt) 2 x j, j S, x j Ω i x (α) R 3, α {1,, 8} v (α) v j ( = v h x j ) = ϕ (α) ( x j) v (α) α {1,,8} ϕ (α) : Ω i R ϕ (α) ( x (β)) = δ αβ, α, β {1,, 8}, (x 1, x 2, x 3 3 1 ) ϕ (α) 52 / 60
7101 (cnt) x ixi+1 x i+2 s s 20: 53 / 60
7101 (cnt) 3 x j, j S, α j = α ( v j) m j=1 αj = 1 m c m x m i m := c m for i = m 1 to 0 do i i := α i c i + ( 1 α i) c i+1 i := i 0 3 i = (i R, i G, i B ) 54 / 60
7101 (cnt) ( ) x ijk = x i 1, x j 2, xk 3, i, j, k {1,, m}, v x ijk ( ) ( ) v ( v x i+1 x ijk) = 1 1, x j 2, xk 3 v x i 1 1, x j 2, xk 3 ( ) ( ) v x i 2 1, x j+1 2, x k 3 v x i 1, x j 1 2, x k 3 ( ) ( ) v x i 1, x j 2, xk+1 3 v x i 1, x j 2, xk 1 3 1 x ijk α ijk v ( x ijk) v ( x ijk) 2 v ( x ijk) 3 Phong 55 / 60
7101 (cnt) 21: 56 / 60
7102 79 ( ) (surface rendering) (marching cubes method) ( ) v 0 x (α) R 3, α {1,, 8} v (α) v (α) v 0 0 v (α) > v 0 1 x (α) 8 0, 1 2 8 = 256 22 (b) 15 57 / 60
7102 (cnt) 1 1 1 1 0 0 0 (a) 0 (b) 22: {0, 1} 58 / 60
711 CG 3 1 / / / / Z 2 3 4 5 3 59 / 60
[1] James D Foley, Steven K Feiner, Andries van Dam, John F Hughes, ( ), 2001 [2], CG, 2004 [3], OpenGL 3 CG, 2003 60 / 60