• Like
ゲームグラフィックス特論 第5回
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

ゲームグラフィックス特論 第5回

  • 1,919 views
Published

モーフィング,バーテックスブレンディング

モーフィング,バーテックスブレンディング

Published in Education , Technology , Art & Photos
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
1,919
On SlideShare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
86
Comments
0
Likes
6

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. 5 (3)
  • 2. 2
  • 3. 3
  • 4. 4(0, 0)(1, 1)st
  • 5. 5ccoossφφcosφyO x xzOO θccoossθθcosθssiinnθθsinθφssiinnφφsinφssiinnφφsinφ
  • 6. #version 150 core!in vec2 parameter; // CPU !uniform mat4 mc; // !!void main(void)!{!float th = 6.283185 * parameter.s; // [0,1]→[0,2π]!float ph = 3.141593 * parameter.t; // [0,1]→[0,π]!float r = sin(ph);!!vec4 p = vec4(r * cos(th), cos(ph), r * sin(th), 1.0);!!gl_Position = mc * p;!}6
  • 7. 7yO x xzOO θccoossθθcosθssiinnθθsinθh
  • 8. #version 150 core!in vec2 parameter; // CPU !uniform mat4 mc; // !!void main(void)!{!float th = 6.283185 * parameter.s; // [0,1]→[0,2π]!float y = parameter.t * 2.0 - 1.0; // [0,1]→[-1,1]!!vec4 p = vec3(cos(th), y, sin(th), 1.0);!!gl_Position = mc * p;!}!8
  • 9. 9
  • 10. • • • • • • • • • •  CPU•  (attribute)GPU10
  • 11. • • • 11P0P1t = t0t = t1P(t)t
  • 12. 12t0 t1tP0P1P(t)t ∈ t0,t1[ ]s t( )= t −t0( ) t1 −t0( )P t( )= 1− s t( )( )P0 + s t( )P1
  • 13. #version 150 core!in vec4 p0, p1; // !uniform float t; // !uniform mat4 mc; // !void main(void)!{!gl_Position = mc * mix(p0, p1, t);!}!!13
  • 14. //program = glCreateProgram();!… ( , , )// in (attribute) p1 -1GLint p1Loc = glGetAttribLocation(program, "p1");!!// p1GLuint p1Buf;!glGenBuffers(1, &p1Buf);!glBindBuffer(GL_ARRAY_BUFFER, p1Buf);!glBufferData(GL_ARRAY_BUFFER,!sizeof (GLfloat[3]) * vertices, p1, GL_STATIC_DRAW);!attribute14
  • 15. //glBindVertexArray(vao);!!// in (attribute) p1glBindBuffer(GL_ARRAY_BUFFER, p1Buf);!glVertexAttribPointer(p1Loc, 3, GL_FLOAT, GL_FALSE, 0, 0);!glEnableVertexAttribArray(p1Loc);!!//glDrawElements(GL_LINES, lines, GL_UNSIGNED_INT, 0);!15
  • 16. PiP1PkPNPDiDkD116Di = Pi − PNPN:Pi:Di:wi: iP = PN + wiDii=1k∑
  • 17. 17
  • 18. M1M2• 18
  • 19. • • • • 19
  • 20. M1M2• • • 20
  • 21. M1M2BlendM1 and M2• •  M1 M2• M1M221
  • 22. O1zxM1M0B1(t)B0(t)P u(t)22M0, M1 B0(t), B1(t)
  • 23. 23u t( )= wiBii=0n−1∑ t( )Mi−1P, wii=0n−1∑ =1, wi ≥ 0OzxB1(t) PM1B0(t) PM0P u(t)zxPM0OPM1u(t) = w0B0(t)M0 P + w1B1(t)M1 Pw0w1
  • 24. 24V1 = P1 − P0V2 = P − P0t =V1 ⋅V2V12d = V2 − V1td =V2V2 − V1tV2 − V1"#$%$t ≤ 0( )0 < t <1( )t ≥1( )wi = d +1( )−ccP0P1P0P1PPtt > 1dd
  • 25. #version 150 core!in vec4 position; // !uniform mat4 modelViewMatrix; // !uniform mat4 projectionMatrix; // !!//const int MAXBONES = 8;!uniform int numberOfBones; // !uniform vec4 p0[MAXBONES]; // !uniform vec4 p1[MAXBONES]; // !uniform mat4 blendMatrix[MAXBONES]; // Bi * inverse(Mi) CPU !const float exponent = -16.0; // !!void main()!{!vec4 p = modelViewMatrix * position, u = vec4(0.0);!for (int i = 0; i < numberOfBones; ++i) {!vec4 v1 = p1[i] – p0[i], v2 = p – p0[i];!float l = dot(v1, v1);!if (l > 0.0) v2 -= v1 * clamp(dot(v1, v2) / l, 0.0, 1.0);!u += pow(length(v2) + 1.0, exponent) * blendMatrix[i] * p; // !}!gl_Position = projectionMatrix * u;!}!25
  • 26. GLSL•  sin(x), cos(x)•  , x (radian) ,•  pow(x, y)•  , xy•  mix(v1, v2, t)•  v1 v2 t v1 * (1 - t) + v2 * t•  dot(v1, v2)•  v1, v2 , cross(v1, v2)•  length(v)•  v•  clamp(v, min, max)•  , v<min min, v>max max, v26
  • 27. •  P0, P1P d27V1 = P1 − P0V2 = P − P0t =V1 ⋅V2V12d = V2 − V1tV2V1PtdQP0P1
  • 28. • •  https://github.com/tokoik/ggsample05•  cylinder.hp0•  p1•  main.cpp p1 GPUsimple.vert•  main.cpp simple.vert•  tokoi@sys.wakayama-u.ac.jp28
  • 29. 29