Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
lmj01 committed Sep 6, 2024
1 parent debd8ee commit b397e25
Show file tree
Hide file tree
Showing 11 changed files with 124 additions and 8 deletions.
2 changes: 2 additions & 0 deletions cg/graphics.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
- [Khronos社区](https://community.khronos.org/)
- [threejs社区](https://discourse.threejs.org/)

- [光照模型](/cg/lighting/illumination.model.md)

早期3D的API由驱动层提供,所有细节都是驱动贴近硬件实现的,在经过shader发展中,现代硬件越来越复杂了
新时代的抽象图形接口vulkan来了,需要更具象化的过程,就是需要自己负责更多的事情
- 任务调度
Expand Down
52 changes: 52 additions & 0 deletions cg/lighting/illumination.model.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# 光照模型

Illumination model, also known as Shading model or Lighting model, is used to calculate the intensity of light that is reflected at a given point on surface.

依赖三个元素
- Light Source : Light source is the light emitting source.
- Point Sources
- Parallel Sources
- Distributed Sources
- 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

$$
I_{amb} = K_{a}I_{a} \newline
I_{a} \text{ambient light intensity}, K_{a} \text{ surface ambient reflectivity } \in [0,1]
$$

### Diffuse Reflection

$$
I_{diff} = K_{d}I_{p}cos\theta = K_{d}I_{p}(N \dot L) \newline
I_{p} \text{the point light intensity}, K_{d} \text{ surface diffuse reflectivity } \in [0,1], \newline
N \text{the surface normal}, L \text{the light direction}
$$

- Normals in geometry a normal is a vector or a line that is perpendicular to a given object (e.g. plane normal, vertex normal ).
- 用于光照计算,如Diffuse reflection漫反射

### Specular Reflection

$$
I_{spec} = W(\theta)I_{I}cos^{n}(\phi) = K_{s}I_{I}cos^{n}(\phi) \newline
N \text{the surface normal}, L \text{the light direction} \newline
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
$$

## 物理渲染模型

### Physically Based Rendering

[Monte Carlo Integration](https://64.github.io/monte-carlo/)


## 参考

- [Basic Illumination Models](https://www.geeksforgeeks.org/basic-illumination-models/)
File renamed without changes.
4 changes: 0 additions & 4 deletions cg/lighting/pbr.md

This file was deleted.

34 changes: 32 additions & 2 deletions cg/mesh/mesh.triangle.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# 三角面片

- [重新审视褶皱表面的模拟](http://image.diku.dk/projects/media/morten.mikkelsen.08.pdf)

## Normal

Expand All @@ -10,13 +11,15 @@

## Tangent

切线空间是一个局部坐标系,原点就是vertex顶点位置,通常Z轴与顶点的法线对齐,X轴由顶点的切线Tangent、y轴由顶点的副切线Bitangent定义。

- [Lesson 6bis: tangent space normal mapping](https://github.com/ssloy/tinyrenderer/wiki/Lesson-6bis:-tangent-space-normal-mapping)

### per-vertex tangent spaces
- [Computing Tangent Space Basis Vectors for an Arbitrary Mesh](https://terathon.com/blog/tangent-space.html)
- [课件](https://www.cs.upc.edu/~virtual/G/index.php?dir=)
- [pdf](https://www.cs.upc.edu/~virtual/G/1.%20Teoria/06.%20Textures/Tangent%20Space%20Calculation.pdf)

- [threejs的Tangent支持](https://threejs.org/docs/#examples/en/utils/BufferGeometryUtils.computeMikkTSpaceTangents)

<details>
<summary>顶点切线的数学推理</summary>

Expand Down Expand Up @@ -89,6 +92,27 @@ $$

</details>

#### [threejs的Tangent支持](https://threejs.org/docs/#examples/en/utils/BufferGeometryUtils.computeMikkTSpaceTangents)
```c
#ifdef USE_TANGENT
attribute vec4 tangent;
#endif
vec3 objectTangent = vec3( tangent.xyz );
// src\renderers\shaders\ShaderChunk\normal_pars_fragment.glsl.js
// src\renderers\shaders\ShaderChunk\normal_pars_vertex.glsl.js
varying vec3 vTangent;
varying vec3 vBitangent;
// src\renderers\shaders\ShaderChunk\defaultnormal_vertex.glsl.js
vec3 transformedTangent = objectTangent; // 变形的影响
// src\renderers\shaders\ShaderChunk\normal_vertex.glsl.js
vTangent = normalize( transformedTangent );
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
// src\renderers\shaders\ShaderChunk\normal_fragment_begin.glsl.js
mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
// src\renderers\shaders\ShaderChunk\normal_fragment_maps.glsl.js
normal = normalize( tbn * mapN );
```

### MikkTSpace
- [Tangent Space Normal Maps](http://www.mikktspace.com/)
- [github c](https://github.com/mmikk/MikkTSpace)
Expand All @@ -97,4 +121,10 @@ $$
<details>
<summary>MikkTSpace切线的数学推理</summary>

MikkTSpace的方案成了事实上的标准,blender就用它来生成Normal Mapping的,光照计算中也是一个非常角色。
MikkTSpace生成tangent space即使改变了点索引,面的顺序,删除primitive等等都不影响且对triangles和quads都支持的。

顶点必须具有属性:位置Position,法线Normal,纹理坐标UV


</details>
2 changes: 1 addition & 1 deletion cg/threejs/use.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ camera的近远曲线的趋势。
牙龈根据关键点生成了面片数据,包含了顶点、uv、索引。

前端对生成的数据进行了处理,处理顶点法线,position,uv,normal,tangent。
又根据uv和tangent算出了一个uv2和tangent2. 至于为什么有这样的逻辑?忙猜是逆向过程中看到这样的逻辑
又根据uv和tangent算出了一个uv2和tangent2. 大致逻辑是拷贝,处理相同点的问题,在shader中取tangent和tangent2的均值作为最终值来使用

### flickering
2024-7-19
Expand Down
5 changes: 5 additions & 0 deletions cg/tools/galacean.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# [Galacen](https://galacean.antgroup.com/engine/)

阿里系下的一个webgl引擎,号称性能很好,研究一下源码看看核心的功能
分析一下shader的代码逻辑

1 change: 1 addition & 0 deletions cg/tools/webgl.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- [笔记](/cg/threejs/index.md)
- [BabylonJS](https://www.babylonjs.com/)
- [笔记](/cg/babylonjs/index.md)
- [galacean笔记](/cg/tools/galacean.md)

## [WebGL API](https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API)

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

</details>

## 代数

### 代数式

#### 对称式

如果交换一个代数式中任意两个字母的位置,所得代数式和原代数式恒等,那么成代数式为对称式。

#### 轮询式

把一个代数式中的字母按照某个秩序排列,然后依次把第一个字母换成第二个字母,第二个字母换成第三个字母,……,最后一个字母换成第一个字母,依次轮换一圈后,所得的代数式与原代数式恒等,则称这个代数式为轮换式

- 对称式一定是轮询式
- 轮询式不一定是对称式
- 轮换对称式的和、差、积、商也是轮换对称式

##### 齐次轮换对称式

如果轮换对称式中各项的次数相等,那么就把这样的代数式叫做齐次轮换对称式. 具有一下属性,对因式分解非常有帮助

- 齐次轮换对称式的和、差、积、商也是齐次轮换对称式

## 几何

<details>
Expand Down
7 changes: 6 additions & 1 deletion index/community.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,9 @@ languages including common scripting languages such as Javascript, Perl, PHP, Py

- [这是一款开源、多语言、自托管的项目管理工具,兼容了 Trello 和 Notion 的特点](https://www.focalboard.com/)
- [github](https://github.com/mattermost/focalboard)
- [款开源、安全、跨平台的密码管理器。该项目是采用 C++ 开发的免费、离线、无广告的密码管理工具](https://github.com/keepassxreboot/keepassxc)
- [款开源、安全、跨平台的密码管理器。该项目是采用 C++ 开发的免费、离线、无广告的密码管理工具](https://github.com/keepassxreboot/keepassxc)

## 社区

- [Khronos Standards community discussions github-account](https://community.khronos.org/)
- [The three.js community discourse. github-account](https://discourse.threejs.org/)
3 changes: 3 additions & 0 deletions index/computerScience.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
- [Zig is a general-purpose programming language and toolchain for maintaining robust, optimal and reusable software.](https://ziglang.org/)

- [core analyzer -- A power tool to understand memory layout](https://core-analyzer.sourceforge.net/index_files/Page525.html)
- [Numerical Computation Guide](https://docs.oracle.com/cd/E19957-01/806-3568/ncgTOC.html)
- [What Every Computer Scientist Should Know About Floating-Point Arithmetic](https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html)

### Database

Expand Down Expand Up @@ -66,6 +68,7 @@
- [Bgfx](/cg/bgfx.md)
- [UI](/cg/ui.md)
- [threejs 笔记](/cg/threejs/index.md)
- [Galacean](/cg/galacean/index.md)

### 动画

Expand Down

0 comments on commit b397e25

Please sign in to comment.