当前位置:网站首页>[OpenGL] notes 29. Advanced lighting (specular highlights)
[OpenGL] notes 29. Advanced lighting (specular highlights)
2022-07-02 13:13:00 【ycrsw】
1. technological process
In the traditional Feng's illumination model , The algorithm of specular illumination can achieve better results :

But the illumination model also has limitations , You can see , An obvious fault appears at the edge of the specular highlight area in the figure below . The reason for this problem is that the angle between the observation vector and the reflection vector cannot be greater than 90 degree . If the result of the dot product is negative , The specular component becomes 0.0.
When calculating diffuse illumination , The angle between the illumination direction and the normal vector exceeds 90° It means that the light comes from the back , It is correct not to show the light at this time , But the calculation of specular light must not be like this , Because the angle between the incident angle of light and the angle of view is greater than 90° It's not against common sense to see specular highlights , Even if the angle of view is far from the direction of reflection , As long as the specular reflection coefficient is small enough , Then its reflection component cannot be ignored , As shown above , To solve this part of the lighting defects , We need to think of another way to approximate :
That is, as shown in the above figure , The half range vector obtained by adding the angle vector and the incident vector and the normal vector are point multiplied , So the included angle is greater than 90° The light is really invisible , give the result as follows , The edges of the visible mirror light are indeed much smoother :
Here is a simple example of shader illumination calculation :
vec3 CalcDirLight(DirLight light, vec3 normal, vec3 viewDir)
{
vec3 lightDir = normalize(-light.direction);
// Diffuse shading
float diff = max(dot(normal, lightDir), 0.0);
// Specular shading
vec3 halfDir = normalize(lightDir + viewDir);
float spec = pow(max(dot(halfDir, normal), 0.0), material.shininess);
// Consolidated results
vec3 ambient = light.ambient * vec3(texture(material.diffuse, TexCoords));
vec3 diffuse = light.diffuse * diff * vec3(texture(material.diffuse, TexCoords));
vec3 specular = light.specular * spec * vec3(texture(material.specular, TexCoords));
return (ambient + diffuse + specular);
}
边栏推荐
- 诚邀青年创作者,一起在元宇宙里与投资人、创业者交流人生如何做选择……...
- Jerry's weather code table [chapter]
- Mysql常用命令详细大全
- 操作教程:EasyDSS如何将MP4点播文件转化成RTSP视频流?
- Ali was killed by two programming problems at the beginning, pushed inward again, and finally landed (he has taken an electronic offer)
- Linear DP acwing 902 Shortest editing distance
- Unity SKFramework框架(二十)、VFX Lab 特效库
- [opencv learning] [moving object detection]
- Sensor adxl335bcpz-rl7 3-axis accelerometer complies with rohs/weee
- JS逆向之行行查data解密
猜你喜欢

SAP MM 因物料有负库存导致MMPV开账期失败问题之对策

移动式布局(流式布局)

Unity SKFramework框架(二十)、VFX Lab 特效库

挥发性有机物TVOC、VOC、VOCS气体检测+解决方案

Unity SKFramework框架(十三)、Question 问题模块

无向图的桥

VIM super practical guide collection of this one is enough
![[opencv learning] [Canny edge detection]](/img/8b/37694ae2f0f13f829f3c033da0605e.jpg)
[opencv learning] [Canny edge detection]

面渣逆袭:MySQL六十六问,两万字+五十图详解!有点六

阿里初面被两道编程题给干掉,再次内推终上岸(已拿电子offer)
随机推荐
阿里初面被两道编程题给干掉,再次内推终上岸(已拿电子offer)
【OpenGL】笔记二十九、高级光照(镜面高光)
Unity SKFramework框架(十八)、RoamCameraController 漫游视角相机控制脚本
js4day(DOM开始:获取DOM元素内容,修改元素样式,修改表单元素属性,setInterval定时器,轮播图案例)
Professor of Shanghai Jiaotong University: he Yuanjun - bounding box (containment / bounding box)
Js1day (input / output syntax, data type, data type conversion, VaR and let differences)
阿里发布的Redis开发文档,涵盖了所有的redis操作
Unity SKFramework框架(二十一)、Texture Filter 贴图资源筛选工具
Async/await asynchronous function
Fully autonomous and controllable 3D cloud CAD: crowncad's convenient command search can quickly locate the specific location of the required command.
Obtain file copyright information
Unity skframework Framework (XVI), package manager Development Kit Manager
[opencv] [image gradient]
Unity skframework framework (XV), singleton singleton
Uniapp develops wechat applet Tencent map function and generates sig signature of location cloud
Security RememberMe原理分析
二、帧模式 MPLS 操作
Should I have a separate interface assembly- Should I have a separate assembly for interfaces?
国产免费数据仓库ETL调度自动化运维专家—TASKCTL
To bypass obregistercallbacks, you need to drive the signature method