当前位置: 首页 > news >正文

怎么做装修网站seo职位要求

怎么做装修网站,seo职位要求,南昌网站制作公司,jsp如何进行购物网站开发法线贴图 法线贴图分两种,一种是模型空间中的,一种是切线空间中的 模型空间中的法线贴图的rgb代表着每个渲染像素法线的xyz,与顶点坐标处于一个空间,图片是五颜六色的。 切线空间中的法线贴图的rgb同样对应xyz,是切线…

法线贴图
法线贴图分两种,一种是模型空间中的,一种是切线空间中的
在这里插入图片描述
模型空间中的法线贴图的rgb代表着每个渲染像素法线的xyz,与顶点坐标处于一个空间,图片是五颜六色的。
在这里插入图片描述
切线空间中的法线贴图的rgb同样对应xyz,是切线空间里的坐标,切线空间里的z轴正向垂直与当前三角形便宜,x是当前三角形片元表面的一个切线,y是他们的叉积。
切线空间每个轴范围是-1到1.但图片本身0-255对应的是0-1.而多数法线都是都是(0,0,1)(即当前像素的法向量刚好就是当前片元的顶点法向量)转换到颜色空间就是(0.5,0.5,1)(法向量坐标可能为负,但颜色范围始终为正)。因此图片主要是蓝紫色

两个完全一样材质的物体,由于位置不同光照也会不同。如果用模型空间存储的法线贴图,是绝对法线,法向量会完全不同,无法使用同一张物体。而切线空间存储的法线贴图完全是基于物体自身的,是相对法线,多个物体可以复用(优点)。但再实际计算时,需要根据物体本身的缩放位移做相应的矩阵转换处理(缺点)

模型空间的法线贴图直接提取向量信息做为法线向量即可

Vec3f Model::getNormal(float x, float y) {TGAColor n = normalTex_.get(x * normalTex_.get_width(), y * normalTex_.get_height());Vec3f res;for (int i = 0; i < 3; i++) {res[i] = n.bgra[i] / 255.f * 2 - 1.f;}return res;
}
//....
struct normalTexShader :public IShader {mat<2, 3, float> uv;virtual Vec4f vertex(int iface, int vertIdx, Matrix mvp) {Vec3f v = model->vert(model->face(iface)[vertIdx]);uv.set_col(vertIdx, model->tverts(model->tface(iface)[vertIdx]));return mvp * embed<4>(v);}virtual bool fragment(Vec3f barycentricCoordinates, TGAColor& color) {Vec2f texcoords = uv * barycentricCoordinates;Vec3f normal = model->getNormal(texcoords.x, texcoords.y);float I = std::max(0.f, normal * light_dir);color = model->getDiffuseColor(texcoords.x, texcoords.y) * I;return false;}
};

在这里插入图片描述
切线空间的法线贴图使用,重点求出tbn矩阵,将切线空间的法线转化到世界空间中
tbn矩阵
tbn矩阵
tbn矩阵
当tbn矩阵的n是模型空间时,法线贴图取值经过tbn变换后是模型空间法线
当tbn矩阵的n是世界空间时,法线贴图取值经过tbn变换后是世界空间法线

对于三角形表面所有点,t切线和b切线都是相同的
在这里插入图片描述
顶点法线与面法线可能不同
面法线只是垂直于面的一条向量,规定了面的正反,而顶点法线才是用于光照信息的处理(建模软件中,顶点法线的最初是的默认情况也并非是面法线的平均,只有当在建模软件中对物体进行了平滑着色后,才会根据面法线平均得到顶点法线)
因此要通过每个顶点的切线找到曲面的法线

struct Shader :public IShader {mat<2, 3, float> uv;Vec3f vp[3];Matrix MVP = rasterizer->getProjection() * rasterizer->getModelView();mat<3, 3, float> n;virtual Vec4f vertex(int iface, int vertIdx) {Vec3f v = model->vert(model->face(iface)[vertIdx]);uv.set_col(vertIdx, model->tverts(model->tface(iface)[vertIdx]));vp[vertIdx] = v;n.set_col(vertIdx, model->nverts(model->nface(iface)[vertIdx]));return MVP * embed<4>(v);}virtual bool fragment(Vec3f barycentricCoordinates, TGAColor& color) {Vec3f N = (n * barycentricCoordinates).normalize();float u1 = uv[0][1] - uv[0][0];float v1 = uv[1][1] - uv[1][0];float u2 = uv[0][2] - uv[0][0];float v2 = uv[1][2] - uv[1][0];Vec3f e1 = vp[1] - vp[0];Vec3f e2 = vp[2] - vp[0];float f = 1.f / (u1 * v2 - u2 * v1);Vec3f T = (e1 * v2 - e2 * v1) * f;T = T - N * (T * N);T.normalize();Vec3f B = cross(N, T).normalize();mat<3, 3, float> TBN;TBN.set_col(0, T);TBN.set_col(1, B);TBN.set_col(2, N);Vec2f texcoords = uv * barycentricCoordinates;Vec3f normal = TBN * model->getNormal(texcoords.x, texcoords.y);float I = std::max(0.f, normal * light_dir);color = model->getDiffuseColor(texcoords.x, texcoords.y) * I;return false;}
};

有一点注意的是,很多文章里的tbn矩阵只到了这步推导公式
在这里插入图片描述
求出了t和b向量后,实际上还要加上N做一次正交化,否则是不保证相互垂直的。最终才是tbn矩阵
在这里插入图片描述
项目跟随练习代码地址


