yodaaaaaa
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
package chess.view.DDDrender.shader;
|
||||
|
||||
import org.joml.Matrix4f;
|
||||
|
||||
public class PieceShader extends ShaderProgram {
|
||||
|
||||
private static String vertexShader = """
|
||||
#version 330
|
||||
|
||||
layout(location = 0) in vec3 position;
|
||||
layout(location = 1) in vec2 uv;
|
||||
layout(location = 2) in vec3 normal;
|
||||
|
||||
uniform mat4 camMatrix;
|
||||
uniform mat4 modelTransform;
|
||||
|
||||
flat out vec3 pass_color;
|
||||
|
||||
void main(void){
|
||||
gl_Position = camMatrix * modelTransform * vec4(position, 1.0);
|
||||
pass_color = vec3(1, 0, 1);
|
||||
}
|
||||
""";
|
||||
|
||||
private static String fragmentShader = """
|
||||
#version 330
|
||||
|
||||
flat in vec3 pass_color;
|
||||
|
||||
out vec4 out_color;
|
||||
|
||||
void main(void){
|
||||
out_color = vec4(pass_color, 1.0);
|
||||
}
|
||||
""";
|
||||
|
||||
private int location_CamMatrix = 0;
|
||||
private int location_ModelTransform = 0;
|
||||
|
||||
public PieceShader() {
|
||||
|
||||
}
|
||||
|
||||
public void LoadShader() {
|
||||
super.LoadProgram(vertexShader, fragmentShader);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void GetAllUniformLocation() {
|
||||
location_CamMatrix = GetUniformLocation("camMatrix");
|
||||
location_ModelTransform = GetUniformLocation("modelTransform");
|
||||
}
|
||||
|
||||
public void SetCamMatrix(Matrix4f mat) {
|
||||
LoadMat4(location_CamMatrix, mat);
|
||||
}
|
||||
|
||||
public void setModelTransform(Matrix4f mat) {
|
||||
LoadMat4(location_ModelTransform, mat);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user