Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
lmj01 committed Sep 12, 2024
1 parent 779eb29 commit 1b2714f
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 24 deletions.
11 changes: 10 additions & 1 deletion articles/notes/work.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,13 @@
- fa 牙号放在的位置
- flAxis 从颊侧到舌侧方向
- ieAxis 从牙冠到牙根方向
- mdAxis 从近中到远中方向
- mdAxis 从近中到远中方向

### 编辑

- 牙齿轴向
- 附件
- IPR
- 间隙
- 托槽
- 牙弓曲线,渲染有问题
55 changes: 44 additions & 11 deletions cg/lighting/illumination.model.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ Illumination model, also known as Shading model or Lighting model, is used to ca
- Surface : When light falls on a surface part of it is reflected and part of it is absorbed.
- Observer : The observer’s position and sensor spectrum sensitivities also affect the lighting effect


## 基础光照模型

### Ambient Illumination
Expand All @@ -29,15 +28,6 @@ void main() {

### Diffuse Reflection

- Rough surfaces tend to cause more diffuse reflection than smooth surfaces.

There are three types of diffuse reflection: Lambertian, Oren-Nayar, and Phong.
- Lambertian reflection, is the simplest type of diffuse reflection. It assumes that the surface is perfectly diffuse, meaning that the angle at which light hits the surface has no effect on how much light is reflected. This results in a smooth, even reflection without any highlights or shadows.

- Oren-Nayar reflection is a more realistic type of diffuse reflection that takes into account the fact that light doesn’t always hit a surface evenly. It accounts for both the angle at which light hits the surface and the roughness of the surface. This results in a more natural-looking reflection with highlights and shadows.

- Phong reflection is the most realistic type of diffuse reflection. It takes into account not only the angle at which light hits the surface and the roughness of the surface but also the shininess of the surface. This results in a very natural-looking reflection with highlights, shadows, and specular reflections (the bright highlights you see on polished surfaces).

$$
R_{d} = K_{d} \times I \times max(0, N * L) = K_{d}I(N \cdot L) \newline
I \text{光照强度light intensity}, K_{d} \text{表面散射系数surface diffuse reflectivity } \in [0,1], \newline
Expand All @@ -51,7 +41,7 @@ uniform vec3 lightPos;
void main() {
vec3 norm = normalize(normal);
vec3 lightDir = normalize(lightPos - position); // 入射光方向
float diff = max(dot(norm, lightDir), 0.0);
float diff = max(dot(norm, lightDir), 0.0);
vec3 dColor = lightColor * diff * objectColor;
}
```
Expand All @@ -70,12 +60,55 @@ R \text{direction of reflected ray}, V \text{direction of observer} \newline
\theta \text{angle between L and R}, \phi \text{angle between R and V} \newline
$$

```glsl
attribute vec3 position;
attribute vec3 normal;
uniform vec3 lightPos;
uniform vec3 cameraPos;
void main() {
vec3 viewDir = normalize(cameraPos - positioin);
vec3 lightDir = normalize(lightPos - position);
vec3 reflectDir = reflect(-lightDir, N); // R = 2(N dot L)N - L
float spec = pow(max(dot(viewDir, lightDir), 0.0), gloss);
vec3 sColor = lightColor * spec * objectColor;
}
```

### Phong

ADS = Ambient + Diffuse + Specular

存在一个问题就是camera和light在法线的同一侧时,这就是Blinn-Phong的方案
引入半程向量h,定义为入射光和观察方向的中间向量,夹角越小高光越亮

```glsl
attribute vec3 position;
attribute vec3 normal;
uniform vec3 lightPos;
uniform vec3 cameraPos;
void main() {
vec3 viewDir = normalize(cameraPos - positioin);
vec3 lightDir = normalize(lightPos - position);
vec3 h = normalize(viewDir + lightDir);
vec3 reflectDir = reflect(-lightDir, N); // R = 2(N dot L)N - L
float spec = pow(max(dot(h, normal), 0.0), ks);
vec3 sColor = lightColor * spec * objectColor;
}
```

## 物理渲染模型

没有统一的公式,有的就是概率分布上的封装,基础光照模型中,法线、光线这些分布都是有约束的,实际中可能存在各种情况
- 法线分布概率,顶点法线的不够丝滑如何解决,不能靠增加法线计算量来模拟?
- 光的可见性函数V,有多少光线被表面的凹凸不平遮住了,产生的效果如何模拟?
- 双向反射分布函数BRFD,物体本身的属性吸收光和反射光产生的最终效果如何模拟?

为了更接近真实材质的外观表现,具备能量守恒,符合物理世界的真实,由经验的光照模型转移到基于物理理论的光照模型,就是PBR。

$L = C_{diffuse} \times N \cdot L + C_{specular}(N \cdot H)^{m}$

m控制高光大小范围,m越大,光斑越集中,m越小,光斑越分散。

### Physically Based Rendering

[Monte Carlo Integration](https://64.github.io/monte-carlo/)
Expand Down
11 changes: 5 additions & 6 deletions cg/threejs/material.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# [Shader](https://threejs.org/docs/index.html?q=material)
# [材质material](https://threejs.org/docs/index.html?q=material)

- [[SOLVED] Why does object get dimmer/darker when light gets closer to it?](https://discourse.threejs.org/t/solved-why-does-object-get-dimmer-darker-when-light-gets-closer-to-it/3475)

Expand Down Expand Up @@ -31,14 +31,13 @@ It would require some changes to use this with the THREE.EffectComposer, sorry.

- [描述fog的一个思路应用,效果很好](https://discourse.threejs.org/t/tesseract-open-world-planetary-engine/1473/7)

## [Shader](https://threejs.org/docs/index.html?q=shader#api/en/materials/ShaderMaterial)
## [ShaderMaterial](https://threejs.org/docs/index.html?q=shader#api/en/materials/ShaderMaterial)

在源码src\renderers\webgl\WebGLProgram.js中函数WebGLProgram组装最后的代码到prefixVertex, prefixFragment

```js
renderer.toneMapping = LinearToneMapping;
renderer.toneMappingExposure = 0.1;
```
对象renderer.info.programs中缓存了WebGLProgram,WebGLProgram.cacheKey作为了一个shader对象的unique值,它是由src\renderers\webgl\WebGLPrograms.js文件中getProgramCacheKey决定的一个string值。



### BumpMap

Expand Down
4 changes: 1 addition & 3 deletions cg/threejs/model.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ LoadingManager是一个独立封装的,类似一个函数,全部在construct

## 导出

### JSON
### string
导出当前内存的对象为JSON文件
```js
/**
Expand All @@ -44,5 +44,3 @@ LoadingManager是一个独立封装的,类似一个函数,全部在construct
window.URL.revokeObjectURL(url);
})();
```


15 changes: 12 additions & 3 deletions cg/tools/glsl.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
# [GLSL]()

```glsl
// builtin-function
float dotNL = saturate( dot( normal, lightDir ) ); // make sure result in [0,1]
// snippet code
// [-1,1] to [0, 1]
float out1 = in1 * 0.5 + 0.5;
// [0, 1] to [-1, 1]
float out2 = in2 * 2.0 - 1.0;
```
## 内置函数
在图形编程中,pow 函数常用于计算光照模型中的衰减、颜色混合的伽马校正、模拟物体表面的物理属性(如反射率、折射率等)等。
```js
```glsl
// vndc = pos.xy / pos.w; from vertex
// mouse = [2*offsetx/w-1, 1-2*offsety/h]
// focused highlight
float falloff = 10.0;
float dif = pow(falloff, -clamp(length(mouse - vndc), 0.0, 1.0));
```
```

8 changes: 8 additions & 0 deletions exercises/math.secondary.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ $e^{\pi i} + 1 = 0 \to e^{\pi i} = -1$

## 几何

<details>
<summary>2024-8-23塞瓦定理</summary>

- [用圆幂及消点法解2024年高中数学联赛加试几何题](https://mp.weixin.qq.com/s/A-NDWhNZ_EeUFDv8bi2YXA)

</details>


<details>
<summary>2024-8-23塞瓦定理</summary>

Expand Down

0 comments on commit 1b2714f

Please sign in to comment.