Phong Shading
【Phong Shading】
The most serious problem with Gouraud shading occurs when specular highlights are found in the middle of a large polygon. Since these specular highlights are absent from the polygon's vertices and Gouraud shading interpolates based on the vertex colors, the specular highlight will be missing from the polygon's interior. This problem is fixed by Phong shading.
相比Gouraud,Phong Shading能更好地解决镜面照问题。
Unlike Gouraud shading, which interpolates colors across polygons, in Phong shading a normal vector is linearly interpolated across the surface of the polygon from the polygon's vertex normals. The surface normal is interpolated and normalized at each pixel and then used in a reflection model, e.g. the Phong reflection model, to obtain the final pixel color. Phong shading is more computationally expensive than Gouraud shading since the reflection model must be computed at each pixel instead of at each vertex.
顶点色=GlobalAmbient*kAmbientColor + LiVec*Normal*kDiffuseColor + RefVec*ViewVec*kSpecularColor
Color = Dot(v,r)^m1*Spec*m2
m1:光泽度,小的m1带来大而平滑的光斑。大的值带来小而亮的光斑。
m2:反射色,控制光斑的强度。强反射表面拥有较大的m2值,粗糙表面拥有较小的m2值。
当有多个光源时,对所有光源求和即可。
【Blinn-Phong】
相比于Phong,镜面光照公式改为下面这个:
MidVec*Normal*kSpecularColor。
MidVec指LiVec和ViewVec的中间向量。Blinn-Phong比Phong略快。
【光的衰减】
现实世界里,光强度反比于物体和光源距离的平方。可以用一个简单的衰减模型来替代。用D_min、D_max把距离分为3段,小于D_min时,光强为1;大于D_max时光强为0;在D_min、D_max中进行插值。
一旦计算出衰减系数i,则用i乘以Phone模型计算出的(镜面反射+漫反射)颜色,即可模型光的衰减。记住环境光是没有衰减的。
参考《3D数学基础》15.4.7光的衰减
参考:
1、http://en.wikipedia.org/wiki/Phong_shading
2、http://en.wikipedia.org/wiki/Phong_reflection_model
3、http://en.wikipedia.org/wiki/Blinn%E2%80%93Phong_shading_model
Phong Shading的更多相关文章
- 如何在Unity中分别实现Flat Shading(平面着色)、Gouraud Shading(高洛德着色)、Phong Shading(冯氏着色)
写在前面: 先说一下为什么决定写这篇文章,我也是这两年开始学习3D物体的光照还有着色方式的,对这个特别感兴趣,在Wiki还有NVIDIA官网看了相关资料后,基本掌握了渲染物体时的渲染管道(The re ...
- What is Away3D
做了几个基于Flash平台的3D的项目,一路走来收获颇多.Away3D作为一个开源的Flash3D引擎,在3D页游领域,无疑是当前OGRE在国内的地位. 翻译出了多年前做Away3D中国社区的时候翻译 ...
- OpenGL Shader in OpenCASCADE
OpenGL Shader in OpenCASCADE eryar@163.com Abstract. As implementation of one of the strategic steps ...
- OpenCascade Ray Tracing Rendering
OpenCascade Ray Tracing Rendering eryar@163.com 摘要Abstract:OpenCascade6.7.0中引入了光线跟踪算法的实现.使用光线跟踪算法可实现 ...
- Unity3d《Shader篇》法线贴图
效果图 贴图 法线贴图 //代码 Shader "Custom/NormalMap" { Properties { _MainTex ("Texture", 2 ...
- 解读Unity中的CG编写Shader系列十 (光滑的镜面反射(冯氏着色))
前文完成了最基本的镜面反射着色器,单平行光源下的逐顶点着色(per-vertex lighting),又称为古罗着色(Gouraud shading).这篇文章作为后续讨论更光滑的镜面反射方式,逐像素 ...
- Opengles 管线编程介绍
OpenGL ES 2.0可编程管道 上图橙色部分(Vertex Shader和Fragment Shader)为此管道的可编程部分.整个管道包含以下两个规范: 1) OpenGL ...
- [ZZ] 基于DirectX shader的Per-pixel lighting实现
这个特效需要用到DX11 UAV吗? http://blog.tianya.cn/blogger/post_show.asp?BlogID=510979&PostID=5665974 Intr ...
- OpenGL 开始学习指南
近期需要做一个涌潮的预报与仿真模拟,为了使模型更具有真实感,且逼真,使用起来更灵活.感觉还是得从基础的OpenGL学习.鉴于Direct3D技术存在的众多不确定性,且评论不太好的原因,决定用OpenG ...
随机推荐
- css animation动画
css 动画: 动画是CSS3中具有颠覆性的特征之一,可通过设置多个节点来精确控制一个或一组动画,常用来实现复杂的动画效果. 必要元素: a.通过@keyframes指定动画序列:自动补间动画,确定两 ...
- Android模糊图像
在Android中.我们能够实现非常多非常酷的处理图片的效果. 在2014年某次会议的讲演<图像的魔力>中,我介绍了当中的一部分. 当中的一项技术是怎样模糊图像.演示样例代码是使用Rend ...
- [LeetCode系列]链表环探测问题II
给定一个链表头, 探测其是否有环, 如果没有返回NULL, 如果有返回环开始的位置. 环开始的位置定义为被两个指针指向的位置. 算法描述: 1. 快慢指针遍历, 如果到头说明无环返回NULL, 如果相 ...
- Hadoop 2.7.4 关闭与启动
环境说明:[root@hadp-master sbin]# hadoop versionHadoop 2.7.4 一. 脚本封装全部一起启动.关闭1.1 启动[root@hadp-master sbi ...
- filter添加水印
1filter写法 先定义自己的responseWrapper chain.doFilter(request,responseWrapper); responseWrapper来输出 package ...
- bzoj 1069 [SCOI2007]最大土地面积——旋转卡壳
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1069 发现 n 可以 n^2 .所以枚举对角线,分开的两部分三角形就可以旋转卡壳了. 注意坐 ...
- javascript 中的 arguments,callee.caller,apply,call 区别
记录一下: 1.arguments是一个对象, 是函数的一个特性,只有在函数内才具有这个特性,在函数外部不用使用. 举例: function test(){ alert(typeof argume ...
- ubuntu 指令修改时区 tzselect
修改时区 tzselect 指令只是根据提示一步步选择正确时区,但不能真正修改时区,最后输入提示的指令,然后重启,才能永久修改. aaron@ubuntu:~$ tzselect Please ide ...
- 部署docker
部署和开发环境不一样,我们不需要频繁地进入到容器内部,所以一般我们会将代码和环境打包到一块,部署到服务器上 Clone 代码 将项目代码克隆到本地 git clone git@git.coding.n ...
- MVC自定义错误页面
MVC异常处理主要有三种方案:1.基于HandleErrorAttribute重写OnException方法:2.基于Global.apsx添加Application_Error方法:3.直接在Web ...