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的更多相关文章

  1. 如何在Unity中分别实现Flat Shading(平面着色)、Gouraud Shading(高洛德着色)、Phong Shading(冯氏着色)

    写在前面: 先说一下为什么决定写这篇文章,我也是这两年开始学习3D物体的光照还有着色方式的,对这个特别感兴趣,在Wiki还有NVIDIA官网看了相关资料后,基本掌握了渲染物体时的渲染管道(The re ...

  2. What is Away3D

    做了几个基于Flash平台的3D的项目,一路走来收获颇多.Away3D作为一个开源的Flash3D引擎,在3D页游领域,无疑是当前OGRE在国内的地位. 翻译出了多年前做Away3D中国社区的时候翻译 ...

  3. OpenGL Shader in OpenCASCADE

    OpenGL Shader in OpenCASCADE eryar@163.com Abstract. As implementation of one of the strategic steps ...

  4. OpenCascade Ray Tracing Rendering

    OpenCascade Ray Tracing Rendering eryar@163.com 摘要Abstract:OpenCascade6.7.0中引入了光线跟踪算法的实现.使用光线跟踪算法可实现 ...

  5. Unity3d《Shader篇》法线贴图

    效果图 贴图 法线贴图 //代码 Shader "Custom/NormalMap" { Properties { _MainTex ("Texture", 2 ...

  6. 解读Unity中的CG编写Shader系列十 (光滑的镜面反射(冯氏着色))

    前文完成了最基本的镜面反射着色器,单平行光源下的逐顶点着色(per-vertex lighting),又称为古罗着色(Gouraud shading).这篇文章作为后续讨论更光滑的镜面反射方式,逐像素 ...

  7. Opengles 管线编程介绍

      OpenGL ES 2.0可编程管道 上图橙色部分(Vertex Shader和Fragment Shader)为此管道的可编程部分.整个管道包含以下两个规范: 1)         OpenGL ...

  8. [ZZ] 基于DirectX shader的Per-pixel lighting实现

    这个特效需要用到DX11 UAV吗? http://blog.tianya.cn/blogger/post_show.asp?BlogID=510979&PostID=5665974 Intr ...

  9. OpenGL 开始学习指南

    近期需要做一个涌潮的预报与仿真模拟,为了使模型更具有真实感,且逼真,使用起来更灵活.感觉还是得从基础的OpenGL学习.鉴于Direct3D技术存在的众多不确定性,且评论不太好的原因,决定用OpenG ...

随机推荐

  1. json常用方法和本地存储方法

    1.JSON.parse()[把json字符串解析成json对象] 2.JSON.stringify()[把json对象中解析成json字符串] <script> let obj = '{ ...

  2. 如何在aspx.cs 里面获取html 控件值

    aspx 页面 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default. ...

  3. java基础--关键字

  4. nodejs之assert

    assert断言在nodejs中的用法: 1.引入assert模块 2.语法 assert('条件', '条件不成立时显示信息'); 例如:assert.js文件 const assert = req ...

  5. hive加载json数据解决方案

    hive官方并不支持json格式的数据加载,默认支持csv格式文件加载,如何在不依赖外部jar包的情况下实现json数据格式解析,本编博客着重介绍此问题解决方案 首先创建元数据表: create EX ...

  6. Android中处理崩溃异常 (转)

    大家都知道,现在安装Android系统的手机版本和设备千差万别,在模拟器上运行良好的程序安装到某款手机上说不定就出现崩溃的现象,开发者个人不可能购买所有设备逐个调试,所以在程序发布出去之后,如果出现了 ...

  7. emacs之开始就加载tag

    ~/emacsConfig/original-tags.el (setq tags-table-list ' ( "~/emacsConfig/etags/muduo" " ...

  8. FPGA能代替CPU架构吗?

    你还没听过FPGA?那你一定是好久没有更新自己在企业级IT领域的知识了.今天笔者就和大家聊聊何为FPGA?FPGA主要应用场景是什么?有人说FPGA是替代传统CPU和GPU的未来,你信吗? FPGA全 ...

  9. Spring AOP两种实现方式

    一. AOP 概念: Spring AOP 即Aspect Oriented Programming(面向切面编程), 实现方式分为两种: 1. 注解(Annotation) 2. 配置(Config ...

  10. AngularJS.js: 杂项

    ylbtech-AngularJS.js: 杂项 AngularJS诞生于2009年,由Misko Hevery 等人创建,后为Google所收购.是一款优秀的前端JS框架,已经被用于Google的多 ...