1
0
mirror of https://github.com/Anuken/Mindustry.git synced 2024-09-11 08:15:35 +03:00

"Realistic" specular planet lighting

This commit is contained in:
Anuken 2021-09-16 10:20:32 -04:00
parent 7b623e964c
commit 845b64945e
3 changed files with 21 additions and 14 deletions

2
.gitignore vendored
View File

@ -165,4 +165,4 @@ android/libs/
# ignored due to frequent branch conflicts.
core/assets/logicids.dat
core/assets/icons.icons.properties
core/assets/icons/icons.properties

View File

@ -15,11 +15,16 @@ const float shinefalloff = 4.0;
const float shinelen = 0.2;
void main(){
vec3 norc = u_ambientColor * (diffuse + vec3(clamp((dot(a_normal, u_lightdir) + 1.0) / 2.0, 0.0, 1.0)));
float shinedot = max((-dot(u_camdir, a_normal) - (1.0 - shinelen)) / shinelen, 0.0);
float albedo = (1.0 - a_color.a) * pow(shinedot, shinefalloff);
vec4 baseCol = vec4(a_color.rgb, 1.0);
vec3 specular = vec3(0, 0, 0);
v_col = mix(baseCol * vec4(norc, 1.0), vec4(1.0), albedo * norc.r);
vec3 lightReflect = normalize(reflect(a_normal, u_lightdir));
float specularFactor = dot(u_camdir, lightReflect);
if(specularFactor > 0){
specular = vec3(1.0f * pow(specularFactor, 32f)) * (1f-a_color.a); //specular power = 32
}
vec3 norc = (u_ambientColor + specular) * (diffuse + vec3(clamp((dot(a_normal, u_lightdir) + 1.0) / 2.0, 0.0, 1.0)));
v_col = vec4(a_color.rgb, 1.0) * vec4(norc, 1.0);
gl_Position = u_proj * u_trans * a_position;
}

View File

@ -127,7 +127,7 @@ public class Blocks implements ContentList{
statusDuration = 120f;
drownTime = 140f;
cacheLayer = CacheLayer.water;
albedo = 0.5f;
albedo = 0.9f;
}};
water = new Floor("shallow-water"){{
@ -138,7 +138,7 @@ public class Blocks implements ContentList{
liquidDrop = Liquids.water;
isLiquid = true;
cacheLayer = CacheLayer.water;
albedo = 0.5f;
albedo = 0.9f;
}};
taintedWater = new Floor("tainted-water"){{
@ -149,7 +149,7 @@ public class Blocks implements ContentList{
liquidDrop = Liquids.water;
isLiquid = true;
cacheLayer = CacheLayer.water;
albedo = 0.5f;
albedo = 0.9f;
attributes.set(Attribute.spores, 0.15f);
}};
@ -162,27 +162,27 @@ public class Blocks implements ContentList{
liquidDrop = Liquids.water;
isLiquid = true;
cacheLayer = CacheLayer.water;
albedo = 0.5f;
albedo = 0.9f;
attributes.set(Attribute.spores, 0.15f);
}};
darksandTaintedWater = new ShallowLiquid("darksand-tainted-water"){{
speedMultiplier = 0.75f;
statusDuration = 60f;
albedo = 0.5f;
albedo = 0.9f;
attributes.set(Attribute.spores, 0.1f);
}};
sandWater = new ShallowLiquid("sand-water"){{
speedMultiplier = 0.8f;
statusDuration = 50f;
albedo = 0.5f;
albedo = 0.9f;
}};
darksandWater = new ShallowLiquid("darksand-water"){{
speedMultiplier = 0.8f;
statusDuration = 50f;
albedo = 0.5f;
albedo = 0.9f;
}};
tar = new Floor("tar"){{
@ -275,7 +275,6 @@ public class Blocks implements ContentList{
statusDuration = 30f;
attributes.set(Attribute.water, 1f);
cacheLayer = CacheLayer.mud;
albedo = 0.35f;
walkSound = Sounds.mud;
walkSoundVolume = 0.08f;
walkSoundPitchMin = 0.4f;
@ -300,18 +299,21 @@ public class Blocks implements ContentList{
snow = new Floor("snow"){{
attributes.set(Attribute.water, 0.2f);
albedo = 0.7f;
}};
ice = new Floor("ice"){{
dragMultiplier = 0.35f;
speedMultiplier = 0.9f;
attributes.set(Attribute.water, 0.4f);
albedo = 0.65f;
}};
iceSnow = new Floor("ice-snow"){{
dragMultiplier = 0.6f;
variants = 3;
attributes.set(Attribute.water, 0.3f);
albedo = 0.6f;
}};
shale = new Floor("shale"){{