-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathCommonProgramsSetup.java
More file actions
86 lines (73 loc) · 3.44 KB
/
CommonProgramsSetup.java
File metadata and controls
86 lines (73 loc) · 3.44 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package lemon.evolution.setup;
import lemon.engine.math.Matrix;
import lemon.engine.math.Vector3D;
import lemon.engine.render.MatrixType;
import lemon.engine.texture.TextureBank;
import lemon.engine.toolbox.Color;
import lemon.evolution.util.CommonPrograms2D;
import lemon.evolution.util.CommonPrograms3D;
public class CommonProgramsSetup {
public static void setup3D(Matrix projectionMatrix) {
CommonPrograms3D.initAll();
CommonPrograms3D.COLOR.getShaderProgram().use(program -> {
program.loadMatrix(MatrixType.MODEL_MATRIX, Matrix.IDENTITY_4);
program.loadMatrix(MatrixType.VIEW_MATRIX, Matrix.IDENTITY_4);
program.loadMatrix(MatrixType.PROJECTION_MATRIX, projectionMatrix);
});
CommonPrograms3D.TEXTURE.getShaderProgram().use(program -> {
program.loadMatrix(MatrixType.MODEL_MATRIX, Matrix.IDENTITY_4);
program.loadMatrix(MatrixType.VIEW_MATRIX, Matrix.IDENTITY_4);
program.loadMatrix(MatrixType.PROJECTION_MATRIX, projectionMatrix);
program.loadInt("textureSampler", TextureBank.REUSE.getId());
});
CommonPrograms3D.CUBEMAP.getShaderProgram().use(program -> {
program.loadMatrix(MatrixType.VIEW_MATRIX, Matrix.IDENTITY_4);
program.loadMatrix(MatrixType.PROJECTION_MATRIX, projectionMatrix);
program.loadInt("cubemapSampler", TextureBank.SKYBOX.getId());
});
CommonPrograms3D.POST_PROCESSING.getShaderProgram().use(program -> {
program.loadInt("colorSampler", TextureBank.COLOR.getId());
program.loadInt("depthSampler", TextureBank.DEPTH.getId());
});
CommonPrograms3D.PARTICLE.getShaderProgram().use(program -> {
program.loadMatrix(MatrixType.VIEW_MATRIX, Matrix.IDENTITY_4);
program.loadMatrix(MatrixType.PROJECTION_MATRIX, projectionMatrix);
program.loadColor4f(Color.WHITE);
});
CommonPrograms3D.LIGHT.getShaderProgram().use(program -> {
program.loadMatrix(MatrixType.MODEL_MATRIX, Matrix.IDENTITY_4);
program.loadMatrix(MatrixType.VIEW_MATRIX, Matrix.IDENTITY_4);
program.loadMatrix(MatrixType.PROJECTION_MATRIX, projectionMatrix);
});
CommonPrograms3D.TERRAIN.getShaderProgram().use(program -> {
program.loadMatrix(MatrixType.MODEL_MATRIX, Matrix.IDENTITY_4);
program.loadMatrix(MatrixType.VIEW_MATRIX, Matrix.IDENTITY_4);
program.loadMatrix(MatrixType.PROJECTION_MATRIX, projectionMatrix);
program.loadInt("grassSampler", TextureBank.GRASS.getId());
program.loadInt("slopeSampler", TextureBank.SLOPE.getId());
program.loadInt("rockSampler", TextureBank.ROCK.getId());
program.loadInt("baseSampler", TextureBank.BASE.getId());
program.loadInt("snowSampler", TextureBank.SNOW.getId());
});
}
public static void setup2D(Matrix projectionMatrix) {
CommonPrograms2D.initAll();
CommonPrograms2D.COLOR.getShaderProgram().use(program -> {
program.loadMatrix(MatrixType.TRANSFORMATION_MATRIX, Matrix.IDENTITY_4);
program.loadMatrix(MatrixType.PROJECTION_MATRIX, projectionMatrix);
program.loadColor4f("filterColor", Color.WHITE);
});
CommonPrograms2D.LINE.getShaderProgram().use(program -> {
program.loadInt("index", 0);
program.loadInt("total", 0);
program.loadFloat("alpha", 1f);
});
CommonPrograms2D.TEXT.getShaderProgram().use(program -> {
program.loadMatrix(MatrixType.MODEL_MATRIX, Matrix.IDENTITY_4);
program.loadMatrix(MatrixType.VIEW_MATRIX, Matrix.IDENTITY_4);
program.loadMatrix(MatrixType.PROJECTION_MATRIX, projectionMatrix);
program.loadVector("color", Vector3D.ZERO);
program.loadInt("textureSampler", TextureBank.REUSE.getId());
});
}
}