Skip to content

Commit

Permalink
feat: progress towards 1:1 sky properties
Browse files Browse the repository at this point in the history
  • Loading branch information
vinceh121 committed Dec 28, 2023
1 parent 3b4a458 commit 2ad72f0
Show file tree
Hide file tree
Showing 4 changed files with 238 additions and 70 deletions.
220 changes: 188 additions & 32 deletions android/assets/skies.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,54 @@
{
"normal": {
"sunColor": {
"0.75": {
"r": 0.0,
"g": 0.0,
"b": 0.0,
"a": 0.0
},
"0.875": {
"r": 0.439216,
"g": 0.090196,
"b": 0.0,
"a": 0.0
},
"0.0": {
"r": 1.0,
"g": 1.0,
"b": 0.109804,
"a": 0.0
},
"0.125": {
"r": 1.0,
"g": 1.0,
"b": 1.0,
"a": 0.0
},
"0.25": {
"r": 1.0,
"g": 1.0,
"b": 1.0,
"a": 0.0
},
"0.375": {
"r": 1.0,
"g": 1.0,
"b": 1.0,
"a": 0.0
},
"0.5": {
"r": 0.486275,
"g": 0.266667,
"b": 0.113725,
"a": 0.0
},
"0.625": {
"r": 0.0,
"g": 0.0,
"b": 0.0,
"a": 0.0
}
},
"sunLightColor": {
"0": {
Expand Down Expand Up @@ -41,35 +89,53 @@
}
},
"ambLightColor": {
"0": {
"r": 0.4,
"g": 0.4,
"b": 0.4,
"a": 1.0
"0.75": {
"r": 0.184314,
"g": 0.227451,
"b": 0.25098,
"a": 0.0
},
"0.875": {
"r": 0.3,
"g": 0.1,
"b": 0.0,
"a": 0.0
},
"0.0": {
"r": 0.3,
"g": 0.1,
"b": 0.0,
"a": 0.0
},
"0.125": {
"r": 0.054902,
"g": 0.137255,
"b": 0.152941,
"a": 0.0
},
"0.25": {
"r": 0.6,
"g": 0.6,
"b": 0.6,
"a": 1.0
"r": 0.090196,
"g": 0.196078,
"b": 0.223529,
"a": 0.0
},
"0.625": {
"r": 0.5,
"g": 0.5,
"b": 0.5,
"a": 1.0
"0.375": {
"r": 0.07451,
"g": 0.101961,
"b": 0.101961,
"a": 0.0
},
"0.75": {
"r": 0.3,
"g": 0.3,
"b": 0.3,
"a": 1.0
"0.5": {
"r": 0.466667,
"g": 0.05098,
"b": 0.05098,
"a": 0.0
},
"0.875": {
"r": 0.5,
"g": 0.5,
"b": 0.5,
"a": 1.0
"0.625": {
"r": 0.0,
"g": 0.0,
"b": 0.0,
"a": 0.0
}
},
"skyTopColor": {
Expand Down Expand Up @@ -158,15 +224,105 @@
"a": 0
}
},
"starsOpacity": {
"0.5": 0,
"0.75": 1,
"1": 0
"starsColor": {
"0.75": {
"r": 1.0,
"g": 1.0,
"b": 1.0,
"a": 1.0
},
"0.875": {
"r": 0.0,
"g": 0.0,
"b": 0.0,
"a": 0.0
},
"0.0": {
"r": 0.0,
"g": 0.0,
"b": 0.0,
"a": 0.0
},
"0.125": {
"r": 0.0,
"g": 0.0,
"b": 0.0,
"a": 0.0
},
"0.25": {
"r": 0.0,
"g": 0.0,
"b": 0.0,
"a": 0.0
},
"0.375": {
"r": 0.0,
"g": 0.0,
"b": 0.0,
"a": 0.0
},
"0.5": {
"r": 0.0,
"g": 0.0,
"b": 0.0,
"a": 0.0
},
"0.625": {
"r": 0.784314,
"g": 0.784314,
"b": 0.784314,
"a": 0.0
}
},
"galaxyOpacity": {
"0.5": 0,
"0.75": 1,
"1": 0
"galaxyColor": {
"0.75": {
"r": 0.0,
"g": 0.0,
"b": 0.0,
"a": 0.2
},
"0.875": {
"r": 0.0,
"g": 0.0,
"b": 0.0,
"a": 0.151
},
"0.0": {
"r": 0.0,
"g": 0.0,
"b": 0.0,
"a": 0.192
},
"0.125": {
"r": 0.0,
"g": 0.0,
"b": 0.0,
"a": 0.151
},
"0.2476852": {
"r": 0.0,
"g": 0.0,
"b": 0.0,
"a": 0.11
},
"0.375": {
"r": 0.0,
"g": 0.0,
"b": 0.0,
"a": 0.226
},
"0.5": {
"r": 0.5,
"g": 0.5,
"b": 0.5,
"a": 0.075
},
"0.625": {
"r": 0.0,
"g": 0.0,
"b": 0.0,
"a": 0.349
}
}
}
}
16 changes: 8 additions & 8 deletions core/src/me/vinceh121/wanderer/glx/SkyProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ public class SkyProperties {
private final NavigableMap<Float, Color> skyMiddleColor = new TreeMap<>();
private final NavigableMap<Float, Color> skyBottomColor = new TreeMap<>();
private final NavigableMap<Float, Color> sunShineColor = new TreeMap<>();
private final NavigableMap<Float, Float> starsOpacity = new TreeMap<>();
private final NavigableMap<Float, Float> galaxyOpacity = new TreeMap<>();
private final NavigableMap<Float, Color> starsColor = new TreeMap<>();
private final NavigableMap<Float, Color> galaxyColor = new TreeMap<>();

public NavigableMap<Float, Color> getSunColor() {
return sunColor;
Expand Down Expand Up @@ -44,19 +44,19 @@ public NavigableMap<Float, Color> getSunShineColor() {
return sunShineColor;
}

public NavigableMap<Float, Float> getStarsOpacity() {
return starsOpacity;
public NavigableMap<Float, Color> getStarsColor() {
return starsColor;
}

public NavigableMap<Float, Float> getGalaxyOpacity() {
return galaxyOpacity;
public NavigableMap<Float, Color> getGalaxyColor() {
return galaxyColor;
}

@Override
public String toString() {
return "SkyProperties [sunColor=" + sunColor + ", sunLightColor=" + sunLightColor + ", ambLightColor="
+ ambLightColor + ", skyTopColor=" + skyTopColor + ", skyMiddleColor=" + skyMiddleColor
+ ", skyBottomColor=" + skyBottomColor + ", sunShineColor=" + sunShineColor + ", starsOpacity="
+ starsOpacity + ", galaxyOpacity=" + galaxyOpacity + "]";
+ ", skyBottomColor=" + skyBottomColor + ", sunShineColor=" + sunShineColor + ", starsColor="
+ starsColor + ", galaxyColor=" + galaxyColor + "]";
}
}
20 changes: 12 additions & 8 deletions core/src/me/vinceh121/wanderer/glx/SkyboxRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,12 @@ public void update(final float time) {
this.previous = time;

this.stars.transform.rotateRad(Vector3.Y, 0.02f * delta / 0.016666668f);
((BlendingAttribute) this.stars.materials.get(0).get(BlendingAttribute.Type)).opacity =
1 - this.interpolatedFloat(time, this.skyProperties.getStarsOpacity());
((ColorAttribute) this.stars.materials.get(0).get(ColorAttribute.Diffuse)).color
.set(this.interpolatedColor(time, this.skyProperties.getStarsColor()));

this.move(this.sun, MathUtils.PI * 0.65f, time * MathUtils.PI2, 0.6f, 0);
((ColorAttribute) this.sun.materials.get(0).get(ColorAttribute.Diffuse)).color
.set(this.interpolatedColor(time, this.skyProperties.getSunColor()));
MathUtilsW.preciseSetFromSpherical(this.sunDir, MathUtils.PI * 0.65f, time * MathUtils.PI2);

if (this.shader != null) {
Expand All @@ -111,8 +113,8 @@ public void update(final float time) {
this.move(this.mars, MathUtils.PI2 * time, 0.12f * MathUtils.PI2, 1f, 0);

this.move(this.galaxy, MathUtils.sin(time * MathUtils.PI2) / 5 + MathUtils.PI * 0.1f, MathUtils.HALF_PI, 1f, 0);
((BlendingAttribute) this.galaxy.materials.get(0).get(BlendingAttribute.Type)).opacity =
1 - this.interpolatedFloat(time, this.skyProperties.getGalaxyOpacity());
((ColorAttribute) this.galaxy.materials.get(0).get(ColorAttribute.Diffuse)).color
.set(this.interpolatedColor(time, this.skyProperties.getGalaxyColor()));

// skycap rotates counter clock-wise
this.skycap.transform.rotateRad(Vector3.Y, 0.2f * delta / 0.016666668f);
Expand Down Expand Up @@ -336,9 +338,11 @@ private ModelInstance makeStars(final Texture tex) {
final Model model = WandererConstants.ASSET_MANAGER.get("orig/lib/stars/stars.obj", Model.class);
final ModelInstance ins = new ModelInstance(model);
ins.materials.get(0)
.set(new DepthTestAttribute(false), IntAttribute.createCullFace(0), TextureAttribute.createDiffuse(tex)
// ,new NoLightningAttribute()
);
.set(new DepthTestAttribute(false),
IntAttribute.createCullFace(0),
TextureAttribute.createDiffuse(tex),
new NoLightningAttribute(),
ColorAttribute.createDiffuse(Color.CLEAR));
return ins;
}

Expand Down Expand Up @@ -374,7 +378,7 @@ public static float toDayProgress(int hour, int minutes) {
return toDayProgress(hour * 60 + minutes);
}

public static float toDayProgress(int dayMinutes) {
public static float toDayProgress(float dayMinutes) {
return (dayMinutes / 1440f - 0.25f + 1) % 1f;
}
}
Loading

0 comments on commit 2ad72f0

Please sign in to comment.