Initial commit
53
src/main/resources/assets/shaders/Shape.fragment.glsl
Normal file
@@ -0,0 +1,53 @@
|
||||
#version 120
|
||||
|
||||
varying vec3 varyingColorMultiplier;
|
||||
varying vec2 varyingTextureCoords;
|
||||
varying vec3 varyingNormals;
|
||||
|
||||
uniform sampler2D textureSlot;
|
||||
uniform vec2 textureStart;
|
||||
uniform vec2 textureSize;
|
||||
|
||||
void applyTexture() {
|
||||
gl_FragColor = texture2D(
|
||||
textureSlot,
|
||||
vec2(
|
||||
varyingTextureCoords[0] * textureSize[0] + textureStart[0],
|
||||
varyingTextureCoords[1] * textureSize[1] + textureStart[1]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
void multiply(inout vec4 vector, float scalar) {
|
||||
vector.x *= scalar;
|
||||
vector.y *= scalar;
|
||||
vector.z *= scalar;
|
||||
vector.w *= scalar;
|
||||
}
|
||||
|
||||
void linearMultiply(inout vec4 vector, vec4 scalars) {
|
||||
vector.x *= scalars.x;
|
||||
vector.y *= scalars.y;
|
||||
vector.z *= scalars.z;
|
||||
vector.w *= scalars.w;
|
||||
}
|
||||
|
||||
void applyColorMultiplier() {
|
||||
linearMultiply(gl_FragColor, vec4(varyingColorMultiplier, 1.0));
|
||||
}
|
||||
|
||||
void applyShading() {
|
||||
vec3 light = normalize(vec3(0.5, 1.0, 0.2));
|
||||
vec3 normal = varyingNormals;
|
||||
|
||||
float angleCos = dot(normal, light);
|
||||
float lightness = (angleCos + 1.5) / 2;
|
||||
|
||||
linearMultiply(gl_FragColor, vec4(lightness.xxx, 1.0));
|
||||
}
|
||||
|
||||
void applyAlpha() {
|
||||
if (gl_FragColor.w < 0.01) {
|
||||
discard;
|
||||
}
|
||||
}
|
27
src/main/resources/assets/shaders/Shape.vertex.glsl
Normal file
@@ -0,0 +1,27 @@
|
||||
#version 120
|
||||
|
||||
attribute vec3 inputPositions;
|
||||
|
||||
attribute vec3 inputColorMultiplier;
|
||||
varying vec3 varyingColorMultiplier;
|
||||
|
||||
attribute vec2 inputTextureCoords;
|
||||
varying vec2 varyingTextureCoords;
|
||||
|
||||
attribute vec3 inputNormals;
|
||||
varying vec3 varyingNormals;
|
||||
|
||||
uniform mat4 worldTransform;
|
||||
uniform mat4 finalTransform;
|
||||
|
||||
vec4 applyFinalTransform(vec4 vector) {
|
||||
return finalTransform * vector;
|
||||
}
|
||||
|
||||
void transferToFragment() {
|
||||
varyingColorMultiplier = inputColorMultiplier;
|
||||
varyingTextureCoords = inputTextureCoords;
|
||||
|
||||
mat3 worldRotation = mat3(worldTransform);
|
||||
varyingNormals = normalize(worldRotation * inputNormals);
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
#version 120
|
||||
|
||||
void main(void) {
|
||||
applyTexture();
|
||||
applyColorMultiplier();
|
||||
applyShading();
|
||||
applyAlpha();
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
#version 120
|
||||
|
||||
void main(void) {
|
||||
gl_Position = applyFinalTransform(vec4(inputPositions, 1.0));
|
||||
transferToFragment();
|
||||
}
|
BIN
src/main/resources/assets/textures/compass.png
Normal file
After Width: | Height: | Size: 256 B |
BIN
src/main/resources/assets/textures/glass.png
Normal file
After Width: | Height: | Size: 644 B |
BIN
src/main/resources/assets/textures/glass_clear.png
Normal file
After Width: | Height: | Size: 5.3 KiB |
BIN
src/main/resources/assets/textures/grass_bottom.png
Normal file
After Width: | Height: | Size: 816 B |
BIN
src/main/resources/assets/textures/grass_side.png
Normal file
After Width: | Height: | Size: 752 B |
BIN
src/main/resources/assets/textures/grass_top.png
Normal file
After Width: | Height: | Size: 792 B |
BIN
src/main/resources/assets/textures/side_east.png
Normal file
After Width: | Height: | Size: 588 B |
BIN
src/main/resources/assets/textures/side_north.png
Normal file
After Width: | Height: | Size: 609 B |
BIN
src/main/resources/assets/textures/side_south.png
Normal file
After Width: | Height: | Size: 591 B |
BIN
src/main/resources/assets/textures/side_west.png
Normal file
After Width: | Height: | Size: 604 B |
BIN
src/main/resources/assets/textures/stone.png
Normal file
After Width: | Height: | Size: 1.2 KiB |