Reflective planet water
This commit is contained in:
@@ -5,7 +5,7 @@ attribute vec4 a_color;
|
||||
uniform mat4 u_proj;
|
||||
uniform mat4 u_trans;
|
||||
uniform vec3 u_lightdir;
|
||||
//uniform vec3 u_camdir;
|
||||
uniform vec3 u_camdir;
|
||||
uniform vec3 u_ambientColor;
|
||||
|
||||
varying vec4 v_col;
|
||||
@@ -14,7 +14,12 @@ const vec3 diffuse = vec3(0);
|
||||
|
||||
void main(){
|
||||
vec3 norc = u_ambientColor * (diffuse + vec3(clamp((dot(a_normal, u_lightdir) + 1.0) / 2.0, 0.0, 1.0)));
|
||||
float falloff = 4.0;
|
||||
float shinelen = 0.2;
|
||||
float shinedot = max((-dot(u_camdir, a_normal) - (1.0 - shinelen)) / shinelen, 0.0);
|
||||
float shinyness = (1.0 - a_color.a) * pow(shinedot, falloff);
|
||||
vec4 baseCol = vec4(a_color.rgb, 1.0);
|
||||
|
||||
v_col = a_color * vec4(norc, 1.0);
|
||||
v_col = lerp(baseCol * vec4(norc, 1.0), vec4(1.0), shinyness * norc.r);
|
||||
gl_Position = u_proj * u_trans * a_position;
|
||||
}
|
||||
|
||||
@@ -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"){{
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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());
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
org.gradle.daemon=true
|
||||
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
||||
archash=50df607c88d697dc42b29b56947cda318f90d71b
|
||||
archash=da2913187aa724da769c6a80bc709eebb5bc0888
|
||||
|
||||
Reference in New Issue
Block a user