mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
more emissive and glow codes that fixes glow/emsv-seen-thru-foreground
This commit is contained in:
BIN
assets/mods/basegame/blocks/176_emsv.tga
LFS
Normal file
BIN
assets/mods/basegame/blocks/176_emsv.tga
LFS
Normal file
Binary file not shown.
BIN
assets/mods/basegame/blocks/208_emsv.tga
LFS
Normal file
BIN
assets/mods/basegame/blocks/208_emsv.tga
LFS
Normal file
Binary file not shown.
BIN
assets/mods/basegame/blocks/209_emsv.tga
LFS
Normal file
BIN
assets/mods/basegame/blocks/209_emsv.tga
LFS
Normal file
Binary file not shown.
BIN
assets/mods/basegame/blocks/210_emsv.tga
LFS
Normal file
BIN
assets/mods/basegame/blocks/210_emsv.tga
LFS
Normal file
Binary file not shown.
BIN
assets/mods/basegame/blocks/211_emsv.tga
LFS
Normal file
BIN
assets/mods/basegame/blocks/211_emsv.tga
LFS
Normal file
Binary file not shown.
BIN
assets/mods/basegame/blocks/212_emsv.tga
LFS
Normal file
BIN
assets/mods/basegame/blocks/212_emsv.tga
LFS
Normal file
Binary file not shown.
BIN
assets/mods/basegame/blocks/213_emsv.tga
LFS
Normal file
BIN
assets/mods/basegame/blocks/213_emsv.tga
LFS
Normal file
Binary file not shown.
BIN
assets/mods/basegame/blocks/214_emsv.tga
LFS
Normal file
BIN
assets/mods/basegame/blocks/214_emsv.tga
LFS
Normal file
Binary file not shown.
BIN
assets/mods/basegame/blocks/215_emsv.tga
LFS
Normal file
BIN
assets/mods/basegame/blocks/215_emsv.tga
LFS
Normal file
Binary file not shown.
BIN
assets/mods/basegame/blocks/216_emsv.tga
LFS
Normal file
BIN
assets/mods/basegame/blocks/216_emsv.tga
LFS
Normal file
Binary file not shown.
BIN
assets/mods/basegame/blocks/218_emsv.tga
LFS
Normal file
BIN
assets/mods/basegame/blocks/218_emsv.tga
LFS
Normal file
Binary file not shown.
BIN
assets/mods/basegame/blocks/219_emsv.tga
LFS
Normal file
BIN
assets/mods/basegame/blocks/219_emsv.tga
LFS
Normal file
Binary file not shown.
BIN
assets/mods/basegame/blocks/220_emsv.tga
LFS
Normal file
BIN
assets/mods/basegame/blocks/220_emsv.tga
LFS
Normal file
Binary file not shown.
BIN
assets/mods/basegame/blocks/221_emsv.tga
LFS
Normal file
BIN
assets/mods/basegame/blocks/221_emsv.tga
LFS
Normal file
Binary file not shown.
BIN
assets/mods/basegame/blocks/222_emsv.tga
LFS
Normal file
BIN
assets/mods/basegame/blocks/222_emsv.tga
LFS
Normal file
Binary file not shown.
BIN
assets/mods/basegame/blocks/223_emsv.tga
LFS
Normal file
BIN
assets/mods/basegame/blocks/223_emsv.tga
LFS
Normal file
Binary file not shown.
BIN
assets/mods/basegame/blocks/256_emsv.tga
LFS
Normal file
BIN
assets/mods/basegame/blocks/256_emsv.tga
LFS
Normal file
Binary file not shown.
BIN
assets/mods/basegame/blocks/257_emsv.tga
LFS
Normal file
BIN
assets/mods/basegame/blocks/257_emsv.tga
LFS
Normal file
Binary file not shown.
BIN
assets/mods/basegame/blocks/258_emsv.tga
LFS
Normal file
BIN
assets/mods/basegame/blocks/258_emsv.tga
LFS
Normal file
Binary file not shown.
BIN
assets/mods/basegame/blocks/_emsv.tga
LFS
Normal file
BIN
assets/mods/basegame/blocks/_emsv.tga
LFS
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -14,6 +14,10 @@ import net.torvald.terrarum.modulebasegame.gameactors.Pocketed
|
||||
import net.torvald.terrarum.savegame.ByteArray64Reader
|
||||
import net.torvald.terrarum.savegame.EntryID
|
||||
import net.torvald.terrarum.savegame.SimpleFileSystem
|
||||
import net.torvald.terrarum.savegame.VDFileID
|
||||
import net.torvald.terrarum.savegame.VDFileID.BODYPARTEMISSIVE_TO_ENTRY_MAP
|
||||
import net.torvald.terrarum.savegame.VDFileID.BODYPARTGLOW_TO_ENTRY_MAP
|
||||
import net.torvald.terrarum.savegame.VDFileID.BODYPART_TO_ENTRY_MAP
|
||||
import net.torvald.terrarum.serialise.Common
|
||||
import net.torvald.terrarum.spriteassembler.ADProperties
|
||||
import net.torvald.terrarum.spriteassembler.ADPropertyObject
|
||||
@@ -31,12 +35,19 @@ class AssembledSpriteAnimation(
|
||||
@Transient val adp: ADProperties,
|
||||
parentActor: ActorWithBody,
|
||||
@Transient val disk: SimpleFileSystem?, // specify if the resources for the animation is contained in the disk archive
|
||||
@Transient val bodypartToFileMap: EntryID?, // which file in the disk contains bodypart-to-fileid mapping for this particular instance of sprite animation
|
||||
@Transient val isGlow: Boolean,
|
||||
@Transient val isEmissive: Boolean
|
||||
) : SpriteAnimation(parentActor) {
|
||||
|
||||
constructor(adp: ADProperties, parentActor: ActorWithBody, isGlow: Boolean, isEmissive: Boolean) : this(adp, parentActor, null, null, isGlow, isEmissive)
|
||||
constructor(adp: ADProperties, parentActor: ActorWithBody, isGlow: Boolean, isEmissive: Boolean) : this(adp, parentActor, null, isGlow, isEmissive)
|
||||
|
||||
@Transient val bodypartToFileMap = if (isEmissive)
|
||||
BODYPARTEMISSIVE_TO_ENTRY_MAP
|
||||
else if (isGlow)
|
||||
BODYPARTGLOW_TO_ENTRY_MAP
|
||||
else
|
||||
BODYPART_TO_ENTRY_MAP
|
||||
|
||||
|
||||
var currentFrame = 0 // while this number is zero-based, the frame number on the ADP is one-based
|
||||
private set
|
||||
@@ -69,13 +80,21 @@ class AssembledSpriteAnimation(
|
||||
|
||||
val fileGetter = if (disk != null) {
|
||||
val bodypartMapping = Properties()
|
||||
bodypartMapping.load(ByteArray64Reader(disk.getFile(bodypartToFileMap!!)!!.bytes, Common.CHARSET))
|
||||
bodypartMapping.load(ByteArray64Reader(disk.getFile(bodypartToFileMap)!!.bytes, Common.CHARSET))
|
||||
|
||||
AssembleSheetPixmap.getVirtualDiskFileGetter(bodypartMapping, disk)
|
||||
}
|
||||
else AssembleSheetPixmap.getAssetsDirFileGetter(adp)
|
||||
|
||||
adp.bodyparts.forEach { res[it] = getPartTexture(fileGetter, it) }
|
||||
val fileGetterFallback = if (disk != null) {
|
||||
val bodypartMapping = Properties()
|
||||
bodypartMapping.load(ByteArray64Reader(disk.getFile(BODYPART_TO_ENTRY_MAP)!!.bytes, Common.CHARSET))
|
||||
|
||||
AssembleSheetPixmap.getVirtualDiskFileGetter(bodypartMapping, disk)
|
||||
}
|
||||
else AssembleSheetPixmap.getAssetsDirFileGetter(adp)
|
||||
|
||||
adp.bodyparts.forEach { res[it] = getPartTexture(fileGetter, fileGetterFallback, it) }
|
||||
|
||||
val (mugPixmap, headSprite0) = if (disk != null)
|
||||
AssembleSheetPixmap.getMugshotFromVirtualDisk(disk, -1025L, adp)
|
||||
@@ -225,11 +244,25 @@ class AssembledSpriteAnimation(
|
||||
// TODO fill in with armours/etc
|
||||
)
|
||||
|
||||
private fun getPartTexture(getFile: (String) -> InputStream?, partName: String): TextureRegion? {
|
||||
private fun getPartTexture(getFile: (String) -> InputStream?, getFileFallback: (String) -> InputStream?, partName: String): TextureRegion? {
|
||||
getFile(partName)?.let {
|
||||
val bytes = it.readAllBytes()
|
||||
return TextureRegion(Texture(Pixmap(bytes, 0, bytes.size)))
|
||||
}
|
||||
getFileFallback(partName)?.let {
|
||||
val bytes = it.readAllBytes()
|
||||
|
||||
// filter the image so that it's either transparent or black
|
||||
val pixmap = Pixmap(bytes, 0, bytes.size)
|
||||
for (y in 0 until pixmap.height) {
|
||||
for (x in 0 until pixmap.width) {
|
||||
val c = pixmap.getPixel(x, y)
|
||||
pixmap.drawPixel(x, y, c and 0xFF)
|
||||
}
|
||||
}
|
||||
|
||||
return TextureRegion(Texture(pixmap))
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1796,8 +1796,8 @@ open class ActorWithBody : Actor {
|
||||
if (isVisible) {
|
||||
blendNormalStraightAlpha(batch)
|
||||
if (spriteGlow != null)
|
||||
drawSpriteInGoodPosition(frameDelta, spriteGlow!!, batch, 2)
|
||||
else
|
||||
drawSpriteInGoodPosition(frameDelta, spriteGlow!!, batch, 1)
|
||||
else if (sprite != null)
|
||||
drawSpriteInGoodPosition(frameDelta, sprite!!, batch, 1, Color.BLACK)
|
||||
}
|
||||
}
|
||||
@@ -1807,7 +1807,7 @@ open class ActorWithBody : Actor {
|
||||
blendNormalStraightAlpha(batch)
|
||||
if (spriteEmissive != null)
|
||||
drawSpriteInGoodPosition(frameDelta, spriteEmissive!!, batch, 1)
|
||||
else
|
||||
else if (sprite != null)
|
||||
drawSpriteInGoodPosition(frameDelta, sprite!!, batch, 2, Color.BLACK)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,7 +179,6 @@ object ReadActor {
|
||||
actor.animDesc!!,
|
||||
actor,
|
||||
if (bodypartsFile != null) disk else null,
|
||||
if (bodypartsFile != null) BODYPART_TO_ENTRY_MAP else null,
|
||||
false, false
|
||||
)
|
||||
|
||||
@@ -189,7 +188,6 @@ object ReadActor {
|
||||
actor.animDescGlow!!,
|
||||
actor,
|
||||
if (bodypartsFile != null) disk else null,
|
||||
if (bodypartsFile != null) BODYPARTGLOW_TO_ENTRY_MAP else null,
|
||||
true, false
|
||||
)
|
||||
}
|
||||
@@ -200,7 +198,6 @@ object ReadActor {
|
||||
actor.animDescEmissive!!,
|
||||
actor,
|
||||
if (bodypartsFile != null) disk else null,
|
||||
if (bodypartsFile != null) BODYPARTEMISSIVE_TO_ENTRY_MAP else null,
|
||||
false, true
|
||||
)
|
||||
}
|
||||
@@ -223,50 +220,4 @@ object ReadActor {
|
||||
}
|
||||
}
|
||||
|
||||
private fun makeSprite(mode: Int, actor: IngamePlayer, disk: SimpleFileSystem, file: EntryFile?, bodypartsFile: EntryFile?) {
|
||||
val animDesc = when (mode) {
|
||||
0 -> actor.animDesc
|
||||
1 -> actor.animDescGlow
|
||||
2 -> actor.animDescEmissive
|
||||
else -> throw IllegalArgumentException()
|
||||
}
|
||||
|
||||
if (file != null) {
|
||||
when (mode) {
|
||||
0 -> { actor.animDesc = ADProperties(ByteArray64Reader(file.bytes, Common.CHARSET)) }
|
||||
1 -> { actor.animDescGlow = ADProperties(ByteArray64Reader(file.bytes, Common.CHARSET)) }
|
||||
2 -> { actor.animDescEmissive = ADProperties(ByteArray64Reader(file.bytes, Common.CHARSET)) }
|
||||
else -> throw IllegalArgumentException()
|
||||
}
|
||||
|
||||
when (mode) {
|
||||
0 -> { actor.sprite = AssembledSpriteAnimation(
|
||||
actor.animDesc!!,
|
||||
actor,
|
||||
if (bodypartsFile != null) disk else null,
|
||||
if (bodypartsFile != null) BODYPART_TO_ENTRY_MAP else null,
|
||||
false, false
|
||||
) }
|
||||
1 -> { actor.spriteGlow = AssembledSpriteAnimation(
|
||||
actor.animDescGlow!!,
|
||||
actor,
|
||||
if (bodypartsFile != null) disk else null,
|
||||
if (bodypartsFile != null) BODYPARTGLOW_TO_ENTRY_MAP else null,
|
||||
true, false
|
||||
) }
|
||||
2 -> { actor.spriteEmissive = AssembledSpriteAnimation(
|
||||
actor.animDescEmissive!!,
|
||||
actor,
|
||||
if (bodypartsFile != null) disk else null,
|
||||
if (bodypartsFile != null) BODYPARTEMISSIVE_TO_ENTRY_MAP else null,
|
||||
false, true
|
||||
) }
|
||||
else -> throw IllegalArgumentException()
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,5 @@ const vec2 boolean = vec2(0.0, 1.0);
|
||||
void main(void) {
|
||||
vec4 colorTex0 = texture(u_texture, v_texCoords); // lightmap (RGB) pre-mixed
|
||||
vec4 colorTex1 = texture(tex1, v_texCoords); // lightmap (A) pre-mixed
|
||||
// fragColor = (max(colorTex0, colorTex1) * boolean.yyyx) + (colorTex0 * boolean.xxxy);
|
||||
fragColor = fma(max(colorTex0, colorTex1), boolean.yyyx, colorTex0 * boolean.xxxy);
|
||||
}
|
||||
@@ -16,6 +16,10 @@ const vec2 boolean = vec2(0.0, 1.0);
|
||||
void main(void) {
|
||||
vec4 colorTex0 = texture(u_texture, v_texCoords); // lightmap (RGB) pre-mixed
|
||||
vec4 colorTex1 = texture(tex1, vec2(v_texCoords.x, 1.0 - v_texCoords.y)); // lightmap (A) pre-mixed
|
||||
// fragColor = (max(colorTex0, colorTex1) * boolean.yyyx) + (colorTex0 * boolean.xxxy);
|
||||
fragColor = fma(max(colorTex0, colorTex1), boolean.yyyx, colorTex0 * boolean.xxxy);
|
||||
// if (colorTex0.a > colorTex1.a) {
|
||||
fragColor = fma(max(colorTex0, colorTex1), boolean.yyyx, colorTex0 * boolean.xxxy);
|
||||
// }
|
||||
// else {
|
||||
// fragColor = fma(max(colorTex0, colorTex1), boolean.yyyx, colorTex1 * boolean.xxxy);
|
||||
// }
|
||||
}
|
||||
Reference in New Issue
Block a user