Reflective planet water

This commit is contained in:
Anuken
2020-04-02 12:32:55 -04:00
parent 19239a6890
commit a26cd46a7e
7 changed files with 22 additions and 5 deletions

View File

@@ -133,6 +133,7 @@ public class Blocks implements ContentList{
statusDuration = 120f;
drownTime = 140f;
cacheLayer = CacheLayer.water;
albedo = 0.5f;
}};
water = new Floor("water"){{
@@ -143,6 +144,7 @@ public class Blocks implements ContentList{
liquidDrop = Liquids.water;
isLiquid = true;
cacheLayer = CacheLayer.water;
albedo = 0.5f;
}};
taintedWater = new Floor("tainted-water"){{
@@ -154,6 +156,7 @@ public class Blocks implements ContentList{
liquidDrop = Liquids.water;
isLiquid = true;
cacheLayer = CacheLayer.water;
albedo = 0.5f;
}};
darksandTaintedWater = new Floor("darksand-tainted-water"){{
@@ -164,6 +167,7 @@ public class Blocks implements ContentList{
liquidDrop = Liquids.water;
isLiquid = true;
cacheLayer = CacheLayer.water;
albedo = 0.5f;
}};
sandWater = new Floor("sand-water"){{
@@ -174,6 +178,7 @@ public class Blocks implements ContentList{
liquidDrop = Liquids.water;
isLiquid = true;
cacheLayer = CacheLayer.water;
albedo = 0.5f;
}};
darksandWater = new Floor("darksand-water"){{
@@ -184,6 +189,7 @@ public class Blocks implements ContentList{
liquidDrop = Liquids.water;
isLiquid = true;
cacheLayer = CacheLayer.water;
albedo = 0.5f;
}};
tar = new Floor("tar"){{

View File

@@ -80,6 +80,7 @@ public class Shaders{
public static class PlanetShader extends LoadShader{
public Vec3 lightDir = new Vec3(1, 1, 1).nor();
public Color ambientColor = Color.white.cpy();
public Vec3 camDir = new Vec3();
public PlanetShader(){
super("planet", "planet");
@@ -89,6 +90,7 @@ public class Shaders{
public void apply(){
setUniformf("u_lightdir", lightDir);
setUniformf("u_ambientColor", ambientColor.r, ambientColor.g, ambientColor.b);
setUniformf("u_camdir", camDir);
}
}

View File

@@ -60,8 +60,7 @@ public class TODOPlanetGenerator extends PlanetGenerator{
Block block = getBlock(position);
//replace salt with sand color
if(block == Blocks.salt) return Blocks.sand.mapColor;
//return block.asFloor().isLiquid ? Tmp.c1.set(block.mapColor).a(0.5f) : block.mapColor;
return block.mapColor;
return Tmp.c1.set(block.mapColor).a(1f - block.albedo);
}
@Override

View File

@@ -177,6 +177,9 @@ public class PlanetDialog extends FloatingDialog{
cam.lookAt(planet.position);
cam.update();
//TODO hacky
Shaders.planet.camDir.set(cam.direction).rotate(Vec3.Y, planet.getRotation());
projector.proj(cam.combined());
batch.proj(cam.combined());

View File

@@ -129,6 +129,8 @@ public class Block extends UnlockableContent{
public boolean hasShadow = true;
/** Sounds made when this block breaks.*/
public Sound breakSound = Sounds.boom;
/** How reflective this block is. */
public float albedo = 0f;
/** The sound that this block makes while active. One sound loop. Do not overuse.*/
public Sound activeSound = Sounds.none;