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 ...
随机推荐
- java基础--关键字
- CDN初学搭建(ats)
CDN初学搭建(ats) ats trafficserver squid 一. CDN初学搭建 准备vagrant virtualbox 内部环境测试所需包 一.vagrant创建启动虚拟机 1 mk ...
- HTTP 协议小结
本篇博客来自前辈整理资料的学习之作,若有冒犯,敬请谅解!原文博客已删除,转载篇:HTTP协议详解 1,HTTP特点 HTTP是一个属于应用层的面向对象的协议,由于其简捷.快速的方式,适用于 ...
- [Oracle] CPU/PSU补丁安装详细教程
Oracle CPU的全称是Critical Patch Update, Oracle对于其产品每个季度发行一次安全补丁包,通常是为了修复产品中的安全隐患,以下是对CPU/PSU补丁安装的具体操作步骤 ...
- Oracle在线新增索引
Oracle新增索引语法很简单,如果是普通索引的话: create Index IDX_T_WLF on T_WLF(ACTIVITYID,ACTIVETIME) tablespace TBS_VCO ...
- git 清除本地无效的分支
远程服务器的分支已经删掉了,但是本地分支还存在 $ git fetch -p 如果不行,使用下面的指令 $ git remote prune origin
- 快速创建yii2 RESTful api的小记
1.复制backend的应用到同级目录,改名叫api 2.然后就是配置项修改,common和api目录下的 common下: bootstrap.php最后添加一行配置 api/config/main ...
- m'ybatis 一对一 一对多 配置详解
javabean: package com.me.model; import java.io.Serializable; import java.util.Date; import java.util ...
- (转)Inno Setup入门(八)——有选择性的安装文件
本文转载自:http://blog.csdn.net/yushanddddfenghailin/article/details/17250827 这主要使用[Components]段实现,一个演示的代 ...
- StreamTool
public class StreamTool { //从流中读取数据 public static byte[] read(InputStream inStream) throws Exception ...