mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-17 03:05:30 -04:00
Mimic screen text fading for holograms.
Performance might be affected (definitely improved but I can't notice it)
This commit is contained in:
parent
c4105d5197
commit
ebbd3c2ea6
@ -66,6 +66,12 @@ opencomputers {
|
|||||||
# hologram projector when at maximum scale. Render distance is scaled
|
# hologram projector when at maximum scale. Render distance is scaled
|
||||||
# down with the actual scale of the hologram.
|
# down with the actual scale of the hologram.
|
||||||
hologramRenderDistance: 64
|
hologramRenderDistance: 64
|
||||||
|
|
||||||
|
# The distance at which to start fading out the hologram (as with
|
||||||
|
# hologramRenderDistance). This is purely cosmetic, to avoid image
|
||||||
|
# disappearing instantly when moving too far away from a projector.
|
||||||
|
# It does not affect performance. Holograms are transparent anyway.
|
||||||
|
hologramFadeStartDistance: 48
|
||||||
}
|
}
|
||||||
|
|
||||||
# Computer related settings, concerns server performance and security.
|
# Computer related settings, concerns server performance and security.
|
||||||
|
@ -31,6 +31,7 @@ class Settings(config: Config) {
|
|||||||
val robotLabels = config.getBoolean("client.robotLabels")
|
val robotLabels = config.getBoolean("client.robotLabels")
|
||||||
val soundVolume = config.getDouble("client.soundVolume").toFloat max 0 min 2
|
val soundVolume = config.getDouble("client.soundVolume").toFloat max 0 min 2
|
||||||
val fontCharScale = config.getDouble("client.fontCharScale") max 0.5 min 2
|
val fontCharScale = config.getDouble("client.fontCharScale") max 0.5 min 2
|
||||||
|
val hologramFadeStartDistance = config.getDouble("client.hologramFadeStartDistance") max 0
|
||||||
val hologramRenderDistance = config.getDouble("client.hologramRenderDistance") max 0
|
val hologramRenderDistance = config.getDouble("client.hologramRenderDistance") max 0
|
||||||
|
|
||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
|
@ -34,6 +34,11 @@ object HologramRenderer extends TileEntitySpecialRenderer with Callable[Int] wit
|
|||||||
RenderState.makeItBlend()
|
RenderState.makeItBlend()
|
||||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE)
|
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE)
|
||||||
|
|
||||||
|
val playerDistSq = x*x + y*y + z*z
|
||||||
|
val maxDistSq = hologram.getMaxRenderDistanceSquared
|
||||||
|
val fadeDistSq = hologram.getFadeStartDistanceSquared
|
||||||
|
RenderState.setBlendAlpha(0.75f * (if (playerDistSq > fadeDistSq) math.max(0, 1 - ((playerDistSq - fadeDistSq) / (maxDistSq - fadeDistSq)).toFloat) else 1))
|
||||||
|
|
||||||
GL11.glPushMatrix()
|
GL11.glPushMatrix()
|
||||||
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5)
|
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5)
|
||||||
GL11.glScaled(1.001, 1.001, 1.001) // Avoid z-fighting with other blocks.
|
GL11.glScaled(1.001, 1.001, 1.001) // Avoid z-fighting with other blocks.
|
||||||
@ -150,7 +155,7 @@ object HologramRenderer extends TileEntitySpecialRenderer with Callable[Int] wit
|
|||||||
for (hz <- 0 until hologram.width) {
|
for (hz <- 0 until hologram.width) {
|
||||||
for (hy <- 0 until hologram.height) {
|
for (hy <- 0 until hologram.height) {
|
||||||
if (isSolid(hx, hy, hz)) {
|
if (isSolid(hx, hy, hz)) {
|
||||||
val v: Int = (192 << 24) + hologram.colors(value(hx, hy, hz) - 1)
|
val v: Int = hologram.colors(value(hx, hy, hz) - 1)
|
||||||
// South
|
// South
|
||||||
if (!isSolid(hx, hy, hz + 1)) {
|
if (!isSolid(hx, hy, hz + 1)) {
|
||||||
tmpBuf.put(c)
|
tmpBuf.put(c)
|
||||||
@ -252,7 +257,7 @@ object HologramRenderer extends TileEntitySpecialRenderer with Callable[Int] wit
|
|||||||
GL11.glInterleavedArrays(GL11.GL_T2F_V3F, 0, 0)
|
GL11.glInterleavedArrays(GL11.GL_T2F_V3F, 0, 0)
|
||||||
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, privateBuf)
|
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, privateBuf)
|
||||||
GL11.glEnableClientState(GL11.GL_COLOR_ARRAY)
|
GL11.glEnableClientState(GL11.GL_COLOR_ARRAY)
|
||||||
GL11.glColorPointer(4, GL11.GL_UNSIGNED_BYTE, 0, 0)
|
GL11.glColorPointer(3, GL11.GL_UNSIGNED_BYTE, 4, 0)
|
||||||
GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, privateBuf)
|
GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, privateBuf)
|
||||||
|
|
||||||
GL11.glDrawElements(GL11.GL_QUADS, hologram.visibleQuads * 4, GL11.GL_UNSIGNED_INT, hologram.width * hologram.width * hologram.height * 24 * 4)
|
GL11.glDrawElements(GL11.GL_QUADS, hologram.visibleQuads * 4, GL11.GL_UNSIGNED_INT, hologram.width * hologram.width * hologram.height * 24 * 4)
|
||||||
|
@ -278,6 +278,7 @@ class Hologram(var tier: Int) extends traits.Environment with SidedEnvironment w
|
|||||||
override def shouldRenderInPass(pass: Int) = pass == 1
|
override def shouldRenderInPass(pass: Int) = pass == 1
|
||||||
|
|
||||||
override def getMaxRenderDistanceSquared = scale / Settings.hologramMaxScaleByTier.max * Settings.get.hologramRenderDistance * Settings.get.hologramRenderDistance
|
override def getMaxRenderDistanceSquared = scale / Settings.hologramMaxScaleByTier.max * Settings.get.hologramRenderDistance * Settings.get.hologramRenderDistance
|
||||||
|
def getFadeStartDistanceSquared = scale / Settings.hologramMaxScaleByTier.max * Settings.get.hologramFadeStartDistance * Settings.get.hologramFadeStartDistance
|
||||||
|
|
||||||
override def getRenderBoundingBox = AxisAlignedBB.getAABBPool.getAABB(xCoord + 0.5 - 1.5 * scale, yCoord, zCoord - scale, xCoord + 0.5 + 1.5 * scale, yCoord + 0.25 + 2 * scale, zCoord + 0.5 + 1.5 * scale)
|
override def getRenderBoundingBox = AxisAlignedBB.getAABBPool.getAABB(xCoord + 0.5 - 1.5 * scale, yCoord, zCoord - scale, xCoord + 0.5 + 1.5 * scale, yCoord + 0.25 + 2 * scale, zCoord + 0.5 + 1.5 * scale)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user