This commit is contained in:
DBotThePony 2022-10-05 22:19:06 +07:00
parent 08c2b5a685
commit 6cc7ae51a0
Signed by: DBot
GPG Key ID: DCC23B5715498507
2 changed files with 32 additions and 29 deletions

View File

@ -117,29 +117,29 @@ class ClientWorld(
val determineRenderers = ArrayList<ILayeredRenderer>()
client.lightRenderer.begin()
//client.lightRenderer.begin()
for (chunk in collectPositionAware(size.encasingChunkPosAABB())) {
val renderer = chunk.second.OneShotRenderer(chunk.first)
determineRenderers.add(renderer)
chunk.second.bake()
client.lightRenderer.addShadowGeometry(renderer)
//client.lightRenderer.addShadowGeometry(renderer)
}
renderLayeredList(client.gl.matrixStack, determineRenderers)
for ((lightPosition, color) in listOf(
/*for ((lightPosition, color) in listOf(
(client.screenToWorld(client.mouseCoordinatesF)) to Color.RED,
(client.screenToWorld(client.mouseCoordinatesF) + Vector2f(0.1f)) to Color.GREEN,
(client.screenToWorld(client.mouseCoordinatesF) + Vector2f(-0.1f)) to Color.BLUE,
)) {
if (isScreenspaceRender) {
val (x, y) = client.worldToScreen(lightPosition.x - 20f, lightPosition.y - 20f)
val (x2, y2) = client.worldToScreen(lightPosition.x + 20f, lightPosition.y + 20f)
val (x, y) = client.worldToScreen(lightPosition.x - 64f, lightPosition.y - 64f)
val (x2, y2) = client.worldToScreen(lightPosition.x + 64f, lightPosition.y + 64f)
client.pushScissorRect(x, client.viewportHeight - y, x2 - x, y - y2)
}
//client.lightRenderer.renderSoftLight(lightPosition, color, radius = 20f, innerRadius = 1f)
client.lightRenderer.renderSoftLight(lightPosition, color, radius = 64f, innerRadius = 2f)
if (isScreenspaceRender) {
client.popScissorRect()
@ -149,12 +149,12 @@ class ClientWorld(
val old = client.gl.blendFunc
client.gl.blendFunc = BlendFunc.MULTIPLY_BY_SRC
// client.gl.activeTexture = 0
// client.gl.texture2D = client.lightRenderer.outputTexture
// client.gl.programs.textureQuad.run()
client.gl.activeTexture = 0
client.gl.texture2D = client.lightRenderer.outputTexture
client.gl.programs.viewTextureQuad.run()
client.gl.blendFunc = old
*/
val pos = client.screenToWorld(client.mouseCoordinatesF).toDoubleVector()
/*val lightsize = 16
@ -197,6 +197,9 @@ class ClientWorld(
}
*/
//rayLightCircleNaive(pos, 48.0, falloffByTravel = 1.0, falloffByTile = 3.0)
/*
val result = rayLightCircleNaive(pos, 48.0, falloffByTravel = 1.0, falloffByTile = 3.0)
val result2 = rayLightCircleNaive(pos + Vector2d(-8.0), 24.0, falloffByTravel = 1.0, falloffByTile = 3.0)
val frame = GLFrameBuffer(client.gl)
@ -207,7 +210,7 @@ class ClientWorld(
client.gl.clearColor = Color.BLACK
glClear(GL_COLOR_BUFFER_BIT)
client.gl.blendFunc = BlendFunc.ADDITIVE
client.gl.blendFunc = BlendFunc.ADDITIVE*/
/*client.gl.quadColor {
for (row in 0 until result.rows) {
@ -243,7 +246,7 @@ class ClientWorld(
}
}*/
val lightTextureWidth = (client.viewportWidth / PIXELS_IN_STARBOUND_UNIT).roundToInt()
/*val lightTextureWidth = (client.viewportWidth / PIXELS_IN_STARBOUND_UNIT).roundToInt()
val lightTextureHeight = (client.viewportHeight / PIXELS_IN_STARBOUND_UNIT).roundToInt()
val textureBuffer = ByteBuffer.allocateDirect(lightTextureWidth * lightTextureHeight * 3)
@ -261,28 +264,28 @@ class ClientWorld(
textureBuffer.put((color * 255).toInt().coerceAtMost(255).toByte())
}
}
}
}*/
frame.unbind()
//frame.unbind()
val texture = GLTexture2D(client.gl)
// val texture = GLTexture2D(client.gl)
textureBuffer.position(0)
texture.upload(GL_RGB, lightTextureWidth, lightTextureHeight, GL_RGB, GL_UNSIGNED_BYTE, textureBuffer)
// textureBuffer.position(0)
// texture.upload(GL_RGB, lightTextureWidth, lightTextureHeight, GL_RGB, GL_UNSIGNED_BYTE, textureBuffer)
texture.textureMinFilter = GL_LINEAR
texture.textureMagFilter = GL_LINEAR
// texture.textureMinFilter = GL_LINEAR
// texture.textureMagFilter = GL_LINEAR
client.gl.blendFunc = BlendFunc.MULTIPLY_BY_SRC
// client.gl.blendFunc = BlendFunc.MULTIPLY_BY_SRC
client.gl.activeTexture = 0
client.gl.texture2D = texture
client.gl.programs.viewTextureQuad.run()
// client.gl.activeTexture = 0
// client.gl.texture2D = texture
// client.gl.programs.viewTextureQuad.run()
client.gl.blendFunc = old
// client.gl.blendFunc = old
frame.close()
texture.close()
//frame.close()
//texture.close()
physics.debugDraw()

View File

@ -473,12 +473,12 @@ abstract class World<This : World<This, ChunkType>, ChunkType : Chunk<This, Chun
currentIntensity -= falloffByTravel
}
result.add(currentIntensity to pos)
//result.add(currentIntensity to pos)
if (currentIntensity <= 0.0) {
return@castRayNaive RayFilterResult.HIT
return@castRayNaive RayFilterResult.HIT_SKIP
} else {
return@castRayNaive RayFilterResult.CONTINUE
return@castRayNaive RayFilterResult.SKIP
}
}