交互式计算机图形学(第五版)1-7章课后题答案
计算机图形学基础答案全
计算机图形学考试重点计算题
What is the difference between Gouraud and Phong shading?
- Gouraud shading (AKA Smooth Shading) is a per-vertex color computation. What this means is that the vertex shader must determine a color for each vertex and pass the color as an out variable to the fragment shader. Since this color is passed to the fragment shader as an in varying variable, it is interpolated across the fragments thus giving the smooth shading.
- In contrast, Phong shading is a per-fragment color computation. The vertex shader provides the normal and position data as out variables to the fragment shader. The fragment shader then interpolates these variables and computes the color.
BSP tree
BSP Tree
图形学复习
1 图形系统和模型
- 图形系统示意图:CPU、GPU、frame缓存、显示器
- 输入设备 —> 中央处理单元—>图形处理单元—> 帧缓存—> 输出单元
| | {存储屏幕显示像素的颜色值,深度信息}
CPU存储器 GPU存储器
- 输入设备 —> 中央处理单元—>图形处理单元—> 帧缓存—> 输出单元
- 处理器{获取由应用程序生成图元的属性,并为帧缓存像素赋值。即光栅化/扫描转换:几何实体-帧缓存中像素颜色和位置}
GPU{图形处理+并行性}
显示器{阴极射线管;逐行扫描,隔行扫描(60Hz每秒30次)} - 虚拟照相机模型:什么叫COP、Projector、计算依据及实现理论
- Sample 2、2) A CG synthesized camera is normally located in space by the position of its viewpoint, its aim direction, and an up vector. If we let pc be the viewpoint, uc be the aim direction, and vup be the up vector, give the mathematics showing how to construct the view coordinate frame ux, uy, uz of the camera. (10 points)
- [4.3.3] pc viewpoint, vc aim direction
VPN=vc−pc
n=VPN/|VPN|
u=vup∗n/|vup∗n| //叉积、归一化生成与 n 、vup 均垂直的向量
v=n∗u/|n∗u| // vup 在照相机观察平面的投影
- [4.3.3] pc viewpoint, vc aim direction
- Sample 2、2) A CG synthesized camera is normally located in space by the position of its viewpoint, its aim direction, and an up vector. If we let pc be the viewpoint, uc be the aim direction, and vup be the up vector, give the mathematics showing how to construct the view coordinate frame ux, uy, uz of the camera. (10 points)
- COP投影中心、Projector投影线
- !虚拟照相机模型(synthetic-camera-model)中,虚拟成像平面与对象同侧
- Pipeline
- 顶点-顶点处理模块{执行坐标变换和计算每个顶点的颜色值}-裁剪模块和图元组装模块{顶点组装成像线段、多边形等图元,通过裁剪体对其裁剪}-光栅化模块{对每个图元生成一组片元,看作携带相关信息的潜在像素}-片元处理模块{更新帧缓存中像素}-像素
2 图形学编程
- 画图关键词 …_Line_Stripe/…
- GL_POINTS, GL_LINES, GL_LINE_STRIP, GL_LINE_LOOP
- GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN
- 交互、event、idel…:补充程序
void main(){
glutInit(int argc, char *argv);
glutInitDisplayMode(GLUT_RGBA | GLUT_DPUBLE | GLUT_DEPTH);//双缓存,display中glFlush改glutSwapBuffers
...
glutIdleFunc(glutPostRedisplay);//空闲回调函数
//glutDisplayFunc(display);//回调函数并将其注册到窗口系统
glutMouseFunc(myMouse);
glutKeyboardFunc(mykey);//glutSpecialFunc(ListenKey);
glutMainLoop();//事件处理循环
}
vod myMouse(int button, int states, int x, int y){
if (button == GLUT_LEFT_BUTTON && states == GLUT_DOWN){
exit(0);
}
...
}
void myKey(unsigned char key, int x, int y){
if (key=='q' || key = 'Q'){
exit(0);
}
...
}
3 几何对象和变换 ⚠
- 空间
- 向量空间(标量、向量)
- Euclid空间:向量空间+对大小或者距离的度量
- 仿射空间:向量空间+点;性质:凸性的表示
- 标架变换: b=(MT)−1a
- 向量的仿射变换仅9个自由度,点具有全部12个自由度
- 四元数:概念,如何表示旋转
- 包含向量(方向)和标量(旋转角度): (q0,q)
- ab=(p0q0−q`p,q0p+p0q,qXp)
- r=(cos(θ/2),sin(θ/2)v)
p′=rpr−1 :p绕向量v旋转角度 θ 后的位置
各类矩阵及合成:平移缩放旋转剪切
- 平移、旋转:刚体变化,只改变对象的位置和方向
- 缩放:放射变换,改变大小,6个自由度:一个不动点+三个独立的缩放因子
100001000010αxαyαz1(平移)
cosθ0−sinθ00100