Specular light 计算
Specular lighting is most commonly used to give light reflection off of metallic surfaces such as mirrors and highly polished/reflective metal surfaces. It is also used on other materials such as reflecting sunlight off of water. Used well it can add a degree of photo realism to most 3D scenes.
The equation for specular lighting is the following:
SpecularLighting = SpecularColor * (SpecularColorOfLight * ((NormalVector dot HalfWayVector) power SpecularReflectionPower) * Attentuation * Spotlight)
We will modify the equation to produce just the basic specular lighting effect as follows:
SpecularLighting = SpecularLightColor * (ViewingDirection dot ReflectionVector) power SpecularReflectionPower
The reflection vector in this equation has to be produced by multiplying double the light intensity by the vertex normal. The direction of the light is subtracted which then gives the reflection vector between the light source and the viewing angle:
ReflectionVector = 2 * LightIntensity * VertexNormal - LightDirection
The viewing direction in the equation is produced by subtracting the location of the camera by the position of the vertex:
ViewingDirection = CameraPosition - VertexPosition
Specular light 计算的更多相关文章
- CSharpGL(54)用基于图像的光照(IBL)来计算PBR的Specular部分
CSharpGL(54)用基于图像的光照(IBL)来计算PBR的Specular部分 接下来本系列将通过翻译(https://learnopengl.com)这个网站上关于PBR的内容来学习PBR(P ...
- 软件光栅器实现(二、VS和PS的运作,法线贴图,切空间的计算)
二.软件光栅器的VS和PS的输入.输出和运作,实现法线贴图效果的版本.转载请注明出处. 这里介绍的VS和PS是实现法线映射的版本,本文仅介绍实现思路,并给出代码供参考.切空间计算.光照模型等相关公式不 ...
- 基于虎书实现LALR(1)分析并生成GLSL编译器前端代码(C#)
基于虎书实现LALR(1)分析并生成GLSL编译器前端代码(C#) 为了完美解析GLSL源码,获取其中的信息(都有哪些in/out/uniform等),我决定做个GLSL编译器的前端(以后简称编译器或 ...
- [CG编程] 基本光照模型的实现与拓展以及常见光照模型解析
0.前言 这篇文章写于去年的暑假.大二的假期时间多,小组便开发一个手机游戏的项目,开发过程中忙里偷闲地了解了Unity的shader编写,而CG又与shaderLab相似,所以又阅读了<CG教程 ...
- Shader预处理宏、内置状态变量、多版本编译等
预定义shader预处理宏: Target platform: SHADER_API_OPENGL - desktop OpenGL SHADER_API_D3D9 - Direct3D SHADER ...
- u3d_Shader_effects笔记2 自定义surfaceDiffuseLight
1.前面的心情 今晚7点半睡着后,9点半左右被吵醒.醒来后非常失落,感觉人生到底在追求什么,我又在追求什么.昨晚梦到妈妈了.最近不时会想到爷爷的去世.人世的险恶,良心的缺失.不过一切总要向前看,至少我 ...
- Rendering Path
Rendering Path:渲染路径 设置:1.Player Setting,2.Camera(会覆盖PlayerSetting中的设置) 选择:根据渲染内容和目标平台来选择合适的Rendering ...
- D3D的绘制
一.D3D中的绘制 顶点缓存和索引缓存:IDirect3DVertexBuffer9 IDirect3DIndexBuffer 使用这两缓存而不是用数组来存储数据的原因是,缓存可以被放置在显存中,进行 ...
- UnityShader快速上手指南(二)
简介 前一篇介绍了如果编写最基本的shader,接下来本文将会简单的深入一下,我们先来看下效果吧 呃,gif效果不好,实际效果是很平滑的动态过渡 实现思路 1.首先我们要实现一个彩色方块 2.让色彩动 ...
随机推荐
- 创建一个cocos2d-x工程添加一个自定义Scene并显示
#include "cocos2d.h" class RunScene :public cocos2d::CCLayer { public: virtual bool init() ...
- Delphi XE2及以后的版本编译后的程序大小问题
说说Delphi XE2及以后的版本编译后的程序大小问题. 其实最终得到的程序并不大,由于编译器的变化,XE2里Debug版程序比Release版程序大很多,要减小程序体积,就使用Release版.下 ...
- Chart Style
How to add label to column chart http://blogs.msdn.com/b/delay/archive/2009/07/27/simple-column-labe ...
- 把Mvc4项目部署到虚拟目录之后找不到control想到的文件路径规范的问题
最近部署的项目的时候由于端口不够用,想到了把Mvc项目部署到虚拟目录中,结果发现图片,js设置control都找不到了.项目是mvc4+easyui开发的,大量的代码都是在js中调用control,写 ...
- 认识基本的UI资源
什么是UI精灵(Sprite) 在制作UI时,经常将一些零碎的小的UI资源(比如,一个小箭头,一个按钮等)打包成一张大图,然后在使用时,只使用这个大图中的一部分,那么这一块"被切出来&quo ...
- 转载 -- iOS数据持久化存储
作者:@翁呀伟呀 授权本站转载 概论 所谓的持久化,就是将数据保存到硬盘中,使得在应用程序或机器重启后可以继续访问之前保存的数据.在iOS开发中,有很多数据持久化的方案,接下来我将尝试着介绍一下5种方 ...
- 升级mac中的系统之后,给PHP安装扩展常出现问题
(1)在装mcrypt插件时报错,提示:mcrypt fatal error: 'php.h' file not found,然后又仔细操作了一次在输完phpize回车时就已经开始出错了,出错信息如下 ...
- 1006: [HNOI2008]神奇的国度
图上的最小的染色方案: 学习了陈丹绮的论文: MCS算法 #include<cstdio> #define maxn 10005 #define maxm 2000005 using na ...
- win7(x64)+VS2012+cocos2d-x环境的配置以及试运行
原地址:http://blog.csdn.net/gf771115/article/details/20740993 转自:http://blog.sina.com.cn/s/blog_62df697 ...
- WINDOWS HYPER-V加新网卡,设置网络出错
新网卡加入,设置好IP之后,HYPER-V需要更改相应外部网络连接,然后重新生成新的虚拟连接网卡. 不然,虚拟机无法正常使用网络. 但我昨天在绑定新的网站时,出现如下错误: Adding a new ...