摘要: 看了康玉之大牛的《GPU 编程与CG 语言之阳春白雪下里巴人》,和放风筝的程序员的博客,自己也来写写光照模型1. Lambert光照模型,也就是漫反射光照模型。它考虑的是ambient光和diffuse光对物体的综合影响着色器程序struct VertexIn { float4 position : POSITION; float4 normal : NORMAL; }; struct VertexScreen { float4 oPosition : POSITION; float4 color : COLOR; }; void main_v(V... 阅读全文
posted @ 2011-10-17 21:19 wangwh0910 阅读(577) 评论(0) 推荐(0) 编辑
摘要: cg内置的变量glstate.matrix.modelview[n]: modelview matrix nglstate.matrix.invtrans.modelview[0]:ModelViewIT 模型视图矩阵转置的逆矩阵,用于把顶点法向量变换到世界空间glstate.matrix.mvp:modelview-projection matrixglstate.matrix.projection :projection matrixglstate.matrix.texture[n] :texture matrix nglstate.matrix.palette[n]:palette ma 阅读全文
posted @ 2011-10-17 21:08 wangwh0910 阅读(623) 评论(0) 推荐(0) 编辑
摘要: 第一个CG程序1. 首先,自然是包含头文件#include <cg/cg.h>#include <cg/cgGL.h>#pragma comment(lib,"cg.lib")#pragma comment(lib,"cgGL.lib")2. 创建着色器程序所需的变量着色上下文CGcontext,着色器程序CGprogram,CGprofile是用来告诉CG如何选择最适合你显卡的方式来处理顶点或片段着色,CGparameter,参数传递,从你所写的程序中向着色器程序中传递参数.static CGcontext Context = 阅读全文
posted @ 2011-10-17 20:06 wangwh0910 阅读(435) 评论(0) 推荐(0) 编辑