-
Notifications
You must be signed in to change notification settings - Fork 4
/
BlockEndShader.ts
60 lines (50 loc) · 1.65 KB
/
BlockEndShader.ts
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import {VertexAttributeEnum} from '../../../foundation/definitions/VertexAttribute';
import { GLSLShader } from '../GLSLShader';
import {CompositionTypeEnum} from '../../../foundation/definitions/CompositionType';
import {ShaderSocket} from '../../../foundation/materials/core/AbstractMaterialContent';
import { AttributeNames } from '../../types/CommonTypes';
export class BlockEndShader extends GLSLShader {
constructor(
private __functionName: string,
private __valueInputs: ShaderSocket[],
private __valueOutputs: ShaderSocket[]
) {
super();
}
get vertexShaderDefinitions() {
let funcStr = `void ${this.__functionName}(`;
for (let i = 0; i < this.__valueInputs.length; i++) {
const input = this.__valueInputs[i];
const type = input.compositionType.getGlslStr(input.componentType);
funcStr += `
in ${type} value${i},`;
}
for (let i = 0; i < this.__valueOutputs.length; i++) {
const output = this.__valueOutputs[i];
const type = output.compositionType.getGlslStr(output.componentType);
funcStr +=
`
out ${type} outValue${i}` +
(i === this.__valueOutputs.length - 1 ? '' : ',');
}
funcStr += ') {\n';
for (let i = 0; i < this.__valueOutputs.length; i++) {
funcStr += `
outValue${i} = value${i};\n`;
}
funcStr += '}';
return funcStr;
}
get pixelShaderDefinitions() {
return this.vertexShaderDefinitions;
}
get attributeNames(): AttributeNames {
return [];
}
get attributeSemantics(): Array<VertexAttributeEnum> {
return [];
}
get attributeCompositions(): Array<CompositionTypeEnum> {
return [];
}
}