mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +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 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 aTex: TextureRegion
|
||||
@@ -511,7 +512,6 @@ object IngameRenderer : Disposable {
|
||||
fboRGB_lightMixed0.inAction(null, null) { clearBuffer() }
|
||||
fboRGB_lightMixed.inAction(null, null) { clearBuffer() }
|
||||
|
||||
|
||||
fboRGBactorsBehind.inAction(camera, batch) {
|
||||
clearBuffer()
|
||||
setCameraPosition(0f, 0f)
|
||||
@@ -539,6 +539,12 @@ object IngameRenderer : Disposable {
|
||||
}
|
||||
BlurMgr.makeBlur(fboRGBactorsMiddle, fboRGBactorsMiddleShadow, 2.5f)
|
||||
|
||||
fboRGBwall.inAction(camera, batch) {
|
||||
clearBuffer()
|
||||
setCameraPosition(0f, 0f)
|
||||
BlocksDrawer.drawWall(batch.projectionMatrix, false)
|
||||
}
|
||||
|
||||
fboRGBterrain.inAction(camera, batch) {
|
||||
clearBuffer()
|
||||
setCameraPosition(0f, 0f)
|
||||
@@ -546,24 +552,41 @@ object IngameRenderer : Disposable {
|
||||
}
|
||||
BlurMgr.makeBlur(fboRGBterrain, fboRGBterrainShadow, 2.5f)
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
fboRGB.inAction(camera, batch) {
|
||||
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
|
||||
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 = shaderShadowShallow
|
||||
shaderShadowShallow.setUniformi("u_wall", 1)
|
||||
setCameraPosition(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
|
||||
shaderShadowDeep.setUniformi("u_wall", 1)
|
||||
setCameraPosition(0f, 0f)
|
||||
batch.drawFlipped(fboRGBterrainShadow.colorBufferTexture, 0f, 0f)
|
||||
batch.drawFlipped(fboRGBactorsMiddleShadow.colorBufferTexture, 0f, 0f)
|
||||
}
|
||||
|
||||
// Gdx.gl20.glActiveTexture(0)
|
||||
|
||||
// draw behind actors and particles
|
||||
batch.inUse {
|
||||
batch.shader = shaderForActors
|
||||
@@ -1288,6 +1311,7 @@ object IngameRenderer : Disposable {
|
||||
fboRGBactorsBehindShadow = Float16FrameBuffer(width, height, false)
|
||||
fboRGBactorsMiddleShadow = Float16FrameBuffer(width, height, false)
|
||||
fboRGBterrainShadow = Float16FrameBuffer(width, height, false)
|
||||
fboRGBwall = Float16FrameBuffer(width, height, false)
|
||||
lightmapFbo = Float16FrameBuffer(
|
||||
LightmapRenderer.lightBuffer.width * 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 (::fboRGBactorsMiddleShadow.isInitialized) fboRGBactorsMiddleShadow.tryDispose()
|
||||
if (::fboRGBterrainShadow.isInitialized) fboRGBterrainShadow.tryDispose()
|
||||
if (::fboRGBwall.isInitialized) fboRGBwall.tryDispose()
|
||||
|
||||
blurtex0.tryDispose()
|
||||
|
||||
|
||||
@@ -132,6 +132,11 @@ internal object ExportFBO : ConsoleCommand {
|
||||
fun fborgbterrainshadow(): FrameBuffer {
|
||||
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)
|
||||
@@ -7,12 +7,14 @@ in vec4 v_color;
|
||||
in vec4 v_generic;
|
||||
in vec2 v_texCoords;
|
||||
uniform sampler2D u_texture;
|
||||
uniform sampler2D u_wall;
|
||||
out vec4 fragColor;
|
||||
|
||||
vec4 mult = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
|
||||
void main() {
|
||||
vec4 backcol = texture(u_wall, 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;
|
||||
}
|
||||
@@ -7,12 +7,14 @@ in vec4 v_color;
|
||||
in vec4 v_generic;
|
||||
in vec2 v_texCoords;
|
||||
uniform sampler2D u_texture;
|
||||
uniform sampler2D u_wall;
|
||||
out vec4 fragColor;
|
||||
|
||||
vec4 mult = vec4(0.0, 0.0, 0.0, 0.703);
|
||||
|
||||
void main() {
|
||||
vec4 backcol = texture(u_wall, 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;
|
||||
}
|
||||
Reference in New Issue
Block a user