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.让色彩动 ...
随机推荐
- 【原创】一起学C++ 之enum ---------C++ primer plus(第6版)
枚举 定义:在默认情况下讲整数值赋给枚举量,第一个枚举量的值为0,第二个枚举量的值为1,依次+1 一.定义一个枚举,枚举类型,枚举量 *与C#相比个人认为C++的enum不好一点是不能通过枚举名点其中 ...
- 2016031901 - U盘安装ubuntu系统
使用U盘安装ubuntu系统 01.进入u盘安装 个人使用的是闪迪U盘安装 02. 个人重装ubuntu 03.进入ubuntu安装界面 04.进入语言界面 05.准备安装ubuntu 06.ubun ...
- ConfigParser读取记事本、notepad++修改后的配置文件会出现:ConfigParser.MissingSectionHeaderError
使用ConfigParser来读取配置文件,经常会发现经过记事本.notepad++修改后的配置文件读取时出现下面的问题: ConfigParser.MissingSectionHeaderError ...
- 中国海洋大学第四届朗讯杯高级组 I Cuckoo for Hashing
http://acm.sdut.edu.cn/sdutoj/showproblem.php?pid=2719&cid=1203 题意 :意思就是哈希来的,具体大意就是说有两个哈希表,然后有这样 ...
- UVALive 3211 Now or later
每架飞机有早晚起降两种方式,给定n架飞机两种方式的起落时间,为每架飞机安排起落时间(早或晚),使得所有飞机起降时间按照早到晚的顺序之间的间隔时间最小值尽量大. 分析: 最小时间尽量大应该采用二分的方法 ...
- cocos2d-x mac or windows eclipse android ------ Eclipse工程里面还会有许多警告
由于公司的游戏项目比较特殊, coco2d-x 的 ios 和 android 的游戏 代码 没有采用 共享目录的开发方式.所以android 内的 c++ 游戏代码全部放在 jni 下, ...
- 使用Code first 进行更新数据库结构(数据迁移)
CodeFirst 背景 code first起初当修改model后,要持久化至数据库中时,总要把原数据库给删除掉再创建(DropCreateDatabaseIfModelChanges),此时就会 ...
- UAC新解(有非正常手段可以绕过)
360第一次注册是需要弹,可是以后就不弹了开机自启动不弹框,开机自启动不弹框 服务是system权限再说一句,一般程序也不需要过UAC系统启动项白名单.UAC有一个白名单机制.还有UAC也可以通过wu ...
- MySQL的SQL_CALC_FOUND_ROWS
分页程序一般由两条SQL组成: SELECT COUNT(*) FROM ... WHERE .... SELECT ... FROM ... WHERE LIMIT ... 如果使用SQL_CALC ...
- ruby Mixin用法
module My NA="China" attr:name attr:age def set_name(name) @name=name end def get_name ret ...