mirror of
https://github.com/Eaglercraft-Archive/Eaglercraftx-1.8.8-src.git
synced 2025-06-27 18:38:14 -05:00
Update #18 - Final release, added PBR shaders
This commit is contained in:
@ -29,6 +29,7 @@ public class AcceleratedEffectRenderer implements IAcceleratedParticleEngine {
|
||||
private float f4;
|
||||
private float f5;
|
||||
|
||||
@Override
|
||||
public void begin(float partialTicks) {
|
||||
this.partialTicks = partialTicks;
|
||||
InstancedParticleRenderer.begin();
|
||||
@ -42,6 +43,7 @@ public class AcceleratedEffectRenderer implements IAcceleratedParticleEngine {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(float texCoordWidth, float texCoordHeight) {
|
||||
InstancedParticleRenderer.render(texCoordWidth, texCoordHeight, 0.0625f, f1, f5, f2, f3, f4);
|
||||
}
|
||||
|
@ -58,7 +58,8 @@ public class ChunkUpdateManager {
|
||||
RenderChunk r = generator.getRenderChunk();
|
||||
try {
|
||||
r.resortTransparency(f, f1, f2, generator);
|
||||
if(generator.getCompiledChunk().isLayerEmpty(EnumWorldBlockLayer.TRANSLUCENT)) {
|
||||
CompiledChunk ch = generator.getCompiledChunk();
|
||||
if(ch.isLayerEmpty(EnumWorldBlockLayer.TRANSLUCENT) && ch.isLayerEmpty(EnumWorldBlockLayer.REALISTIC_WATER)) {
|
||||
throw new EmptyBlockLayerException();
|
||||
}
|
||||
}catch(EmptyBlockLayerException ex) {
|
||||
@ -82,9 +83,16 @@ public class ChunkUpdateManager {
|
||||
}
|
||||
generator.getRenderChunk().setCompiledChunk(compiledchunk);
|
||||
} else if (chunkcompiletaskgenerator$type == ChunkCompileTaskGenerator.Type.RESORT_TRANSPARENCY) {
|
||||
this.uploadChunk(EnumWorldBlockLayer.TRANSLUCENT, generator.getRegionRenderCacheBuilder()
|
||||
.getWorldRendererByLayer(EnumWorldBlockLayer.TRANSLUCENT),
|
||||
generator.getRenderChunk(), compiledchunk);
|
||||
if(!compiledchunk.isLayerEmpty(EnumWorldBlockLayer.TRANSLUCENT)) {
|
||||
this.uploadChunk(EnumWorldBlockLayer.TRANSLUCENT, generator.getRegionRenderCacheBuilder()
|
||||
.getWorldRendererByLayer(EnumWorldBlockLayer.TRANSLUCENT),
|
||||
generator.getRenderChunk(), compiledchunk);
|
||||
}
|
||||
if(!compiledchunk.isLayerEmpty(EnumWorldBlockLayer.REALISTIC_WATER)) {
|
||||
this.uploadChunk(EnumWorldBlockLayer.REALISTIC_WATER, generator.getRegionRenderCacheBuilder()
|
||||
.getWorldRendererByLayer(EnumWorldBlockLayer.REALISTIC_WATER),
|
||||
generator.getRenderChunk(), compiledchunk);
|
||||
}
|
||||
generator.getRenderChunk().setCompiledChunk(compiledchunk);
|
||||
generator.setStatus(ChunkCompileTaskGenerator.Status.DONE);
|
||||
}
|
||||
|
@ -9,6 +9,9 @@ import java.util.concurrent.Callable;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.HString;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.IFramebufferGL;
|
||||
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
|
||||
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
|
||||
import net.lax1dude.eaglercraft.v1_8.opengl.ImageData;
|
||||
import net.minecraft.client.renderer.texture.TextureClock;
|
||||
import net.minecraft.client.renderer.texture.TextureCompass;
|
||||
@ -34,24 +37,26 @@ import net.minecraft.util.ResourceLocation;
|
||||
*
|
||||
*/
|
||||
public class EaglerTextureAtlasSprite {
|
||||
private final String iconName;
|
||||
|
||||
private static final Logger logger = LogManager.getLogger("EaglerTextureAtlasSprite");
|
||||
|
||||
protected final String iconName;
|
||||
protected List<int[][]> framesTextureData = Lists.newArrayList();
|
||||
protected int[][] interpolatedFrameData;
|
||||
private AnimationMetadataSection animationMetadata;
|
||||
private int cacheInterpolateSteps;
|
||||
protected AnimationMetadataSection animationMetadata;
|
||||
protected boolean rotated;
|
||||
protected int originX;
|
||||
protected int originY;
|
||||
protected int width;
|
||||
protected int height;
|
||||
private float minU;
|
||||
private float maxU;
|
||||
private float minV;
|
||||
private float maxV;
|
||||
protected float minU;
|
||||
protected float maxU;
|
||||
protected float minV;
|
||||
protected float maxV;
|
||||
protected int frameCounter;
|
||||
protected int tickCounter;
|
||||
private static String locationNameClock = "builtin/clock";
|
||||
private static String locationNameCompass = "builtin/compass";
|
||||
protected static String locationNameClock = "builtin/clock";
|
||||
protected static String locationNameCompass = "builtin/compass";
|
||||
|
||||
protected TextureAnimationCache animationCache = null;
|
||||
|
||||
@ -143,7 +148,7 @@ public class EaglerTextureAtlasSprite {
|
||||
return this.iconName;
|
||||
}
|
||||
|
||||
public void updateAnimation() {
|
||||
public void updateAnimation(IFramebufferGL[] copyColorFramebuffer) {
|
||||
if(animationCache == null) {
|
||||
throw new IllegalStateException("Animation cache for '" + this.iconName + "' was never baked!");
|
||||
}
|
||||
@ -156,7 +161,7 @@ public class EaglerTextureAtlasSprite {
|
||||
this.tickCounter = 0;
|
||||
int k = this.animationMetadata.getFrameIndex(this.frameCounter);
|
||||
if (i != k && k >= 0 && k < this.framesTextureData.size()) {
|
||||
animationCache.copyFrameLevelsToTex2D(k, this.originX, this.originY, this.width, this.height);
|
||||
animationCache.copyFrameLevelsToTex2D(k, this.originX, this.originY, this.width, this.height, copyColorFramebuffer);
|
||||
}
|
||||
} else if (this.animationMetadata.isInterpolate()) {
|
||||
float f = 1.0f - (float) this.tickCounter / (float) this.animationMetadata.getFrameTimeSingle(this.frameCounter);
|
||||
@ -165,7 +170,7 @@ public class EaglerTextureAtlasSprite {
|
||||
: this.animationMetadata.getFrameCount();
|
||||
int k = this.animationMetadata.getFrameIndex((this.frameCounter + 1) % j);
|
||||
if (i != k && k >= 0 && k < this.framesTextureData.size()) {
|
||||
animationCache.copyInterpolatedFrameLevelsToTex2D(i, k, f, this.originX, this.originY, this.width, this.height);
|
||||
animationCache.copyInterpolatedFrameLevelsToTex2D(i, k, f, this.originX, this.originY, this.width, this.height, copyColorFramebuffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -292,20 +297,19 @@ public class EaglerTextureAtlasSprite {
|
||||
if(animationCache == null) {
|
||||
animationCache = new TextureAnimationCache(width, height, mipLevels);
|
||||
}
|
||||
animationCache.initialize(framesTextureData, animationMetadata.isInterpolate());
|
||||
animationCache.initialize(framesTextureData);
|
||||
}
|
||||
}
|
||||
|
||||
private void allocateFrameTextureData(int index) {
|
||||
protected void allocateFrameTextureData(int index) {
|
||||
if (this.framesTextureData.size() <= index) {
|
||||
for (int i = this.framesTextureData.size(); i <= index; ++i) {
|
||||
this.framesTextureData.add((int[][]) null);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private static int[][] getFrameTextureData(int[][] data, int rows, int columns, int parInt3) {
|
||||
protected static int[][] getFrameTextureData(int[][] data, int rows, int columns, int parInt3) {
|
||||
int[][] aint = new int[data.length][];
|
||||
|
||||
for (int i = 0; i < data.length; ++i) {
|
||||
@ -335,7 +339,7 @@ public class EaglerTextureAtlasSprite {
|
||||
this.framesTextureData = newFramesTextureData;
|
||||
}
|
||||
|
||||
private void resetSprite() {
|
||||
protected void resetSprite() {
|
||||
this.animationMetadata = null;
|
||||
this.setFramesTextureData(Lists.newArrayList());
|
||||
this.frameCounter = 0;
|
||||
@ -352,4 +356,23 @@ public class EaglerTextureAtlasSprite {
|
||||
+ this.height + ", width=" + this.width + ", u0=" + this.minU + ", u1=" + this.maxU + ", v0="
|
||||
+ this.minV + ", v1=" + this.maxV + '}';
|
||||
}
|
||||
|
||||
public void loadSpritePBR(ImageData[][] imageDatas, AnimationMetadataSection animationmetadatasection,
|
||||
boolean dontAnimateNormals, boolean dontAnimateMaterial) {
|
||||
Throwable t = new UnsupportedOperationException("PBR is not enabled");
|
||||
try {
|
||||
throw t;
|
||||
}catch(Throwable tt) {
|
||||
logger.error(t);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateAnimationPBR(IFramebufferGL[] copyColorFramebuffer, IFramebufferGL[] copyMaterialFramebuffer, int materialTexOffset) {
|
||||
Throwable t = new UnsupportedOperationException("PBR is not enabled");
|
||||
try {
|
||||
throw t;
|
||||
}catch(Throwable tt) {
|
||||
logger.error(t);
|
||||
}
|
||||
}
|
||||
}
|
@ -17,6 +17,10 @@ import net.minecraft.entity.Entity;
|
||||
*/
|
||||
public interface IAcceleratedParticleEngine {
|
||||
|
||||
void begin(float partialTicks);
|
||||
|
||||
void draw(float texCoordWidth, float texCoordHeight);
|
||||
|
||||
void drawParticle(Entity entityIn, int particleIndexX, int particleIndexY,
|
||||
int lightMapData, int texSize, float particleSize, float r, float g, float b, float a);
|
||||
|
||||
|
@ -1,18 +1,17 @@
|
||||
package net.lax1dude.eaglercraft.v1_8.minecraft;
|
||||
|
||||
import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.*;
|
||||
import static net.lax1dude.eaglercraft.v1_8.internal.PlatformOpenGL.*;
|
||||
import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.IFramebufferGL;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.IRenderbufferGL;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.ITextureGL;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.buffer.IntBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.opengl.EaglercraftGPU;
|
||||
import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
|
||||
import net.lax1dude.eaglercraft.v1_8.opengl.SpriteLevelMixer;
|
||||
import net.lax1dude.eaglercraft.v1_8.opengl.TextureCopyUtil;
|
||||
import net.lax1dude.eaglercraft.v1_8.vector.Matrix3f;
|
||||
import net.minecraft.client.renderer.GLAllocation;
|
||||
|
||||
@ -31,10 +30,6 @@ import net.minecraft.client.renderer.GLAllocation;
|
||||
*/
|
||||
public class TextureAnimationCache {
|
||||
|
||||
public static final int _GL_FRAMEBUFFER = 0x8D40; // enum not defined in RealOpenGLEnums
|
||||
public static final int _GL_RENDERBUFFER = 0x8D41;
|
||||
public static final int _GL_COLOR_ATTACHMENT0 = 0x8CE0;
|
||||
|
||||
public final int width;
|
||||
public final int height;
|
||||
public final int mipLevels;
|
||||
@ -42,10 +37,8 @@ public class TextureAnimationCache {
|
||||
private int frameCount = 1;
|
||||
|
||||
private int[] cacheTextures = null;
|
||||
private IFramebufferGL[] cacheFramebuffers = null;
|
||||
|
||||
private IFramebufferGL interpolateFramebuffer = null;
|
||||
private IRenderbufferGL interpolateRenderbuffer = null;
|
||||
public static final int _GL_FRAMEBUFFER = 0x8D40;
|
||||
|
||||
public TextureAnimationCache(int width, int height, int mipLevels) {
|
||||
this.width = width;
|
||||
@ -53,9 +46,8 @@ public class TextureAnimationCache {
|
||||
this.mipLevels = mipLevels;
|
||||
}
|
||||
|
||||
public void initialize(List<int[][]> frames, boolean enableInterpolation) {
|
||||
boolean init = cacheTextures == null;
|
||||
if(init) {
|
||||
public void initialize(List<int[][]> frames) {
|
||||
if(cacheTextures == null) {
|
||||
cacheTextures = new int[mipLevels];
|
||||
for(int i = 0; i < cacheTextures.length; ++i) {
|
||||
cacheTextures[i] = GlStateManager.generateTexture();
|
||||
@ -65,17 +57,6 @@ public class TextureAnimationCache {
|
||||
EaglercraftGPU.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
EaglercraftGPU.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
}
|
||||
|
||||
if(enableInterpolation) {
|
||||
interpolateFramebuffer = _wglCreateFramebuffer();
|
||||
_wglBindFramebuffer(_GL_FRAMEBUFFER, interpolateFramebuffer);
|
||||
interpolateRenderbuffer = _wglCreateRenderbuffer();
|
||||
_wglBindRenderbuffer(_GL_RENDERBUFFER, interpolateRenderbuffer);
|
||||
_wglRenderbufferStorage(_GL_RENDERBUFFER, GL_RGBA8, width, height);
|
||||
_wglFramebufferRenderbuffer(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0,
|
||||
_GL_RENDERBUFFER, interpolateRenderbuffer);
|
||||
_wglBindFramebuffer(_GL_FRAMEBUFFER, null);
|
||||
}
|
||||
}
|
||||
|
||||
frameCount = frames.size();
|
||||
@ -111,37 +92,10 @@ public class TextureAnimationCache {
|
||||
}finally {
|
||||
EagRuntime.freeIntBuffer(pixels);
|
||||
}
|
||||
|
||||
if(init) {
|
||||
cacheFramebuffers = new IFramebufferGL[mipLevels];
|
||||
for(int i = 0; i < mipLevels; ++i) {
|
||||
GlStateManager.bindTexture(cacheTextures[i]);
|
||||
IFramebufferGL fbo = _wglCreateFramebuffer();
|
||||
_wglBindFramebuffer(_GL_FRAMEBUFFER, fbo);
|
||||
_wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
|
||||
EaglercraftGPU.getNativeTexture(cacheTextures[i]), 0);
|
||||
cacheFramebuffers[i] = fbo;
|
||||
}
|
||||
_wglBindFramebuffer(_GL_FRAMEBUFFER, null);
|
||||
}
|
||||
}
|
||||
|
||||
public void free() {
|
||||
if(cacheTextures != null) {
|
||||
if(interpolateFramebuffer != null) {
|
||||
_wglDeleteFramebuffer(interpolateFramebuffer);
|
||||
interpolateFramebuffer = null;
|
||||
}
|
||||
if(interpolateRenderbuffer != null) {
|
||||
_wglDeleteRenderbuffer(interpolateRenderbuffer);
|
||||
interpolateRenderbuffer = null;
|
||||
}
|
||||
if(cacheFramebuffers != null) {
|
||||
for(int i = 0; i < mipLevels; ++i) {
|
||||
_wglDeleteFramebuffer(cacheFramebuffers[i]);
|
||||
}
|
||||
cacheFramebuffers = null;
|
||||
}
|
||||
for(int i = 0; i < cacheTextures.length; ++i) {
|
||||
GlStateManager.deleteTexture(cacheTextures[i]);
|
||||
}
|
||||
@ -149,12 +103,16 @@ public class TextureAnimationCache {
|
||||
}
|
||||
}
|
||||
|
||||
public void copyFrameLevelsToTex2D(int animationFrame, int dx, int dy, int w, int h) {
|
||||
copyFrameLevelsToTex2D(animationFrame, mipLevels, dx, dy, w, h);
|
||||
public void copyFrameLevelsToTex2D(int animationFrame, int dx, int dy, int w, int h, IFramebufferGL[] dstFramebuffers) {
|
||||
copyFrameLevelsToTex2D(animationFrame, mipLevels, dx, dy, w, h, dstFramebuffers);
|
||||
}
|
||||
|
||||
public void copyFrameLevelsToTex2D(int animationFrame, int levels, int dx, int dy, int w, int h) {
|
||||
/**
|
||||
* WARNING: call <code>_wglBindFramebuffer(_GL_FRAMEBUFFER, null);</code> when complete
|
||||
*/
|
||||
public void copyFrameLevelsToTex2D(int animationFrame, int levels, int dx, int dy, int w, int h, IFramebufferGL[] dstFramebuffers) {
|
||||
for(int i = 0; i < levels; ++i) {
|
||||
_wglBindFramebuffer(_GL_FRAMEBUFFER, dstFramebuffers[i]);
|
||||
copyFrameToTex2D(animationFrame, i, dx >> i, dy >> i, w >> i, h >> i);
|
||||
}
|
||||
}
|
||||
@ -163,20 +121,23 @@ public class TextureAnimationCache {
|
||||
if(cacheTextures == null) {
|
||||
throw new IllegalStateException("Cannot copy from uninitialized TextureAnimationCache");
|
||||
}
|
||||
_wglBindFramebuffer(_GL_FRAMEBUFFER, cacheFramebuffers[level]);
|
||||
_wglReadBuffer(_GL_COLOR_ATTACHMENT0);
|
||||
_wglCopyTexSubImage2D(GL_TEXTURE_2D, level, dx, dy, 0, h * animationFrame, w, h);
|
||||
_wglBindFramebuffer(_GL_FRAMEBUFFER, null);
|
||||
GlStateManager.bindTexture(cacheTextures[level]);
|
||||
TextureCopyUtil.srcSize(width >> level, (height >> level) * frameCount);
|
||||
TextureCopyUtil.blitTextureUsingViewports(0, h * animationFrame, dx, dy, w, h);
|
||||
}
|
||||
|
||||
public void copyInterpolatedFrameLevelsToTex2D(int animationFrameFrom, int animationFrameTo, float factor, int dx,
|
||||
int dy, int w, int h) {
|
||||
copyInterpolatedFrameLevelsToTex2D(animationFrameFrom, animationFrameTo, factor, mipLevels, dx, dy, w, h);
|
||||
int dy, int w, int h, IFramebufferGL[] dstFramebuffers) {
|
||||
copyInterpolatedFrameLevelsToTex2D(animationFrameFrom, animationFrameTo, factor, mipLevels, dx, dy, w, h, dstFramebuffers);
|
||||
}
|
||||
|
||||
/**
|
||||
* WARNING: call <code>_wglBindFramebuffer(_GL_FRAMEBUFFER, null);</code> when complete
|
||||
*/
|
||||
public void copyInterpolatedFrameLevelsToTex2D(int animationFrameFrom, int animationFrameTo, float factor,
|
||||
int levels, int dx, int dy, int w, int h) {
|
||||
int levels, int dx, int dy, int w, int h, IFramebufferGL[] dstFramebuffers) {
|
||||
for(int i = 0; i < levels; ++i) {
|
||||
_wglBindFramebuffer(_GL_FRAMEBUFFER, dstFramebuffers[i]);
|
||||
copyInterpolatedFrameToTex2D(animationFrameFrom, animationFrameTo, factor, i, dx >> i, dy >> i, w >> i, h >> i);
|
||||
}
|
||||
}
|
||||
@ -187,19 +148,9 @@ public class TextureAnimationCache {
|
||||
throw new IllegalStateException("Cannot copy from uninitialized TextureAnimationCache");
|
||||
}
|
||||
|
||||
int storeTexture = GlStateManager.getTextureBound();
|
||||
|
||||
_wglBindFramebuffer(_GL_FRAMEBUFFER, interpolateFramebuffer);
|
||||
GlStateManager.viewport(dx, dy, w, h);
|
||||
GlStateManager.bindTexture(cacheTextures[level]);
|
||||
|
||||
int[] storeViewport = new int[4];
|
||||
EaglercraftGPU.glGetInteger(GL_VIEWPORT, storeViewport);
|
||||
GlStateManager.viewport(0, 0, w, h);
|
||||
GlStateManager.clearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
GlStateManager.clear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(GL_ONE, GL_ONE);
|
||||
GlStateManager.disableBlend();
|
||||
|
||||
Matrix3f matrix = new Matrix3f();
|
||||
matrix.m11 = 1.0f / frameCount;
|
||||
@ -216,18 +167,13 @@ public class TextureAnimationCache {
|
||||
float fac1 = 1.0f - factor;
|
||||
SpriteLevelMixer.setBlendColor(fac1, fac1, fac1, fac1);
|
||||
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(GL_ONE, GL_ONE);
|
||||
|
||||
SpriteLevelMixer.drawSprite(0);
|
||||
|
||||
GlStateManager.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
GlStateManager.disableBlend();
|
||||
|
||||
GlStateManager.bindTexture(storeTexture);
|
||||
GlStateManager.viewport(storeViewport[0], storeViewport[1], storeViewport[2], storeViewport[3]);
|
||||
GlStateManager.clearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
_wglReadBuffer(_GL_COLOR_ATTACHMENT0);
|
||||
_wglCopyTexSubImage2D(GL_TEXTURE_2D, level, dx, dy, 0, 0, w, h);
|
||||
_wglBindFramebuffer(_GL_FRAMEBUFFER, null);
|
||||
GlStateManager.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
|
||||
public int getFrameCount() {
|
||||
|
Reference in New Issue
Block a user