Skip to content

Commit

Permalink
Merge pull request #123 from JamesTKhan/terrain-cleanup
Browse files Browse the repository at this point in the history
Terrain Cleanup and Terrain Material
  • Loading branch information
JamesTKhan authored Oct 28, 2022
2 parents 8356c0a + 619eb17 commit 9ea467d
Show file tree
Hide file tree
Showing 12 changed files with 142 additions and 707 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import com.mbrlabs.mundus.commons.terrain.SplatTexture;
import com.mbrlabs.mundus.commons.terrain.Terrain;
import com.mbrlabs.mundus.commons.terrain.TerrainLoader;
import com.mbrlabs.mundus.commons.terrain.TerrainTexture;
import com.mbrlabs.mundus.commons.terrain.TerrainMaterial;

import java.util.Map;

Expand Down Expand Up @@ -308,63 +308,63 @@ public void resolveDependencies(Map<String, Asset> assets) {

@Override
public void applyDependencies() {
TerrainTexture terrainTexture = terrain.getTerrainTexture();
TerrainMaterial terrainMaterial = terrain.getTerrainTexture();

if (splatmap == null) {
terrainTexture.setSplatmap(null);
terrainMaterial.setSplatmap(null);
} else {
terrainTexture.setSplatmap(new SplatMap(splatmap));
terrainMaterial.setSplatmap(new SplatMap(splatmap));
}
if (splatBase == null) {
terrainTexture.removeTexture(SplatTexture.Channel.BASE);
terrainMaterial.removeTexture(SplatTexture.Channel.BASE);
} else {
terrainTexture.setSplatTexture(new SplatTexture(SplatTexture.Channel.BASE, splatBase));
terrainMaterial.setSplatTexture(new SplatTexture(SplatTexture.Channel.BASE, splatBase));
}
if (splatR == null) {
terrainTexture.removeTexture(SplatTexture.Channel.R);
terrainMaterial.removeTexture(SplatTexture.Channel.R);
} else {
terrainTexture.setSplatTexture(new SplatTexture(SplatTexture.Channel.R, splatR));
terrainMaterial.setSplatTexture(new SplatTexture(SplatTexture.Channel.R, splatR));
}
if (splatG == null) {
terrainTexture.removeTexture(SplatTexture.Channel.G);
terrainMaterial.removeTexture(SplatTexture.Channel.G);
} else {
terrainTexture.setSplatTexture(new SplatTexture(SplatTexture.Channel.G, splatG));
terrainMaterial.setSplatTexture(new SplatTexture(SplatTexture.Channel.G, splatG));
}
if (splatB == null) {
terrainTexture.removeTexture(SplatTexture.Channel.B);
terrainMaterial.removeTexture(SplatTexture.Channel.B);
} else {
terrainTexture.setSplatTexture(new SplatTexture(SplatTexture.Channel.B, splatB));
terrainMaterial.setSplatTexture(new SplatTexture(SplatTexture.Channel.B, splatB));
}
if (splatA == null) {
terrainTexture.removeTexture(SplatTexture.Channel.A);
terrainMaterial.removeTexture(SplatTexture.Channel.A);
} else {
terrainTexture.setSplatTexture(new SplatTexture(SplatTexture.Channel.A, splatA));
terrainMaterial.setSplatTexture(new SplatTexture(SplatTexture.Channel.A, splatA));
}

if (splatBaseNormal == null) {
terrainTexture.removeNormalTexture(SplatTexture.Channel.BASE);
terrainMaterial.removeNormalTexture(SplatTexture.Channel.BASE);
} else {
terrainTexture.setSplatNormalTexture(new SplatTexture(SplatTexture.Channel.BASE, splatBaseNormal));
terrainMaterial.setSplatNormalTexture(new SplatTexture(SplatTexture.Channel.BASE, splatBaseNormal));
}
if (splatRNormal == null) {
terrainTexture.removeNormalTexture(SplatTexture.Channel.R);
terrainMaterial.removeNormalTexture(SplatTexture.Channel.R);
} else {
terrainTexture.setSplatNormalTexture(new SplatTexture(SplatTexture.Channel.R, splatRNormal));
terrainMaterial.setSplatNormalTexture(new SplatTexture(SplatTexture.Channel.R, splatRNormal));
}
if (splatGNormal == null) {
terrainTexture.removeNormalTexture(SplatTexture.Channel.G);
terrainMaterial.removeNormalTexture(SplatTexture.Channel.G);
} else {
terrainTexture.setSplatNormalTexture(new SplatTexture(SplatTexture.Channel.G, splatGNormal));
terrainMaterial.setSplatNormalTexture(new SplatTexture(SplatTexture.Channel.G, splatGNormal));
}
if (splatBNormal == null) {
terrainTexture.removeNormalTexture(SplatTexture.Channel.B);
terrainMaterial.removeNormalTexture(SplatTexture.Channel.B);
} else {
terrainTexture.setSplatNormalTexture(new SplatTexture(SplatTexture.Channel.B, splatBNormal));
terrainMaterial.setSplatNormalTexture(new SplatTexture(SplatTexture.Channel.B, splatBNormal));
}
if (splatANormal == null) {
terrainTexture.removeNormalTexture(SplatTexture.Channel.A);
terrainMaterial.removeNormalTexture(SplatTexture.Channel.A);
} else {
terrainTexture.setSplatNormalTexture(new SplatTexture(SplatTexture.Channel.A, splatANormal));
terrainMaterial.setSplatNormalTexture(new SplatTexture(SplatTexture.Channel.A, splatANormal));
}

terrain.update();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g3d.Renderable;
import com.badlogic.gdx.graphics.g3d.Shader;
import com.mbrlabs.mundus.commons.terrain.attributes.TerrainTextureAttribute;
import com.mbrlabs.mundus.commons.terrain.attributes.TerrainMaterialAttribute;
import com.mbrlabs.mundus.commons.water.attributes.WaterMaterialAttribute;
import net.mgsx.gltf.scene3d.shaders.PBRShader;
import net.mgsx.gltf.scene3d.shaders.PBRShaderConfig;
Expand All @@ -21,7 +21,7 @@ public MundusPBRShaderProvider(PBRShaderConfig config) {

@Override
protected Shader createShader(Renderable renderable) {
if (renderable.material.has(TerrainTextureAttribute.ATTRIBUTE_SPLAT0))
if (renderable.material.has(TerrainMaterialAttribute.TerrainMaterial))
return createTerrainShader(renderable);
else if (renderable.material.has(WaterMaterialAttribute.WaterMaterial))
return createWaterShader(renderable);
Expand Down
222 changes: 0 additions & 222 deletions commons/src/main/com/mbrlabs/mundus/commons/shaders/TerrainShader.java

This file was deleted.

Loading

0 comments on commit 9ea467d

Please sign in to comment.