赞
踩
兰伯特经验模型计算漫反射的公式:
-
-
-
- worldNormal
-
- =
-
-
-
- normalize
-
- (
-
- mul
-
- (
-
- v
-
- .
-
- normal
-
- ,
-
-
-
- (
-
- float3x3
-
- )
-
- unity_WorldToObject
-
- )
-
- )
-
- ;
- worldLightDir
-
- =
-
-
-
- normalize
-
- (
-
- _WorldSpaceLightPos0
-
- .
-
- xyz
-
- )
-
- ;
-
-
- diffse
-
- =
-
- _LightColor0
-
- .
-
- rgb
-
- *
-
- _Diffuse
-
- .
-
- rgb
-
- *
-
-
-
- max
-
- (
-
- 0
-
- ,
-
- dot
-
- (
-
- worldNormal
-
- ,
-
- worldLightDir
-
- )
-
- )
-
- ;
-
worldNormal的计算过程:
worldLightDir的计算过程:
Diffse的计算过程:
-
-
-
- halfLambert
-
- =
-
-
-
- dot
-
- (
-
- worldNormal
-
- ,
-
- worldLightDir
-
- )
-
-
-
- *
-
-
-
- 0.5
-
-
-
- +
-
-
-
- 0.5
-
高光反射的计算公式:
反射方向计算公式:
-
-
-
- reflectDir
-
- =
-
-
-
- normalize
-
- (
-
- reflect
-
- (
-
- -
-
- worldLight
-
- ,
-
- worldNormal
-
- )
-
- )
-
- ;
-
viewDir = normalize ( _WorldSpaceCameraPos . xyz - i . worldPos . xyz ) ;
最后组装成高光反射公式
-
-
-
- specular
-
- =
-
- _LightColor0
-
- .
-
- rgb
-
- *
-
- _Specular
-
- .
-
- rgb
-
- *
-
-
-
- pow
-
- (
-
- saturate
-
- (
-
- dot
-
- (
-
- reflectDir
-
- ,
-
- viewDir
-
- )
-
- )
-
- ,
-
- _Gloss
-
- )
-
- ;
-
下面是blinn phong的计算公式:
半程向量h的公式:
-
-
-
- h
-
- =
-
-
-
- normalize
-
- (
-
- worldLight
-
- +
-
- viewDir
-
- )
-
- ;
-
-
-
-
- Blinn
-
- specular
-
- =
-
- _LightColor0
-
- .
-
- rgb
-
- *
-
- _Specular
-
- .
-
- rgb
-
- *
-
- pow
-
- (
-
- Max
-
- (
-
- 0
-
- ,
-
- dot
-
- (
-
- worldNormal
-
- ,
-
- h
-
- )
-
- )
-
- ,
-
- _Gloss
-
- )
-
- ;
-
-
-
-
- ambient
-
- =
-
- UNITY_LIGHTMODEL_AMBIENT
-
- .
-
- xyz
-
-
-
-
- atten
-
- =
-
- tex2D
-
- (
-
- _LightTexture0
-
- ,
-
- dot
-
- (
-
- lightCoord
-
- ,
-
- lightCoord
-
- )
-
- .
-
- rr
-
- )
-
- .
-
- UNITY_ATTEN_CHANNEL
-
- ;
-
https://zhuanlan.zhihu.com/p/102134614
《Unity shader 入门精要》
https://en.wikipedia.org/wiki/Blinn%E2%80%93Phong_reflection_model
闫令琪-GAMES101-现代计算机图形学入门
https://paroj.github.io/gltut/Illumination/Tut11%20BlinnPhong%20Model.html
https://zhuanlan.zhihu.com/p/102135703
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。