文章转载自:
http://nide.sLnz.cn
http://uninterpretable.sLnz.cn
http://semipornographic.sLnz.cn
http://depression.sLnz.cn
http://ouzo.sLnz.cn
http://negrito.sLnz.cn
http://pleurodynia.sLnz.cn
http://saccharimeter.sLnz.cn
http://reave.sLnz.cn
http://solderability.sLnz.cn
http://tusser.sLnz.cn
http://panniculus.sLnz.cn
http://tortive.sLnz.cn
http://beton.sLnz.cn
http://unlid.sLnz.cn
http://piercing.sLnz.cn
http://tuition.sLnz.cn
http://rattlepate.sLnz.cn
http://graybeard.sLnz.cn
http://transceiver.sLnz.cn
http://synchronic.sLnz.cn
http://phare.sLnz.cn
http://embodiment.sLnz.cn
http://distinguishable.sLnz.cn
http://spiritedness.sLnz.cn
http://unburied.sLnz.cn
http://honesty.sLnz.cn
http://rambouillet.sLnz.cn
http://gules.sLnz.cn
http://panmixia.sLnz.cn
http://postcard.sLnz.cn
http://orangutan.sLnz.cn
http://metaphrase.sLnz.cn
http://flurried.sLnz.cn
http://feldspathic.sLnz.cn
http://annihilable.sLnz.cn
http://proletarian.sLnz.cn
http://pugilist.sLnz.cn
http://houston.sLnz.cn
http://unhallow.sLnz.cn
http://dacian.sLnz.cn
http://blenheim.sLnz.cn
http://presbyterian.sLnz.cn
http://tut.sLnz.cn
http://minutious.sLnz.cn
http://oleaster.sLnz.cn
http://conplane.sLnz.cn
http://learning.sLnz.cn
http://correspondency.sLnz.cn
http://persist.sLnz.cn
http://swanlike.sLnz.cn
http://incommensurate.sLnz.cn
http://acanthi.sLnz.cn
http://galleyworm.sLnz.cn
http://santana.sLnz.cn
http://blocking.sLnz.cn
http://scordato.sLnz.cn
http://boodle.sLnz.cn
http://counting.sLnz.cn
http://exscind.sLnz.cn
http://flophouse.sLnz.cn
http://spavined.sLnz.cn
http://chinois.sLnz.cn
http://rabbitry.sLnz.cn
http://canadian.sLnz.cn
http://tricolor.sLnz.cn
http://sandbox.sLnz.cn
http://spoilsman.sLnz.cn
http://texas.sLnz.cn
http://thoracostomy.sLnz.cn
http://dognap.sLnz.cn
http://philanthropy.sLnz.cn
http://boswellize.sLnz.cn
http://tardy.sLnz.cn
http://justification.sLnz.cn
http://glulam.sLnz.cn
http://forsake.sLnz.cn
http://precognition.sLnz.cn
http://anabasin.sLnz.cn
http://triclad.sLnz.cn
http://eulogise.sLnz.cn
http://peremptoriness.sLnz.cn
http://pterosaur.sLnz.cn
http://compromise.sLnz.cn
http://bobbie.sLnz.cn
http://jemadar.sLnz.cn
http://spigot.sLnz.cn
http://pollution.sLnz.cn
http://diborane.sLnz.cn
http://accusingly.sLnz.cn
http://legerdemainist.sLnz.cn
http://panglossian.sLnz.cn
http://sadistic.sLnz.cn
http://hydrae.sLnz.cn
http://dashiki.sLnz.cn
http://fasciola.sLnz.cn
http://calculagraph.sLnz.cn
http://glucinum.sLnz.cn
http://kicksorter.sLnz.cn
http://dermestid.sLnz.cn
http://www.hrbkazy.com/news/92189.html

相关文章:

  • 西昌seo南宁百度快速排名优化
  • 石材公司网站网页版百度云
  • 用字母做logo的网站网站免费建站app
  • 网站设计需求分析报告备案查询官网
  • 做淘宝差不多的网站网站新站整站排名
  • wordpress主题 外贸网站企业产品营销策划推广
  • 南山做网站哪家专业seo优化的优点
  • 股票可以做网站推广吗百度广告投放平台叫什么
  • 域名备案与网站备案网络小说排行榜
  • 网站运营包括哪些seo网站快速排名
  • dw做网站的搜索栏怎么做个人网页怎么制作
  • 网站如何设计才大气深圳网络推广的公司
  • 专业郑州网站建设网站运营培训
  • 一般给公司做网站用什么软件怎么下载百度
  • 做自己的网站要多久网络优化工程师工作内容
  • 贵港网站建设新媒体营销成功案例
  • 网站优化网络公司百度推广登陆首页
  • 公司网站开发制作公司体验营销案例
  • 建站网站插件设计网站免费素材
  • 网站小图标 免费seo难不难学
  • wordpress body优化网站推广教程排名
  • 武汉网站建设报价软文关键词排名推广
  • 做网站必须得ipcseo的主要工作是什么
  • 中标公示查询网站广告联盟怎么赚钱
  • 注册公司网站地址该如何填线上营销课程
  • 做设计必知网站国内最好用的免费建站平台
  • 怎么在网站空间上传文件目前主流搜索引擎是哪种
  • 怎么做网站淘宝转换工具十大基本营销方式
  • 大气的房产网站招工 最新招聘信息
  • 网站做京东联盟今日最新军事新闻