experimental new lighting can be toggled with config "fx_newlight"

This commit is contained in:
minjaesong
2022-10-05 23:26:46 +09:00
parent 50d1aabaf3
commit a6685df5d1
2 changed files with 40 additions and 25 deletions

View File

@@ -110,6 +110,8 @@ object DefaultConfig {
"screenmagnifying" to 1.0, "screenmagnifying" to 1.0,
"fx_newlight" to true,
// settings regarding debugger // settings regarding debugger

View File

@@ -326,7 +326,11 @@ object LightmapRenderer {
// why dark spots appear in the first place) // why dark spots appear in the first place)
// - Multithreading? I have absolutely no idea. // - Multithreading? I have absolutely no idea.
// - If you naively slice the screen (job area) to multithread, the seam will appear. // - If you naively slice the screen (job area) to multithread, the seam will appear.
r1(lightmap);r2(lightmap);//r3(lightmap);r4(lightmap) r1(lightmap);r2(lightmap);
if (!App.getConfigBoolean("fx_newlight")) {
r3(lightmap);r4(lightmap)
}
} }
App.measureDebugTime("Renderer.Precalculate2") { App.measureDebugTime("Renderer.Precalculate2") {
@@ -338,10 +342,13 @@ object LightmapRenderer {
} }
} }
/*App.measureDebugTime("Renderer.LightRuns2") { App.measureDebugTime("Renderer.LightRuns2") {
r1(lightmap);r2(lightmap);r3(lightmap);r4(lightmap) // two looks better than one r1(lightmap);r2(lightmap);
if (!App.getConfigBoolean("fx_newlight")) {
r3(lightmap);r4(lightmap) // two looks better than one
}
// no rendering trickery will eliminate the need of 2nd pass, even the "decay out" // no rendering trickery will eliminate the need of 2nd pass, even the "decay out"
}*/ }
} }
private fun buildLanternAndShadowMap(actorContainer: List<ActorWithBody>) { private fun buildLanternAndShadowMap(actorContainer: List<ActorWithBody>) {
@@ -580,7 +587,7 @@ object LightmapRenderer {
} }
private fun swipeLight(sx: Int, sy: Int, ex: Int, ey: Int, dx: Int, dy: Int, lightmap: UnsafeCvecArray) { private fun swipeLight(sx: Int, sy: Int, ex: Int, ey: Int, dx: Int, dy: Int, lightmap: UnsafeCvecArray) {
swipeX = sx; swipeY = sy swipeX = sx; swipeY = sy
distFromLightSrc.broadcast(0) if (App.getConfigBoolean("fx_newlight")) distFromLightSrc.broadcast(0)
while (swipeX*dx <= ex*dx && swipeY*dy <= ey*dy) { while (swipeX*dx <= ex*dx && swipeY*dy <= ey*dy) {
// conduct the task #1 // conduct the task #1
// spread towards the end // spread towards the end
@@ -590,16 +597,18 @@ object LightmapRenderer {
swipeX += dx swipeX += dx
swipeY += dy swipeY += dy
distFromLightSrc.add(1) if (App.getConfigBoolean("fx_newlight")) {
distFromLightSrc.add(1)
if (_mapLightLevelThis.getR(swipeX - dx, swipeY - dy) <= _mapLightLevelThis.getR(swipeX, swipeY)) distFromLightSrc.r = 0 if (_mapLightLevelThis.getR(swipeX - dx, swipeY - dy) <= _mapLightLevelThis.getR(swipeX, swipeY)) distFromLightSrc.r = 0
if (_mapLightLevelThis.getG(swipeX - dx, swipeY - dy) <= _mapLightLevelThis.getG(swipeX, swipeY)) distFromLightSrc.g = 0 if (_mapLightLevelThis.getG(swipeX - dx, swipeY - dy) <= _mapLightLevelThis.getG(swipeX, swipeY)) distFromLightSrc.g = 0
if (_mapLightLevelThis.getB(swipeX - dx, swipeY - dy) <= _mapLightLevelThis.getB(swipeX, swipeY)) distFromLightSrc.b = 0 if (_mapLightLevelThis.getB(swipeX - dx, swipeY - dy) <= _mapLightLevelThis.getB(swipeX, swipeY)) distFromLightSrc.b = 0
if (_mapLightLevelThis.getA(swipeX - dx, swipeY - dy) <= _mapLightLevelThis.getA(swipeX, swipeY)) distFromLightSrc.a = 0 if (_mapLightLevelThis.getA(swipeX - dx, swipeY - dy) <= _mapLightLevelThis.getA(swipeX, swipeY)) distFromLightSrc.a = 0
}
} }
swipeX = ex; swipeY = ey swipeX = ex; swipeY = ey
distFromLightSrc.broadcast(0) if (App.getConfigBoolean("fx_newlight")) distFromLightSrc.broadcast(0)
while (swipeX*dx >= sx*dx && swipeY*dy >= sy*dy) { while (swipeX*dx >= sx*dx && swipeY*dy >= sy*dy) {
// conduct the task #2 // conduct the task #2
// spread towards the start // spread towards the start
@@ -608,12 +617,14 @@ object LightmapRenderer {
swipeX -= dx swipeX -= dx
swipeY -= dy swipeY -= dy
distFromLightSrc.add(1) if (App.getConfigBoolean("fx_newlight")) {
distFromLightSrc.add(1)
if (_mapLightLevelThis.getR(swipeX + dx, swipeY + dy) <= _mapLightLevelThis.getR(swipeX, swipeY)) distFromLightSrc.r = 0 if (_mapLightLevelThis.getR(swipeX + dx, swipeY + dy) <= _mapLightLevelThis.getR(swipeX, swipeY)) distFromLightSrc.r = 0
if (_mapLightLevelThis.getG(swipeX + dx, swipeY + dy) <= _mapLightLevelThis.getG(swipeX, swipeY)) distFromLightSrc.g = 0 if (_mapLightLevelThis.getG(swipeX + dx, swipeY + dy) <= _mapLightLevelThis.getG(swipeX, swipeY)) distFromLightSrc.g = 0
if (_mapLightLevelThis.getB(swipeX + dx, swipeY + dy) <= _mapLightLevelThis.getB(swipeX, swipeY)) distFromLightSrc.b = 0 if (_mapLightLevelThis.getB(swipeX + dx, swipeY + dy) <= _mapLightLevelThis.getB(swipeX, swipeY)) distFromLightSrc.b = 0
if (_mapLightLevelThis.getA(swipeX + dx, swipeY + dy) <= _mapLightLevelThis.getA(swipeX, swipeY)) distFromLightSrc.a = 0 if (_mapLightLevelThis.getA(swipeX + dx, swipeY + dy) <= _mapLightLevelThis.getA(swipeX, swipeY)) distFromLightSrc.a = 0
}
} }
} }
@@ -789,18 +800,20 @@ object LightmapRenderer {
if (x !in 0 until LIGHTMAP_WIDTH || y !in 0 until LIGHTMAP_HEIGHT) return colourNull if (x !in 0 until LIGHTMAP_WIDTH || y !in 0 until LIGHTMAP_HEIGHT) return colourNull
/*return lightmap.getVec(x, y).lanewise { it, ch -> if (App.getConfigBoolean("fx_newlight")) {
it * (1f - darken.lane(ch) * lightScalingMagic) val newDarken: Cvec = darken.lanewise { it, ch ->
}*/ darkenConv(1f - it * lightScalingMagic)
}
val newDarken: Cvec = darken.lanewise { it, ch -> return lightmap.getVec(x, y).lanewise { it, ch ->
darkenConv(1f - it * lightScalingMagic) (it * ((newDarken.lane(ch) - distFromLightSrc.lane(ch)) / newDarken.lane(ch))).coerceAtLeast(0f)
}
} }
else {
return lightmap.getVec(x, y).lanewise { it, ch -> return lightmap.getVec(x, y).lanewise { it, ch ->
(it * ((newDarken.lane(ch) - distFromLightSrc.lane(ch)) / newDarken.lane(ch))).coerceAtLeast(0f) it * (1f - darken.lane(ch) * lightScalingMagic)
}
} }
} }
/** infix is removed to clarify the association direction */ /** infix is removed to clarify the association direction */