cloud model update

This commit is contained in:
minjaesong
2023-09-19 01:34:43 +09:00
parent b0d7bc4022
commit 5616b81a31
6 changed files with 26 additions and 18 deletions

View File

@@ -4,8 +4,8 @@
"daylightClut": "clut_daylight.tga",
"classification": "generic",
"cloudChance": 125,
"cloudGamma": [0.7, 2.4],
"cloudGammaVariance": [0.143, 0.0],
"cloudGamma": [0.9, 2.4],
"cloudGammaVariance": [0.111, 0.0],
"windSpeed": 0.35,
"windSpeedVariance": 0.4,
"windSpeedDamping": 0.5,

View File

@@ -4,8 +4,8 @@
"daylightClut": "clut_daylight.tga",
"classification": "generic2",
"cloudChance": 800,
"cloudGamma": [0.8, 2.4],
"cloudGammaVariance": [0.125, 0.0],
"cloudGamma": [0.9, 2.4],
"cloudGammaVariance": [0.111, 0.0],
"windSpeed": 0.35,
"windSpeedVariance": 0.4,
"windSpeedDamping": 0.5,

View File

@@ -1641,8 +1641,8 @@ public class App implements ApplicationListener {
frag = "#version 400\n"+frag0;
}
else {
vert = "#version 150\n#define fma(a,b,c) ((a*b)+c)\n"+vert0;
frag = "#version 150\n#define fma(a,b,c) ((a*b)+c)\n"+frag0;
vert = "#version 150\n#define fma(a,b,c) (((a)*(b))+(c))\n"+vert0;
frag = "#version 150\n#define fma(a,b,c) (((a)*(b))+(c))\n"+frag0;
}
ShaderProgram s = new ShaderProgram(vert, frag);

View File

@@ -99,9 +99,9 @@ open class ActorHumanoid : ActorWithBody, Controllable, Pocketed, Factionable, L
* Hitbox(x-offset, y-offset, width, height)
* (Use ArrayList for normal circumstances)
*/
@Transient override var lightBoxList: ArrayList<Lightbox> = arrayListOf(Lightbox(Hitbox(2.0, 2.0, baseHitboxW - 3.0, baseHitboxH - 3.0), Cvec(0)))
@Transient override var lightBoxList: ArrayList<Lightbox> = arrayListOf(Lightbox(Hitbox(2.0, 2.0, baseHitboxW - 2.0, baseHitboxH - 2.0), Cvec(0)))
// the actual values are update on the update()
@Transient override var shadeBoxList: ArrayList<Lightbox> = arrayListOf(Lightbox(Hitbox(2.0, 2.0, baseHitboxW - 3.0, baseHitboxH - 3.0), Cvec(0)))
@Transient override var shadeBoxList: ArrayList<Lightbox> = arrayListOf(Lightbox(Hitbox(2.0, 2.0, baseHitboxW - 2.0, baseHitboxH - 2.0), Cvec(0)))
// the actual values are update on the update()
@Transient val BASE_DENSITY = 980.0

View File

@@ -502,12 +502,19 @@ internal object WeatherMixer : RNGConsumer {
// private var gH = 0.8f * App.scr.height
internal var parallaxPos = 0f; private set
private var solarElev = 0.0
private val HALF_DAY = DAY_LENGTH / 2
/**
* Sub-portion of IngameRenderer. You are not supposed to directly deal with this.
*/
internal fun render(camera: OrthographicCamera, batch: FlippingSpriteBatch, world: GameWorld) {
solarElev = if (forceSolarElev != null)
forceSolarElev!!
else if (forceTimeAt != null)
world.worldTime.getSolarElevationAt(world.worldTime.ordinalDay, forceTimeAt!!)
else
world.worldTime.solarElevationDeg
drawSkybox(camera, batch, world)
drawClouds(batch)
batch.color = Color.WHITE
@@ -516,7 +523,9 @@ internal object WeatherMixer : RNGConsumer {
private fun drawClouds(batch: SpriteBatch) {
batch.inUse { _ ->
batch.shader = shaderClouds
batch.shader.setUniformf("shadeCol", 0.06f, 0.07f, 0.08f, 1f) // TODO temporary value
val shadeLum = (globalLightNow.r * 3f + globalLightNow.g * 4f + globalLightNow.b * 1f) / 8f * 0.5f
batch.shader.setUniformf("shadeCol", shadeLum * 1.05f, shadeLum, shadeLum / 1.05f, 1f)
batch.shader.setUniformf("shadiness", (1.0 / cosh(solarElev * 0.5)).toFloat().coerceAtLeast(if (solarElev < 0) 0.6666f else 0f))
clouds.forEach {
it.render(batch as UnpackedColourSpriteBatch, cloudDrawColour)
@@ -534,12 +543,6 @@ internal object WeatherMixer : RNGConsumer {
// we will not care for nextSkybox for now
val timeNow = (forceTimeAt ?: world.worldTime.TIME_T.toInt()) % WorldTime.DAY_LENGTH
val solarElev = if (forceSolarElev != null)
forceSolarElev!!
else if (forceTimeAt != null)
world.worldTime.getSolarElevationAt(world.worldTime.ordinalDay, forceTimeAt!!)
else
world.worldTime.solarElevationDeg
val daylightClut = currentWeather.daylightClut
// calculate global light
val moonSize = (-(2.0 * world.worldTime.moonPhase - 1.0).abs() + 1.0).toFloat()

View File

@@ -10,6 +10,9 @@ out vec4 fragColor;
const vec2 boolean = vec2(0.0, 1.0);
uniform vec4 shadeCol;
uniform float shadiness = 1.0;
vec4 shadeVec = vec4(1.0 + 3.333 * shadiness, 1.0 + 3.333 * shadiness, 1.0 + 3.333 * shadiness, 1.0);
void main() {
vec4 cloudCol = v_color;
@@ -23,10 +26,12 @@ void main() {
// cloud colour format:
// r: bw diffuse map, g: normal, b: normal, a: bw diffuse alpha
vec4 inCol = texture(u_texture, v_texCoords);
vec4 rawCol = range * pow(inCol, gamma) + offset;
vec4 rawCol0 = range * pow(inCol, gamma) + offset;
vec4 rawCol = pow(rawCol0, shadeVec);
// do gradient mapping here
vec4 outCol = fma(mix(shadeCol, cloudCol, rawCol.r), boolean.yyyx, rawCol * boolean.xxxy);
vec4 ccol = mix(shadeCol, cloudCol, rawCol.r);
vec4 outCol = fma(ccol, boolean.yyyx, rawCol * boolean.xxxy);
fragColor = outCol * fma(cloudCol, boolean.xxxy, boolean.yyyx);
}