mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-12 11:34:05 +09:00
no shadows against skybox
This commit is contained in:
@@ -84,6 +84,7 @@ object IngameRenderer : Disposable {
|
|||||||
private lateinit var fboRGBactorsMiddleShadow: Float16FrameBuffer // for large shadow eff; A channel is for glow effects so they don't get shadow effects
|
private lateinit var fboRGBactorsMiddleShadow: Float16FrameBuffer // for large shadow eff; A channel is for glow effects so they don't get shadow effects
|
||||||
private lateinit var fboRGBterrainShadow: Float16FrameBuffer // for large shadow eff; A channel is for glow effects so they don't get shadow effects
|
private lateinit var fboRGBterrainShadow: Float16FrameBuffer // for large shadow eff; A channel is for glow effects so they don't get shadow effects
|
||||||
|
|
||||||
|
private lateinit var fboRGBwall: Float16FrameBuffer // for masking away the shadows
|
||||||
|
|
||||||
private lateinit var rgbTex: TextureRegion
|
private lateinit var rgbTex: TextureRegion
|
||||||
private lateinit var aTex: TextureRegion
|
private lateinit var aTex: TextureRegion
|
||||||
@@ -511,7 +512,6 @@ object IngameRenderer : Disposable {
|
|||||||
fboRGB_lightMixed0.inAction(null, null) { clearBuffer() }
|
fboRGB_lightMixed0.inAction(null, null) { clearBuffer() }
|
||||||
fboRGB_lightMixed.inAction(null, null) { clearBuffer() }
|
fboRGB_lightMixed.inAction(null, null) { clearBuffer() }
|
||||||
|
|
||||||
|
|
||||||
fboRGBactorsBehind.inAction(camera, batch) {
|
fboRGBactorsBehind.inAction(camera, batch) {
|
||||||
clearBuffer()
|
clearBuffer()
|
||||||
setCameraPosition(0f, 0f)
|
setCameraPosition(0f, 0f)
|
||||||
@@ -539,6 +539,12 @@ object IngameRenderer : Disposable {
|
|||||||
}
|
}
|
||||||
BlurMgr.makeBlur(fboRGBactorsMiddle, fboRGBactorsMiddleShadow, 2.5f)
|
BlurMgr.makeBlur(fboRGBactorsMiddle, fboRGBactorsMiddleShadow, 2.5f)
|
||||||
|
|
||||||
|
fboRGBwall.inAction(camera, batch) {
|
||||||
|
clearBuffer()
|
||||||
|
setCameraPosition(0f, 0f)
|
||||||
|
BlocksDrawer.drawWall(batch.projectionMatrix, false)
|
||||||
|
}
|
||||||
|
|
||||||
fboRGBterrain.inAction(camera, batch) {
|
fboRGBterrain.inAction(camera, batch) {
|
||||||
clearBuffer()
|
clearBuffer()
|
||||||
setCameraPosition(0f, 0f)
|
setCameraPosition(0f, 0f)
|
||||||
@@ -546,24 +552,41 @@ object IngameRenderer : Disposable {
|
|||||||
}
|
}
|
||||||
BlurMgr.makeBlur(fboRGBterrain, fboRGBterrainShadow, 2.5f)
|
BlurMgr.makeBlur(fboRGBterrain, fboRGBterrainShadow, 2.5f)
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
fboRGB.inAction(camera, batch) {
|
fboRGB.inAction(camera, batch) {
|
||||||
setCameraPosition(0f, 0f)
|
setCameraPosition(0f, 0f)
|
||||||
|
|
||||||
BlocksDrawer.drawWall(batch.projectionMatrix, false)
|
batch.inUse {
|
||||||
|
batch.shader = null
|
||||||
|
batch.color = Color.WHITE
|
||||||
|
batch.drawFlipped(fboRGBwall.colorBufferTexture, 0f, 0f)
|
||||||
|
}
|
||||||
|
|
||||||
// draw actor shadow BEFORE the terrain draw
|
// draw actor shadow BEFORE the terrain draw
|
||||||
|
fboRGBwall.colorBufferTexture.bind(1)
|
||||||
|
Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0) // so that batch that comes next will bind any tex to it
|
||||||
|
|
||||||
batch.inUse {
|
batch.inUse {
|
||||||
batch.shader = shaderShadowShallow
|
batch.shader = shaderShadowShallow
|
||||||
|
shaderShadowShallow.setUniformi("u_wall", 1)
|
||||||
setCameraPosition(0f, 0f)
|
setCameraPosition(0f, 0f)
|
||||||
batch.drawFlipped(fboRGBactorsBehindShadow.colorBufferTexture, 0f, 0f)
|
batch.drawFlipped(fboRGBactorsBehindShadow.colorBufferTexture, 0f, 0f)
|
||||||
|
}
|
||||||
|
|
||||||
|
fboRGBwall.colorBufferTexture.bind(1)
|
||||||
|
Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0) // so that batch that comes next will bind any tex to it
|
||||||
|
|
||||||
|
batch.inUse {
|
||||||
batch.shader = shaderShadowDeep
|
batch.shader = shaderShadowDeep
|
||||||
|
shaderShadowDeep.setUniformi("u_wall", 1)
|
||||||
setCameraPosition(0f, 0f)
|
setCameraPosition(0f, 0f)
|
||||||
batch.drawFlipped(fboRGBterrainShadow.colorBufferTexture, 0f, 0f)
|
batch.drawFlipped(fboRGBterrainShadow.colorBufferTexture, 0f, 0f)
|
||||||
batch.drawFlipped(fboRGBactorsMiddleShadow.colorBufferTexture, 0f, 0f)
|
batch.drawFlipped(fboRGBactorsMiddleShadow.colorBufferTexture, 0f, 0f)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Gdx.gl20.glActiveTexture(0)
|
||||||
|
|
||||||
// draw behind actors and particles
|
// draw behind actors and particles
|
||||||
batch.inUse {
|
batch.inUse {
|
||||||
batch.shader = shaderForActors
|
batch.shader = shaderForActors
|
||||||
@@ -1288,6 +1311,7 @@ object IngameRenderer : Disposable {
|
|||||||
fboRGBactorsBehindShadow = Float16FrameBuffer(width, height, false)
|
fboRGBactorsBehindShadow = Float16FrameBuffer(width, height, false)
|
||||||
fboRGBactorsMiddleShadow = Float16FrameBuffer(width, height, false)
|
fboRGBactorsMiddleShadow = Float16FrameBuffer(width, height, false)
|
||||||
fboRGBterrainShadow = Float16FrameBuffer(width, height, false)
|
fboRGBterrainShadow = Float16FrameBuffer(width, height, false)
|
||||||
|
fboRGBwall = Float16FrameBuffer(width, height, false)
|
||||||
lightmapFbo = Float16FrameBuffer(
|
lightmapFbo = Float16FrameBuffer(
|
||||||
LightmapRenderer.lightBuffer.width * LightmapRenderer.DRAW_TILE_SIZE.toInt(),
|
LightmapRenderer.lightBuffer.width * LightmapRenderer.DRAW_TILE_SIZE.toInt(),
|
||||||
LightmapRenderer.lightBuffer.height * LightmapRenderer.DRAW_TILE_SIZE.toInt(),
|
LightmapRenderer.lightBuffer.height * LightmapRenderer.DRAW_TILE_SIZE.toInt(),
|
||||||
@@ -1356,6 +1380,7 @@ object IngameRenderer : Disposable {
|
|||||||
if (::fboRGBactorsBehindShadow.isInitialized) fboRGBactorsBehindShadow.tryDispose()
|
if (::fboRGBactorsBehindShadow.isInitialized) fboRGBactorsBehindShadow.tryDispose()
|
||||||
if (::fboRGBactorsMiddleShadow.isInitialized) fboRGBactorsMiddleShadow.tryDispose()
|
if (::fboRGBactorsMiddleShadow.isInitialized) fboRGBactorsMiddleShadow.tryDispose()
|
||||||
if (::fboRGBterrainShadow.isInitialized) fboRGBterrainShadow.tryDispose()
|
if (::fboRGBterrainShadow.isInitialized) fboRGBterrainShadow.tryDispose()
|
||||||
|
if (::fboRGBwall.isInitialized) fboRGBwall.tryDispose()
|
||||||
|
|
||||||
blurtex0.tryDispose()
|
blurtex0.tryDispose()
|
||||||
|
|
||||||
|
|||||||
@@ -132,6 +132,11 @@ internal object ExportFBO : ConsoleCommand {
|
|||||||
fun fborgbterrainshadow(): FrameBuffer {
|
fun fborgbterrainshadow(): FrameBuffer {
|
||||||
return IngameRenderer.extortField<Float16FrameBuffer>("fboRGBterrainShadow")!!
|
return IngameRenderer.extortField<Float16FrameBuffer>("fboRGBterrainShadow")!!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ExportFBOCmd("Framebuffer for wall blocks")
|
||||||
|
fun fborgbwall(): FrameBuffer {
|
||||||
|
return IngameRenderer.extortField<Float16FrameBuffer>("fboRGBwall")!!
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal annotation class ExportFBOCmd(val description: String)
|
internal annotation class ExportFBOCmd(val description: String)
|
||||||
@@ -7,12 +7,14 @@ in vec4 v_color;
|
|||||||
in vec4 v_generic;
|
in vec4 v_generic;
|
||||||
in vec2 v_texCoords;
|
in vec2 v_texCoords;
|
||||||
uniform sampler2D u_texture;
|
uniform sampler2D u_texture;
|
||||||
|
uniform sampler2D u_wall;
|
||||||
out vec4 fragColor;
|
out vec4 fragColor;
|
||||||
|
|
||||||
vec4 mult = vec4(0.0, 0.0, 0.0, 1.0);
|
vec4 mult = vec4(0.0, 0.0, 0.0, 1.0);
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
vec4 backcol = texture(u_wall, v_texCoords);
|
||||||
vec4 incol = texture(u_texture, v_texCoords);
|
vec4 incol = texture(u_texture, v_texCoords);
|
||||||
vec4 outcol = vec4(incol.rgb, pow(incol.a, 1.4142));
|
vec4 outcol = vec4(incol.rgb, backcol.a * pow(incol.a, 1.4142));
|
||||||
fragColor = mult * outcol;
|
fragColor = mult * outcol;
|
||||||
}
|
}
|
||||||
@@ -7,12 +7,14 @@ in vec4 v_color;
|
|||||||
in vec4 v_generic;
|
in vec4 v_generic;
|
||||||
in vec2 v_texCoords;
|
in vec2 v_texCoords;
|
||||||
uniform sampler2D u_texture;
|
uniform sampler2D u_texture;
|
||||||
|
uniform sampler2D u_wall;
|
||||||
out vec4 fragColor;
|
out vec4 fragColor;
|
||||||
|
|
||||||
vec4 mult = vec4(0.0, 0.0, 0.0, 0.703);
|
vec4 mult = vec4(0.0, 0.0, 0.0, 0.703);
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
vec4 backcol = texture(u_wall, v_texCoords);
|
||||||
vec4 incol = texture(u_texture, v_texCoords);
|
vec4 incol = texture(u_texture, v_texCoords);
|
||||||
vec4 outcol = vec4(incol.rgb, pow(incol.a, 1.4142));
|
vec4 outcol = vec4(incol.rgb, backcol.a * pow(incol.a, 1.4142));
|
||||||
fragColor = mult * outcol;
|
fragColor = mult * outcol;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user