Skip to content

Commit

Permalink
Improve water, lighting and decals (#337)
Browse files Browse the repository at this point in the history
  • Loading branch information
BlackYps authored Apr 22, 2023
1 parent 9a4d07f commit e13b8fa
Show file tree
Hide file tree
Showing 35 changed files with 655 additions and 606 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class BasicTextureGenerator extends TextureGenerator {
protected FloatMask accentSlopesTexture;
protected FloatMask accentPlateauTexture;
protected FloatMask slopesTexture;
protected FloatMask steepHillsTexture;
protected FloatMask underWaterTexture;
protected FloatMask rockTexture;
protected FloatMask accentRockTexture;
protected IntegerMask terrainType;
Expand All @@ -28,10 +28,16 @@ public class BasicTextureGenerator extends TextureGenerator {
protected void setupTexturePipeline() {
BooleanMask flat = slope.copyAsBooleanMask(.05f).invert();
BooleanMask slopes = slope.copyAsBooleanMask(.15f);
BooleanMask accentSlopes = slope.copyAsBooleanMask(.55f).invert().subtract(flat);
BooleanMask steepHills = slope.copyAsBooleanMask(.55f);
BooleanMask accentSlopes = slope.copyAsBooleanMask(.75f).invert().subtract(flat);
BooleanMask rock = slope.copyAsBooleanMask(.75f);
BooleanMask accentRock = slope.copyAsBooleanMask(.75f).inflate(2f);
float abyssDepth = generatorParameters.biome().waterSettings().getElevation() -
generatorParameters.biome().waterSettings().getElevationAbyss();
FloatMask scaledWaterDepth = heightmap.copy()
.subtract(generatorParameters.biome().waterSettings().getElevation())
.multiply(-1f)
.divide(abyssDepth)
.clampMin(0f);

BooleanMask realWater = realLand.copy().invert();
BooleanMask shadowsInWater = shadowsMask.copy().multiply(realWater.copy().setSize(512));
Expand Down Expand Up @@ -59,12 +65,10 @@ protected void setupTexturePipeline() {
.clampMax(1f)
.setToValue(accentSlopes.copy().invert(), 0f)
.blur(16);
steepHillsTexture.setSize(textureSize)
.addPerlinNoise(mapSize / 8, 1f)
.addGaussianNoise(.05f)
underWaterTexture.init(realWater.deflate(1), 0f, .7f)
.add(scaledWaterDepth.multiply(.3f))
.clampMax(1f)
.setToValue(steepHills.copy().invert(), 0f)
.blur(8);
.blur(1);
waterBeachTexture.init(realWater.inflate(12).subtract(realPlateaus), 0f, 1f).blur(12);
rockTexture.init(rock, 0f, 1f).blur(4).add(rock, 1f).blur(2).clampMax(1f);
accentRockTexture.setSize(textureSize)
Expand All @@ -74,28 +78,26 @@ protected void setupTexturePipeline() {
.setToValue(accentRock.copy().invert(), 0f)
.blur(2);
texturesLowMask.setComponents(accentGroundTexture, accentPlateauTexture, slopesTexture, accentSlopesTexture);
texturesHighMask.setComponents(steepHillsTexture, waterBeachTexture, rockTexture, accentRockTexture);
texturesHighMask.setComponents(waterBeachTexture, underWaterTexture, rockTexture, accentRockTexture);

setupTerrainType(mapSize);
}

protected void setupTerrainType(int mapSize) {
terrainType.setSize(mapSize);
BooleanMask realWater = realLand.copy().invert().setSize(mapSize);

Integer[] terrainTypes = map.getBiome().terrainMaterials().getTerrainTypes();
terrainType.add(terrainTypes[0])
.setToValue(accentGroundTexture.setSize(mapSize).copyAsBooleanMask(.5f), terrainTypes[1])
.setToValue(accentPlateauTexture.setSize(mapSize).copyAsBooleanMask(.5f), terrainTypes[2])
.setToValue(slopesTexture.setSize(mapSize).copyAsBooleanMask(.3f), terrainTypes[3])
.setToValue(accentSlopesTexture.setSize(mapSize).copyAsBooleanMask(.3f), terrainTypes[4])
.setToValue(steepHillsTexture.setSize(mapSize).copyAsBooleanMask(.5f), terrainTypes[5])
.setToValue(waterBeachTexture.setSize(mapSize).copyAsBooleanMask(.5f), terrainTypes[6])
.setToValue(waterBeachTexture.setSize(mapSize).copyAsBooleanMask(.5f), terrainTypes[5])
// We need to change the order here, otherwise accentRock will overwrite the rock texture completely
.setToValue(accentRockTexture.setSize(mapSize).copyAsBooleanMask(.35f), terrainTypes[8])
.setToValue(rockTexture.setSize(mapSize).copyAsBooleanMask(.55f), terrainTypes[7])
.setToValue(realWater, terrainTypes[9])
.setToValue(realWater.deflate(20), terrainTypes[10]);
.setToValue(accentRockTexture.setSize(mapSize).copyAsBooleanMask(.35f), terrainTypes[7])
.setToValue(rockTexture.setSize(mapSize).copyAsBooleanMask(.55f), terrainTypes[6])
.setToValue(underWaterTexture.setSize(mapSize).copyAsBooleanMask(.7f), terrainTypes[8])
.setToValue(underWaterTexture.setSize(mapSize).copyAsBooleanMask(.8f), terrainTypes[9]);
}

@Override
Expand All @@ -110,7 +112,7 @@ public void initialize(SCMap map, long seed, GeneratorParameters generatorParame
accentSlopesTexture = new FloatMask(1, random.nextLong(), symmetrySettings, "accentSlopesTexture", true);
accentPlateauTexture = new FloatMask(1, random.nextLong(), symmetrySettings, "accentPlateauTexture", true);
slopesTexture = new FloatMask(1, random.nextLong(), symmetrySettings, "slopesTexture", true);
steepHillsTexture = new FloatMask(1, random.nextLong(), symmetrySettings, "steepHillsTexture", true);
underWaterTexture = new FloatMask(1, random.nextLong(), symmetrySettings, "underWaterTexture", true);
rockTexture = new FloatMask(1, random.nextLong(), symmetrySettings, "rockTexture", true);
accentRockTexture = new FloatMask(1, random.nextLong(), symmetrySettings, "accentRockTexture", true);
terrainType = new IntegerMask(1, random.nextLong(), symmetrySettings, "terrainType", true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ private static BufferedImage shadeLayer(BufferedImage image, SCMap map, FloatMas
}

private static BufferedImage getWaterLayer(SCMap map, FloatMask reflectance, FloatMask heightmap) {
Color shallowColor = new Color(134, 233, 233);
Color abyssColor = new Color(35, 49, 162);
Color shallowColor = new Color(53, 85, 117);
Color abyssColor = new Color(60, 67, 137);
LightingSettings lightingSettings = map.getBiome().lightingSettings();
WaterSettings waterSettings = map.getBiome().waterSettings();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@
@Data
@CompiledJson
public class TerrainMaterials {
/* texture slots:
ground
groundAccent
plateauAccent
slopes
slopesAccent
beach
underWater
rock
rockAccent
macroTexture
*/

// engine limitations - must stay 9 and 10 always
public static final int TERRAIN_TEXTURE_COUNT = 10;
public static final int TERRAIN_NORMAL_COUNT = 9;
Expand All @@ -26,7 +39,6 @@ public class TerrainMaterials {
1, // plateauAccent
1, // slopes
1, // slopesAccent
1, // steepHills
40, // beach
150, // rock
150, // rockAccent
Expand Down
Original file line number Diff line number Diff line change
@@ -1,70 +1,70 @@
{
"elevationAbyss": 10.0,
"elevationAbyss": 3.0,
"fresnelPower": 1.5,
"waveTextures": [
{
"normalRepeat": 9.0E-4,
"normalMovement": {
"y": -0.95,
"x": 0.5
},
"texPath": "/textures/engine/waves.dds"
},
{
"normalRepeat": 0.009,
"normalMovement": {
"y": -0.095,
"x": 0.05
},
"texPath": "/textures/engine/waves.dds"
},
{
"normalRepeat": 0.05,
"normalMovement": {
"y": 0.03,
"x": 0.01
},
"texPath": "/textures/engine/waves.dds"
},
{
"normalRepeat": 0.5,
"normalMovement": {
"y": 9.0E-4,
"x": 5.0E-4
},
"texPath": "/textures/engine/waves.dds"
}
],
"elevationDeep": 20.0,
"sunGlow": 0.1,
"skyReflection": 1.5,
"sunStrength": 10.0,
"texPathWaterRamp": "/textures/engine/waterramp.dds",
"texPathWaterRamp": "/textures/engine/waterramp_redrock03.dds",
"colorLerp": {
"y": 0.119,
"y": 0.0,
"x": 0.064
},
"surfaceColor": {
"z": 1.5,
"y": 0.7,
"x": 0.0
"z": 0.65,
"y": 0.55,
"x": 0.46
},
"sunShininess": 50.0,
"sunColor": {
"z": 0.33864275,
"y": 0.47409984,
"x": 0.81274265
"z": 0.77,
"y": 0.86,
"x": 0.94
},
"refractionScale": 0.375,
"waterPresent": true,
"unitReflection": 0.5,
"fresnelBias": 0.15,
"sunReflection": 5.0,
"texPathCubemap": "/textures/engine/waterCubemap.dds",
"sunReflection": 3.3,
"texPathCubemap": "/textures/environment/SkyCube_RedRocks08a.dds",
"sunDirection": {
"z": 0.2518569,
"y": -0.9626309,
"x": 0.09954818
},
"elevation": 25.0
"elevation": 25.0,
"waveTextures": [
{
"normalRepeat": 0.006,
"normalMovement": {
"y": 0.0229813,
"x": 0.0192836
},
"texPath": "/textures/engine/waves000.dds"
},
{
"normalRepeat": 0.012,
"normalMovement": {
"y": 0.0025,
"x": 0.00433013
},
"texPath": "/textures/engine/waves.dds"
},
{
"normalRepeat": 0.05,
"normalMovement": {
"y": 0.00751754,
"x": 0.00273616
},
"texPath": "/textures/engine/waves001.dds"
},
{
"normalRepeat": 0.5,
"normalMovement": {
"y": 0.001,
"x": 0.0
},
"texPath": "/textures/engine/waves001.dds"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
12.25,
13.75,
13.75,
9.5,
4.0,
4.0,
1.0,
6.0
Expand All @@ -38,7 +38,7 @@
"/env/Evergreen2/Layers/EG_Grass001_normal.dds",
"/env/red barrens/layers/rb_cracked02_normal.dds",
"/env/red barrens/layers/rb_sand_normal.dds",
"/env/Evergreen2/Layers/EG_Gravel_normal.DDS",
"/env/Desert/Layers/Des_sandLight_normal.dds",
"/env/Desert/Layers/Des_sandLight_normal.dds",
"/env/red barrens/layers/rb_rock09_normal.dds",
"/env/red barrens/layers/rb_rock06_normal.dds"
Expand All @@ -49,7 +49,7 @@
"/env/ancient-earth/layers/sandlight002_maroon_tint_darker_albedo.dds",
"/env/red barrens/layers/rb_cracked_albedo.dds",
"/env/red barrens/layers/rb_sandwet01_albedo.dds",
"/env/red barrens/layers/rb_gravel01_albedo.dds",
"/env/red barrens/layers/rb_sandwet_albedo.dds",
"/env/red barrens/layers/rb_sandwet_albedo.dds",
"/env/red barrens/layers/rb_rock09_albedo.dds",
"/env/red barrens/layers/rb_rock07_albedo.dds",
Expand All @@ -61,7 +61,7 @@
12.25,
7.25,
14.0,
19.5,
20.0,
20.0,
11.0,
12.0,
Expand All @@ -73,7 +73,6 @@
6,
5,
5,
5,
6,
154,
154,
Expand Down
14 changes: 7 additions & 7 deletions shared/src/main/resources/custom_biome/Desert/Light.scmlighting
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"bloom" : 0.08,
"fogStart" : 0.0,
"sunDirection" : {
"z" : 1.6391277E-7,
"z" : 0.1263912,
"x" : 0.7083398,
"y" : 0.7058716
},
Expand All @@ -14,14 +14,14 @@
},
"fogEnd" : 2000.0,
"sunColor" : {
"z" : 1.82,
"x" : 1.71,
"y" : 1.77
"z" : 1.50,
"x" : 1.39,
"y" : 1.45
},
"sunAmbience" : {
"z" : 0.19,
"x" : 0.19,
"y" : 0.19
"z" : 0.65,
"x" : 0.65,
"y" : 0.65
},
"specularColor" : {
"z" : 0.0,
Expand Down
Loading

0 comments on commit e13b8fa

Please sign in to comment.