Serpulo clouds
This commit is contained in:
20
core/assets/shaders/clouds.vert
Executable file
20
core/assets/shaders/clouds.vert
Executable file
@@ -0,0 +1,20 @@
|
||||
attribute vec4 a_position;
|
||||
attribute vec3 a_normal;
|
||||
attribute vec4 a_color;
|
||||
|
||||
uniform mat4 u_proj;
|
||||
uniform mat4 u_trans;
|
||||
uniform vec3 u_lightdir;
|
||||
uniform vec3 u_ambientColor;
|
||||
uniform float u_alpha;
|
||||
|
||||
varying vec4 v_col;
|
||||
|
||||
const vec3 diffuse = vec3(0.01);
|
||||
|
||||
void main(){
|
||||
vec3 norc = u_ambientColor * (diffuse + vec3(clamp((dot(a_normal, u_lightdir) + 1.0) / 2.0, 0.0, 1.0)));
|
||||
|
||||
v_col = a_color * vec4(norc, u_alpha);
|
||||
gl_Position = u_proj * u_trans * a_position;
|
||||
}
|
||||
@@ -83,6 +83,7 @@ public class Planets implements ContentList{
|
||||
serpulo = new Planet("serpulo", sun, 1, 3){{
|
||||
generator = new SerpuloPlanetGenerator();
|
||||
meshLoader = () -> new HexMesh(this, 6);
|
||||
cloudMeshLoader = () -> new HexSkyMesh(this, 0.17f, 5, Color.white.cpy().lerp(Pal.spore, 0.7f).a(0.7f), 2, 0.5f, 1.1f, 0.45f);
|
||||
atmosphereColor = Color.valueOf("3c1b8f");
|
||||
atmosphereRadIn = 0.02f;
|
||||
atmosphereRadOut = 0.3f;
|
||||
|
||||
@@ -23,6 +23,7 @@ public class Shaders{
|
||||
public static LightShader light;
|
||||
public static SurfaceShader water, mud, tar, slag, space, caustics;
|
||||
public static PlanetShader planet;
|
||||
public static CloudShader clouds;
|
||||
public static PlanetGridShader planetGrid;
|
||||
public static AtmosphereShader atmosphere;
|
||||
public static MeshShader mesh;
|
||||
@@ -55,6 +56,7 @@ public class Shaders{
|
||||
}
|
||||
};
|
||||
planet = new PlanetShader();
|
||||
clouds = new CloudShader();
|
||||
planetGrid = new PlanetGridShader();
|
||||
atmosphere = new AtmosphereShader();
|
||||
unlit = new LoadShader("planet", "unlit");
|
||||
@@ -108,6 +110,26 @@ public class Shaders{
|
||||
}
|
||||
}
|
||||
|
||||
public static class CloudShader extends LoadShader{
|
||||
public Vec3 lightDir = new Vec3(1, 1, 1).nor();
|
||||
public Color ambientColor = Color.white.cpy();
|
||||
public Vec3 camDir = new Vec3();
|
||||
public float alpha = 1f;
|
||||
|
||||
public CloudShader(){
|
||||
super("planet", "clouds");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(){
|
||||
camDir.set(renderer.planets.cam.direction).rotate(Vec3.Y, renderer.planets.planet.getRotation());
|
||||
|
||||
setUniformf("u_alpha", alpha);
|
||||
setUniformf("u_lightdir", lightDir);
|
||||
setUniformf("u_ambientColor", ambientColor.r, ambientColor.g, ambientColor.b);
|
||||
}
|
||||
}
|
||||
|
||||
public static class MeshShader extends LoadShader{
|
||||
|
||||
public MeshShader(){
|
||||
|
||||
40
core/src/mindustry/graphics/g3d/HexSkyMesh.java
Normal file
40
core/src/mindustry/graphics/g3d/HexSkyMesh.java
Normal file
@@ -0,0 +1,40 @@
|
||||
package mindustry.graphics.g3d;
|
||||
|
||||
import arc.graphics.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.util.noise.*;
|
||||
import mindustry.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
|
||||
public class HexSkyMesh extends PlanetMesh{
|
||||
|
||||
public HexSkyMesh(Planet planet, float radius, int divisions, Color color, int octaves, float persistence, float scl, float thresh){
|
||||
super(planet, MeshBuilder.buildHex(new HexMesher(){
|
||||
@Override
|
||||
public float getHeight(Vec3 position){
|
||||
return 1f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getColor(Vec3 position){
|
||||
return color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean skip(Vec3 position){
|
||||
return Simplex.noise3d(planet.id, octaves, persistence, scl, position.x, position.y * 3f, position.z) >= thresh;
|
||||
}
|
||||
}, divisions, false, planet.radius, radius), Shaders.clouds);
|
||||
}
|
||||
|
||||
public HexSkyMesh(){
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preRender(){
|
||||
Shaders.clouds.lightDir.set(planet.solarSystem.position).sub(planet.position).rotate(Vec3.Y, planet.getRotation()).nor();
|
||||
Shaders.clouds.ambientColor.set(planet.solarSystem.lightColor);
|
||||
Shaders.clouds.alpha = 1f - Vars.ui.planet.planets.orbitAlpha;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user