mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-04 23:38:10 +07:00
"Realistic" specular planet lighting
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@ -165,4 +165,4 @@ android/libs/
|
|||||||
|
|
||||||
# ignored due to frequent branch conflicts.
|
# ignored due to frequent branch conflicts.
|
||||||
core/assets/logicids.dat
|
core/assets/logicids.dat
|
||||||
core/assets/icons.icons.properties
|
core/assets/icons/icons.properties
|
@ -15,11 +15,16 @@ const float shinefalloff = 4.0;
|
|||||||
const float shinelen = 0.2;
|
const float shinelen = 0.2;
|
||||||
|
|
||||||
void main(){
|
void main(){
|
||||||
vec3 norc = u_ambientColor * (diffuse + vec3(clamp((dot(a_normal, u_lightdir) + 1.0) / 2.0, 0.0, 1.0)));
|
vec3 specular = vec3(0, 0, 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);
|
|
||||||
|
|
||||||
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;
|
gl_Position = u_proj * u_trans * a_position;
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ public class Blocks implements ContentList{
|
|||||||
statusDuration = 120f;
|
statusDuration = 120f;
|
||||||
drownTime = 140f;
|
drownTime = 140f;
|
||||||
cacheLayer = CacheLayer.water;
|
cacheLayer = CacheLayer.water;
|
||||||
albedo = 0.5f;
|
albedo = 0.9f;
|
||||||
}};
|
}};
|
||||||
|
|
||||||
water = new Floor("shallow-water"){{
|
water = new Floor("shallow-water"){{
|
||||||
@ -138,7 +138,7 @@ public class Blocks implements ContentList{
|
|||||||
liquidDrop = Liquids.water;
|
liquidDrop = Liquids.water;
|
||||||
isLiquid = true;
|
isLiquid = true;
|
||||||
cacheLayer = CacheLayer.water;
|
cacheLayer = CacheLayer.water;
|
||||||
albedo = 0.5f;
|
albedo = 0.9f;
|
||||||
}};
|
}};
|
||||||
|
|
||||||
taintedWater = new Floor("tainted-water"){{
|
taintedWater = new Floor("tainted-water"){{
|
||||||
@ -149,7 +149,7 @@ public class Blocks implements ContentList{
|
|||||||
liquidDrop = Liquids.water;
|
liquidDrop = Liquids.water;
|
||||||
isLiquid = true;
|
isLiquid = true;
|
||||||
cacheLayer = CacheLayer.water;
|
cacheLayer = CacheLayer.water;
|
||||||
albedo = 0.5f;
|
albedo = 0.9f;
|
||||||
attributes.set(Attribute.spores, 0.15f);
|
attributes.set(Attribute.spores, 0.15f);
|
||||||
}};
|
}};
|
||||||
|
|
||||||
@ -162,27 +162,27 @@ public class Blocks implements ContentList{
|
|||||||
liquidDrop = Liquids.water;
|
liquidDrop = Liquids.water;
|
||||||
isLiquid = true;
|
isLiquid = true;
|
||||||
cacheLayer = CacheLayer.water;
|
cacheLayer = CacheLayer.water;
|
||||||
albedo = 0.5f;
|
albedo = 0.9f;
|
||||||
attributes.set(Attribute.spores, 0.15f);
|
attributes.set(Attribute.spores, 0.15f);
|
||||||
}};
|
}};
|
||||||
|
|
||||||
darksandTaintedWater = new ShallowLiquid("darksand-tainted-water"){{
|
darksandTaintedWater = new ShallowLiquid("darksand-tainted-water"){{
|
||||||
speedMultiplier = 0.75f;
|
speedMultiplier = 0.75f;
|
||||||
statusDuration = 60f;
|
statusDuration = 60f;
|
||||||
albedo = 0.5f;
|
albedo = 0.9f;
|
||||||
attributes.set(Attribute.spores, 0.1f);
|
attributes.set(Attribute.spores, 0.1f);
|
||||||
}};
|
}};
|
||||||
|
|
||||||
sandWater = new ShallowLiquid("sand-water"){{
|
sandWater = new ShallowLiquid("sand-water"){{
|
||||||
speedMultiplier = 0.8f;
|
speedMultiplier = 0.8f;
|
||||||
statusDuration = 50f;
|
statusDuration = 50f;
|
||||||
albedo = 0.5f;
|
albedo = 0.9f;
|
||||||
}};
|
}};
|
||||||
|
|
||||||
darksandWater = new ShallowLiquid("darksand-water"){{
|
darksandWater = new ShallowLiquid("darksand-water"){{
|
||||||
speedMultiplier = 0.8f;
|
speedMultiplier = 0.8f;
|
||||||
statusDuration = 50f;
|
statusDuration = 50f;
|
||||||
albedo = 0.5f;
|
albedo = 0.9f;
|
||||||
}};
|
}};
|
||||||
|
|
||||||
tar = new Floor("tar"){{
|
tar = new Floor("tar"){{
|
||||||
@ -275,7 +275,6 @@ public class Blocks implements ContentList{
|
|||||||
statusDuration = 30f;
|
statusDuration = 30f;
|
||||||
attributes.set(Attribute.water, 1f);
|
attributes.set(Attribute.water, 1f);
|
||||||
cacheLayer = CacheLayer.mud;
|
cacheLayer = CacheLayer.mud;
|
||||||
albedo = 0.35f;
|
|
||||||
walkSound = Sounds.mud;
|
walkSound = Sounds.mud;
|
||||||
walkSoundVolume = 0.08f;
|
walkSoundVolume = 0.08f;
|
||||||
walkSoundPitchMin = 0.4f;
|
walkSoundPitchMin = 0.4f;
|
||||||
@ -300,18 +299,21 @@ public class Blocks implements ContentList{
|
|||||||
|
|
||||||
snow = new Floor("snow"){{
|
snow = new Floor("snow"){{
|
||||||
attributes.set(Attribute.water, 0.2f);
|
attributes.set(Attribute.water, 0.2f);
|
||||||
|
albedo = 0.7f;
|
||||||
}};
|
}};
|
||||||
|
|
||||||
ice = new Floor("ice"){{
|
ice = new Floor("ice"){{
|
||||||
dragMultiplier = 0.35f;
|
dragMultiplier = 0.35f;
|
||||||
speedMultiplier = 0.9f;
|
speedMultiplier = 0.9f;
|
||||||
attributes.set(Attribute.water, 0.4f);
|
attributes.set(Attribute.water, 0.4f);
|
||||||
|
albedo = 0.65f;
|
||||||
}};
|
}};
|
||||||
|
|
||||||
iceSnow = new Floor("ice-snow"){{
|
iceSnow = new Floor("ice-snow"){{
|
||||||
dragMultiplier = 0.6f;
|
dragMultiplier = 0.6f;
|
||||||
variants = 3;
|
variants = 3;
|
||||||
attributes.set(Attribute.water, 0.3f);
|
attributes.set(Attribute.water, 0.3f);
|
||||||
|
albedo = 0.6f;
|
||||||
}};
|
}};
|
||||||
|
|
||||||
shale = new Floor("shale"){{
|
shale = new Floor("shale"){{
|
||||||
|
Reference in New Issue
Block a user