mirror of
https://github.com/tengge1/ShadowEditor.git
synced 2026-01-25 15:08:11 +00:00
添加着色器代码。
This commit is contained in:
parent
3afc2ea1d0
commit
bd2d3801ef
@ -1,4 +1,7 @@
|
||||
import applyMatrix4 from './vec3/applyMatrix4.glsl';
|
||||
import lengthSq from './vec3/lengthSq.glsl';
|
||||
import angleTo from './vec3/angleTo.glsl';
|
||||
|
||||
import makeOrthographic from './mat4/makeOrthographic.glsl';
|
||||
import makePerspective from './mat4/makePerspective.glsl';
|
||||
import makePerspective2 from './mat4/makePerspective2.glsl';
|
||||
@ -9,6 +12,8 @@ import decomposeMatrix from './mat4/decomposeMatrix.glsl';
|
||||
Object.assign(THREE.ShaderChunk, {
|
||||
// vec3
|
||||
applyMatrix4: applyMatrix4,
|
||||
lengthSq: lengthSq,
|
||||
angleTo: angleTo,
|
||||
|
||||
// mat4
|
||||
makeOrthographic: makeOrthographic,
|
||||
|
||||
11
ShadowEditor.Web/src/shader/vec3/angleTo.glsl
Normal file
11
ShadowEditor.Web/src/shader/vec3/angleTo.glsl
Normal file
@ -0,0 +1,11 @@
|
||||
#include <lengthSq>
|
||||
|
||||
/**
|
||||
* 求两个向量之间的夹角
|
||||
*/
|
||||
float angleTo(vec3 v1, vec3 v2) {
|
||||
float theta = dot(v1, v2) / sqrt(lengthSq(v1) * lengthSq(v2) );
|
||||
|
||||
// clamp, to handle numerical problems
|
||||
return acos(clamp(theta, -1.0, 1.0));
|
||||
}
|
||||
6
ShadowEditor.Web/src/shader/vec3/lengthSq.glsl
Normal file
6
ShadowEditor.Web/src/shader/vec3/lengthSq.glsl
Normal file
@ -0,0 +1,6 @@
|
||||
/**
|
||||
* 计算vec3长度的平方
|
||||
*/
|
||||
float lengthSq(vec3 v) {
|
||||
return v.x * v.x + v.y * v.y + v.z * v.z;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user