-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathDepthPass.js
32 lines (32 loc) · 1.08 KB
/
DepthPass.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import Enum from './Enum';
import { mat4 } from 'gl-matrix';
import VertShader from './glsl/depthpass.vert';
import FragShader from './glsl/depthpass.frag';
import DepthFormat from './DepthFormatEnum';
import ShaderPrecision from './ShaderPrecision';
import MaterialPass from './MaterialPass';
const M4 = mat4.create();
export default class DepthPass extends MaterialPass {
constructor(gl) {
super({
uid: 'stddepth',
vert: VertShader(),
frag: FragShader(),
});
this.depthFormat = this.inputs.add(new Enum('depthFormat', DepthFormat));
this.precision = this.inputs.add(new ShaderPrecision('highp'));
}
setLightSetup(setup) {
this.depthFormat.proxy(setup === null || setup === void 0 ? void 0 : setup.depthFormat);
}
prepare(prg, node, camera) {
if (prg.uMVP) {
camera.modelViewProjectionMatrix(M4, node._wmatrix);
prg.uMVP(M4);
}
if (prg.uWorldMatrix)
prg.uWorldMatrix(node._wmatrix);
if (prg.uVP)
prg.uVP(camera._viewProj);
}
}