Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/lemon/engine/texture/TextureBank.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

public enum TextureBank {
REUSE(0), COLOR(1), DEPTH(2), SKYBOX(3),
GRASS(4), SLOPE(5), ROCK(6), BASE(7);
GRASS(4), SLOPE(5), ROCK(6), BASE(7), SNOW(8);
private final int id;

private TextureBank(int id) {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/lemon/evolution/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ public float getProgress() {
TextureBank.GRASS, "/res/grass.png",
TextureBank.SLOPE, "/res/slope.png",
TextureBank.ROCK, "/res/rock.png",
TextureBank.BASE, "/res/base.png"
TextureBank.BASE, "/res/base.png",
TextureBank.SNOW, "/res/snow.png"
).forEach((textureBank, path) -> {
textureBank.bind(() -> {
var texture = new Texture();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public static void setup3D(Matrix projectionMatrix) {
program.loadInt("slopeSampler", TextureBank.SLOPE.getId());
program.loadInt("rockSampler", TextureBank.ROCK.getId());
program.loadInt("baseSampler", TextureBank.BASE.getId());
program.loadInt("snowSampler", TextureBank.SNOW.getId());
});
}

Expand Down
Binary file added src/main/resources/res/beauty.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/res/snow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 8 additions & 1 deletion src/main/resources/shaders/terrainFragmentShader
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ uniform sampler2D grassSampler;
uniform sampler2D slopeSampler;
uniform sampler2D rockSampler;
uniform sampler2D baseSampler;
uniform sampler2D snowSampler;

vec4 getTriplanarTexturing(in sampler2D sampler, in vec3 textureCoords, in vec3 weights) {
return texture(sampler, textureCoords.yz) * weights.x +
Expand All @@ -24,16 +25,22 @@ void main(void) {
vec4 slopeColor = getTriplanarTexturing(slopeSampler, passTextureCoords, blendWeights);
vec4 rockColor = getTriplanarTexturing(rockSampler, passTextureCoords, blendWeights);
vec4 baseColor = getTriplanarTexturing(baseSampler, passTextureCoords, blendWeights);
vec4 snowColor = getTriplanarTexturing(snowSampler, passTextureCoords, blendWeights);

float slope = 1 - passNormal.y;

if (slope < 0.2) {
outColor = mix(grassColor, slopeColor, slope / 0.2);
if (passTextureCoords.x < 0) {
outColor = mix(grassColor, slopeColor, slope / 0.2);
} else {
outColor = mix(snowColor, slopeColor, slope / 0.2);
}
} else if (slope < 0.7) {
outColor = mix(slopeColor, rockColor, (slope - 0.2) / 0.5);
} else if (slope < 1.5) {
outColor = mix(rockColor, baseColor, (slope - 0.7) / 0.8);
} else {
outColor = baseColor;
}

}