new lightmap: nice try but didn't work

This commit is contained in:
minjaesong
2020-02-21 03:40:37 +09:00
parent 9d51f419f5
commit 947224c290
6 changed files with 240 additions and 5 deletions

View File

@@ -37,22 +37,31 @@ object BlockPropUtil {
private fun getTorchFlicker(baseLum: Cvec): Cvec {
val funcY = FastMath.interpolateLinear(flickerFuncX / flickerFuncDomain, flickerP0, flickerP1)
return alterBrightnessUniform(baseLum, funcY)
}
private fun getTorchFlicker(baseLum: Float): Float {
return baseLum + FastMath.interpolateLinear(flickerFuncX / flickerFuncDomain, flickerP0, flickerP1)
}
private fun getSlowBreath(baseLum: Cvec): Cvec {
val funcY = FastMath.sin(FastMath.PI * breathFuncX / breathCycleDuration) * breathRange
return alterBrightnessUniform(baseLum, funcY)
}
private fun getSlowBreath(baseLum: Float): Float {
return baseLum + FastMath.sin(FastMath.PI * breathFuncX / breathCycleDuration) * breathRange
}
private fun getPulsate(baseLum: Cvec): Cvec {
val funcY = FastMath.sin(FastMath.PI * pulsateFuncX / pulsateCycleDuration) * pulsateRange
return alterBrightnessUniform(baseLum, funcY)
}
private fun getPulsate(baseLum: Float): Float {
return baseLum + FastMath.sin(FastMath.PI * pulsateFuncX / pulsateCycleDuration) * pulsateRange
}
/**
* Using our own timer so that they flickers for same duration regardless of game's FPS
*/
@@ -94,6 +103,20 @@ object BlockPropUtil {
}
}
/**
* @param chan 0 for R, 1 for G, 2 for B, 3 for A
*/
fun getDynamicLumFuncByChan(baseLum: Float, type: Int, chan: Int): Float {
return when (type) {
1 -> getTorchFlicker(baseLum)
2 -> (Terrarum.ingame!!.world).globalLight.cpy().mul(LightmapRenderer.DIV_FLOAT).getElem(chan) // current global light
3 -> WeatherMixer.getGlobalLightOfTime(Terrarum.ingame!!.world, WorldTime.DAY_LENGTH / 2).cpy().mul(LightmapRenderer.DIV_FLOAT).getElem(chan) // daylight at noon
4 -> getSlowBreath(baseLum)
5 -> getPulsate(baseLum)
else -> baseLum
}
}
/**
* Darken or brighten colour by 'brighten' argument
*