Skip to content

Commit

Permalink
Set cubemaps from biome (#324)
Browse files Browse the repository at this point in the history
Co-authored-by: Sheikah45 <[email protected]>
  • Loading branch information
BlackYps and Sheikah45 authored Mar 26, 2023
1 parent 2479a2d commit 9a4d07f
Show file tree
Hide file tree
Showing 16 changed files with 133 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.List;

import static com.faforever.neroxis.util.EndianSwapper.swap;
import static com.faforever.neroxis.util.jsquish.Squish.compressImage;
Expand Down Expand Up @@ -83,8 +84,9 @@ public static void exportSCMAP(Path folderPath, SCMap map) throws IOException {
writeStringNull(map.getTerrainShaderPath());
writeStringNull(map.getBackgroundPath());
writeStringNull(map.getSkyCubePath());
writeInt(map.getCubeMapCount());
for (CubeMap cubeMap : map.getCubeMaps()) {
List<CubeMap> cubeMaps = map.getBiome().terrainMaterials().getCubeMaps();
writeInt(cubeMaps.size());
for (CubeMap cubeMap : cubeMaps) {
writeStringNull(cubeMap.getName());
writeStringNull(cubeMap.getPath());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ public static SCMap importSCMAP(Path folderPath) throws IOException {
mapTerrainMaterials.getNormalScales()[i] = readFloat();
}

for (CubeMap cubeMap : cubeMaps) {
mapTerrainMaterials.getCubeMaps().add(cubeMap);
}

readInt(); // unknown
readInt(); // unknown

Expand Down Expand Up @@ -246,10 +250,6 @@ public static SCMap importSCMAP(Path folderPath) throws IOException {
for (DecalGroup decalGroup : decalGroups) {
map.addDecalGroup(decalGroup);
}
map.getCubeMaps().clear();
for (CubeMap cubeMap : cubeMaps) {
map.addCubeMap(cubeMap);
}
return map;
}

Expand Down
15 changes: 0 additions & 15 deletions shared/src/main/java/com/faforever/neroxis/map/SCMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ public class SCMap {
private final List<AIMarker> largeExpansionAIMarkers;
private final List<AIMarker> navalAreaAIMarkers;
private final List<AIMarker> navalRallyMarkers;
private final List<CubeMap> cubeMaps;
private byte[] compressedNormal;
private byte[] compressedShadows;
private float heightMapScale = 1f / 128f;
Expand Down Expand Up @@ -119,8 +118,6 @@ public SCMap(int size, Biome biome) {
navalAreaAIMarkers = new ArrayList<>();
navalRallyMarkers = new ArrayList<>();
waveGenerators = new ArrayList<>();
cubeMaps = new ArrayList<>();
cubeMaps.add(new CubeMap("<default>", "/textures/environment/defaultenvcube.dds"));
skyBox = new SkyBox();

generatePreview = true;
Expand Down Expand Up @@ -448,18 +445,6 @@ public void addWaveGenerator(WaveGenerator waveGenerator) {
waveGenerators.add(waveGenerator);
}

public int getCubeMapCount() {
return cubeMaps.size();
}

public CubeMap getCubemap(int i) {
return cubeMaps.get(i);
}

public void addCubeMap(CubeMap cubeMap) {
cubeMaps.add(cubeMap);
}

private void scaleMapContent(float contentScale) {
this.biome.waterSettings().setElevation(this.biome.waterSettings().getElevation() * contentScale);
this.biome.waterSettings().setElevationDeep(this.biome.waterSettings().getElevationDeep() * contentScale);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
package com.faforever.neroxis.util.serial.biome;

import com.dslplatform.json.CompiledJson;
import com.faforever.neroxis.map.CubeMap;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Data
@CompiledJson
public class TerrainMaterials {
// engine limitations - must stay 9 and 10 always
public static final int TERRAIN_TEXTURE_COUNT = 10;
public static final int TERRAIN_NORMAL_COUNT = 9;
private String name;
private List<CubeMap> cubeMaps = new ArrayList<>();
private String[] texturePaths = new String[TERRAIN_TEXTURE_COUNT];
private float[] textureScales = new float[TERRAIN_TEXTURE_COUNT];
private String[] normalPaths = new String[TERRAIN_NORMAL_COUNT];
Expand Down
10 changes: 10 additions & 0 deletions shared/src/main/resources/custom_biome/Brimstone/materials.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@
6.0
],
"name": "Brimstone",
"cubeMaps": [
{
"name": "<default>",
"path": "/textures/environment/SkyCube_RedRocks08a.dds"
},
{
"name": "<water>",
"path": "/textures/environment/SkyCube_RedRocks08a.dds"
}
],
"normalPaths": [
"/env/Tropical/Layers/Trop_GrassJung_normal.dds",
"/env/Evergreen/layers/grass000_normals.dds",
Expand Down
10 changes: 10 additions & 0 deletions shared/src/main/resources/custom_biome/Desert/materials.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"name": "Desert",
"cubeMaps": [
{
"name": "<default>",
"path": "/textures/environment/SkyCube_Desert02.dds"
},
{
"name": "<water>",
"path": "/textures/environment/SkyCube_Desert02a.dds"
}
],
"texturePaths": [
"/env/Desert/Layers/Des_SandDark02_albedo.dds",
"/env/Desert/Layers/Des_SandMed02_albedo.dds",
Expand Down
10 changes: 10 additions & 0 deletions shared/src/main/resources/custom_biome/EarlyAutumn/materials.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@
6.0
],
"name": "EarlyAutumn",
"cubeMaps": [
{
"name": "<default>",
"path": "/textures/environment/DefaultEnvCube.dds"
},
{
"name": "<water>",
"path": "/textures/environment/DefaultEnvCube_mirrored.dds"
}
],
"normalPaths": [
"/env/Tropical/Layers/Trop_GrassJung_normal.dds",
"/env/evergreen2/layers/eg_grass001_normal.dds",
Expand Down
10 changes: 10 additions & 0 deletions shared/src/main/resources/custom_biome/Frithen/materials.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"name": "Frithen",
"cubeMaps": [
{
"name": "<default>",
"path": "/textures/environment/SkyCube_Tundra04a.dds"
},
{
"name": "<water>",
"path": "/textures/environment/SkyCube_Tundra04a.dds"
}
],
"texturePaths": [
"/env/Tundra/Layers/Tund_Rock03_albedo.DDS",
"/env/Tundra/Layers/Tund_Ice001_albedo.DDS",
Expand Down
10 changes: 10 additions & 0 deletions shared/src/main/resources/custom_biome/Loki/materials.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"name": "Loki",
"cubeMaps": [
{
"name": "<default>",
"path": "/textures/environment/SkyCube_TropicalOp06.dds"
},
{
"name": "<water>",
"path": "/textures/environment/SkyCube_TropicalOp06a.dds"
}
],
"texturePaths": [
"/env/Evergreen2/Layers/EvGrass007_albedo.dds",
"/env/Evergreen2/Layers/EvGrass010a_albedo.dds",
Expand Down
10 changes: 10 additions & 0 deletions shared/src/main/resources/custom_biome/Mars/materials.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"name": "Mars",
"cubeMaps": [
{
"name": "<default>",
"path": "/textures/environment/SkyCube_Desert02.dds"
},
{
"name": "<water>",
"path": "/textures/environment/SkyCube_Desert02a.dds"
}
],
"texturePaths": [
"/env/Desert/Layers/Des_Gravel_albedo.dds",
"/env/Desert/Layers/Des_Rock_albedo.dds",
Expand Down
10 changes: 10 additions & 0 deletions shared/src/main/resources/custom_biome/Moonlight/materials.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"name": "Moonlight",
"cubeMaps": [
{
"name": "<default>",
"path": "/textures/environment/SkyCube_RedRocks05.dds"
},
{
"name": "<water>",
"path": "/textures/environment/SkyCube_RedRocks05a.dds"
}
],
"texturePaths": [
"/env/Red Barrens/Layers/RB_RedMud_albedo.dds",
"/env/Red Barrens/Layers/RB_Cracked02_albedo.DDS",
Expand Down
10 changes: 10 additions & 0 deletions shared/src/main/resources/custom_biome/Prayer/materials.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"name": "Prayer",
"cubeMaps": [
{
"name": "<default>",
"path": "/textures/environment/DefaultEnvCube.dds"
},
{
"name": "<water>",
"path": "/textures/environment/DefaultEnvCube_mirrored.dds"
}
],
"texturePaths": [
"/env/Evergreen2/Layers/EvTrans03_albedo.dds",
"/env/Evergreen2/Layers/EvTrans03_albedo.dds",
Expand Down
10 changes: 10 additions & 0 deletions shared/src/main/resources/custom_biome/Stones/materials.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"name": "Stones",
"cubeMaps": [
{
"name": "<default>",
"path": "/textures/environment/SkyCube_Desert03a.dds"
},
{
"name": "<water>",
"path": "/textures/environment/SkyCube_Desert03a.dds"
}
],
"texturePaths": [
"/env/paradise/layers/grass001_albedo.dds",
"/env/paradise/layers/Rock001_albedo.dds",
Expand Down
10 changes: 10 additions & 0 deletions shared/src/main/resources/custom_biome/Syrtis/materials.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"name": "Syrtis",
"cubeMaps": [
{
"name": "<default>",
"path": "/textures/environment/SkyCube_RedRocks06.dds"
},
{
"name": "<water>",
"path": "/textures/environment/SkyCube_RedRocks06.dds"
}
],
"texturePaths": [
"/env/Red Barrens/Layers/RB_RedMud_albedo.dds",
"/env/Red Barrens/Layers/RB_Sandwet.dds",
Expand Down
10 changes: 10 additions & 0 deletions shared/src/main/resources/custom_biome/WindingRiver/materials.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@
6.0
],
"name": "WindingRiver",
"cubeMaps": [
{
"name": "<default>",
"path": "/textures/environment/DefaultEnvCube.dds"
},
{
"name": "<water>",
"path": "/textures/environment/DefaultEnvCube_mirrored.dds"
}
],
"normalPaths": [
"/env/Tropical/Layers/Trop_GrassJung_normal.dds",
"/env/Evergreen/layers/grass000_normals.dds",
Expand Down
10 changes: 10 additions & 0 deletions shared/src/main/resources/custom_biome/Wonder/materials.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"name": "Wonder",
"cubeMaps": [
{
"name": "<default>",
"path": "/textures/environment/DefaultEnvCube.dds"
},
{
"name": "<water>",
"path": "/textures/environment/DefaultEnvCube_mirrored.dds"
}
],
"texturePaths": [
"/env/Evergreen2/Layers/Eg_Dirt002_albedo.dds",
"/env/Evergreen2/Layers/EvGrass009_albedo.dds",
Expand Down

0 comments on commit 9a4d07f

Please sign in to comment.