추천중입니다.
닫기 블로그로 보내기


설정된 블로그가 없습니다.

블로그 설정하기

슬라이드를 블로그에 보내는 중입니다.
ShaderX5 - 2.7_Animating_Vegetation_Using_GPU_Programs
0
03190
ohyecloudy 2008.11.20 00:12:25
마가린 바르기bookmarkr.netmetagsWzd.com네이버에 북마크하기다음에 북마크하기HanRSS에 북마크하기이올린에 북마크하기Pumfit에 글 올리기News2.0에 투고하기del.icio.us에 북마크하기
URL Copy_btn
EMBED Copy_btn
작성자가 등록한 다른 큐
댓글을 작성하기 위해서는 먼저 로그인 하셔야 합니다.
현재 댓글의 수는 0 개 입니다.
Page 0: Page 1: ShaderX5 2.7 Animating Vegetation Using GPU Programs ohyecloudy@gmail.com http://cafe.naver.com/shader.cafe Page 2: Introduction • 잔잔한 바람에 흔들리는 식물을 구현한다. • vertex animation을 사용. • static lightmap 유의 사항 : z-up right-hand 좌표계를 사용했다. Page 3: 적용 가능한 식물 • • • • • • • palms birches mushrooms grass weeds flowers scrub Page 4: 구현 단계 • Animate Vegetation – 일단 움직이게 한다. 개선 • Adding Chaos to Vertex Movement • Lightmap and Height Bias Page 5: Vertex Shader uniform float time; const float magnitude = 0.006; varying vec2 texCoords; // varying : 모든 vertex마다 정의하고 pixel shader에서는 보간된 값을 갖는다. void main() { float amplitude = magnitude * gl_Vertex.z; vec4 wave = amplitude * vec4( sin(time), cos(time), 0, 0); vec4 vert = gl_Vertex + wave; vert.w = 1.0; } gl_Position = gl_ModelViewProjectionMatrix * vert; texCoord = gl_MultiTexCoord0.xy; Page 6: 문제점 • mesh group이 하나일 때는 그럴듯하다. • 복수의 mesh group일 때는 문제 – wave 변수인 time이 똑같다. Page 7: 구현 단계 • Animate Vegetation • Adding Chaos to Vertex Movement – 단조로운 움직임을 없앤다. 개선 • Lightmap and Height Bias Page 8: Vertex Shader vec4 wave = amplitude * vec4( sin(time), cos(time), 0, 0); vec4 wave = amplitude * vec4( sin(time + gl_Vertex.x), cos(time + gl_Vertex.y), 0, 0); - Vertex 마다 다른 wave 값을 갖는다. - 움직임이 부드럽다. - 이웃한 vertex끼리 차이가 작다. Page 9: 문제점 • World 좌표로 계산한다. • amplitude 값이 높이에 비례한다. • Z 좌표가 0인 object에 비해 50인 object 의 움직임이 너무 과하다. Page 10: 구현 단계 • Animate Vegetation • Adding Chaos to Vertex Movement • Lightmap and Height Bias – 라이트 적용 – Height bais를 사용한 amplitude 보정. 개선 Page 11: Vertex Shader float amplitude = magnitude * (gl_Vertex.z); float amplitude = magnitude * (gl_Vertex.z – gl_Color.a); Lightmap R G Vertex color B A Bias Page 12: Fragment Shader(Pixel Shader) uniform sampler2D baseMap; varying vec4 vertColor; varying vec2 texCoords; void main() { vec4 mapColor = texture2D(baseMap, texCoords); vec3 fragColor = mapColor.rgb * vertColor.rgb; float trans = step(0.5, mapColor.a); gl_FragColor = vec4(fragColor.rgb, trans); } • transparency artifact 제거 – 텍스쳐 필터링, 밉맵핑이 원인. Page 13: