Слайд 2Структура взаимодействия приложения с аппаратурой
API
application program interface
Программа
Driver
Graphics Hardware
HAL
hardware abstraction layer
Слайд 3Библиотеки
Open GL – open graphics library
(SGI, 90-е годы, версии 1.0-4.2)
GLUT - OpenGL
Utility Toolkit (http://www.opengl.org/resources/libraries/glut/)
GLEW - OpenGL Extension Wrangler Library (http://glew.sourceforge.net/)
GLM - OpenGL Mathematics (http://glm.g-truc.net/)
. . .
Microsoft Direct3D – часть MS DirectX
(1992 RenderMorphics, версии 2.0-11.0)
D3DX – retained mode toolkit
XNA - Xbox New Architecture
(http://msdn.microsoft.com/ru-ru/xna/)
Слайд 14Видовые преобразования & проецирование
Слайд 16Графический конвейер на GPU
зеленый – полностью программируемый этап
желтый – конфигурируемый и непрограммируемый
синий
– полностью фиксированный
Слайд 18Shaders
использование
инициализация
Слайд 19Shaders: vertex – закраска Гуро
// Gouraud
varying out vec4 c; uniform vec4 spec;
uniform
vec3 eyepos; uniform vec4 diff;
uniform vec4 amb; uniform float spower;
uniform float time;
void main( void )
{
vec3 p = vec3(gl_ModelViewMatrix * gl_Vertex); // transformed point to world space
vec3 campos = vec3(eyepos); // camera position
vec3 l = vec3(sin(time), 0, cos(time)); // vector to light position
vec3 v = campos - p; // vector to the camera
vec3 n = gl_NormalMatrix * gl_Normal; // transformed normal
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
const vec4 diffcolor = vec4(diff); // diffuse
const vec4 speccolor = vec4(spec); // specular
const vec4 ambcolor = vec4(amb); // ambient
const vec4 specpower = vec4(spower); // specular power
vec3 n2 = normalize(n);
vec3 l2 = normalize(l);
vec3 v2 = normalize(v);
vec3 r = reflect(-v2, n2);
vec4 diff = diffcolor * max(dot(n2, l2), 0.0);
vec4 spec = speccolor * pow(max(dot(l2, r), 0.0), specpower);
c = diff + spec + ambcolor;
}
Слайд 20Shaders: fragment (pixel) – закраска Гуро
// Gouraud
varying in vec4 c;
void main( void
)
{
gl_FragColor = c;
}
Слайд 21Shaders: vertex – закраска Фонга
// Phong
varying out vec3 l;
varying out vec3 v;
varying
out vec3 n;
uniform vec3 eyepos;
uniform float time;
void main( void )
{
vec3 p = vec3(gl_ModelViewMatrix * gl_Vertex); // transformed point to world space
vec3 campos = vec3(eyepos); // camera position
l = vec3(sin(time), 0, cos(time)); // vector to light position
v = campos - p; // vector to the camera
n = gl_NormalMatrix * gl_Normal; // transformed normal
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}
Слайд 22Shaders: fragment (pixel) – закраска Фонга
// Phong
varying in vec4 c;
varying in vec3
l;
varying in vec3 v;
varying in vec3 n;
uniform vec4 diff;
uniform vec4 spec;
uniform vec4 amb;
uniform float spower;
void main( void )
{
const vec4 diffcolor = vec4(diff); // diffuse
const vec4 speccolor = vec4(spec); // specular
const vec4 ambcolor = vec4(amb); // ambient
const vec4 specpower = vec4(spower); // specular power
vec3 n2 = normalize(n);
vec3 l2 = normalize(l);
vec3 v2 = normalize(v);
vec3 r = reflect(-v2, n2);
vec4 diff = diff * max(dot(n2, l2), 0.0);
vec4 spec = spec * pow(max(dot(l2, r), 0.0), spower);
gl_FragColor = amb + diff + spec;
}
Слайд 23Stencil buffer, blending & alpha test
Слайд 27Анимация
Синхронизация
clock_t start;
. . .
dt = (clock() - start) / (double)CLOCKS_PER_SEC;
LARGE_INTEGER Start, Quant;
QueryPerformanceFrequency(&Quant);
QueryPerformanceCounter(&Start);
.
. .
QueryPerformanceCounter(&Time);
dt = (Time.QuadPart - Start.QuadPart) /
(double)Quanty.QuadPart;
Слайд 30Инверсная и прямая кинематика
Cyclic Coordinate Descent (CCD)
Слайд 31Tomas Akenine-Moller, Eric Haines, Naty Hoffman, “Real-Time Rendering”, Third Edition, AK Peters-2008
Andrew
S. Glassner (ed.), Eric Haines, Pat Hanrahan, Robert L. Cook, James Arvo, David Kirk, Paul S. Heckbert, "An Introduction to Ray Tracing (The Morgan Kaufmann Series in Computer Graphics)", Academic Press-1989.
Matt Pharr, Greg Humphreys, "Physically Based Rendering, Second Edition: From Theory To Implementation", Morgan Kaufmann-2010
David S. Ebert, F. Kenton Musgrave, Darwyn Peachey, Ken Perlin, Steve Worley, "Texturing and Modeling, Third Edition: A Procedural Approach (The Morgan Kaufmann Series in Computer Graphics)”, Morgan Kaufmann-2002