mirror of
https://github.com/Eaglercraft-Archive/Eaglercraftx-1.8.8-src.git
synced 2025-06-27 18:38:14 -05:00
Update #47 - Singleplayer lag fixes
This commit is contained in:
@ -49,6 +49,7 @@ public class EaglerMeshLoader implements IResourceManagerReloadListener {
|
||||
if(theMesh == null) {
|
||||
theMesh = new HighPolyMesh();
|
||||
reloadMesh(meshLoc, theMesh, Minecraft.getMinecraft().getResourceManager());
|
||||
meshCache.put(meshLoc, theMesh);
|
||||
}
|
||||
meshLoc.cachedPointerType = ResourceLocation.CACHED_POINTER_EAGLER_MESH;
|
||||
meshLoc.cachedPointer = theMesh;
|
||||
|
@ -7,8 +7,8 @@ import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
|
||||
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
|
||||
import net.minecraft.util.MathHelper;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import com.carrotsearch.hppc.IntObjectHashMap;
|
||||
import com.carrotsearch.hppc.IntObjectMap;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.GLObjectMap;
|
||||
@ -213,15 +213,18 @@ public class EaglercraftGPU {
|
||||
++GlStateManager.stateNormalSerial;
|
||||
}
|
||||
|
||||
private static final Map<Integer,String> stringCache = new HashMap<>();
|
||||
private static final IntObjectMap<String> stringCache = new IntObjectHashMap<>();
|
||||
|
||||
public static final String glGetString(int param) {
|
||||
String str = stringCache.get(param);
|
||||
if(str == null) {
|
||||
str = _wglGetString(param);
|
||||
if(str == null) {
|
||||
str = "";
|
||||
}
|
||||
stringCache.put(param, str);
|
||||
}
|
||||
return str;
|
||||
return str.length() == 0 ? null : str;
|
||||
}
|
||||
|
||||
public static final void glGetInteger(int param, int[] values) {
|
||||
|
@ -3,9 +3,10 @@ package net.lax1dude.eaglercraft.v1_8.opengl;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.buffer.ByteBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.buffer.FloatBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.buffer.IntBuffer;
|
||||
import java.util.Arrays;
|
||||
import java.util.BitSet;
|
||||
import java.util.Comparator;
|
||||
import java.util.function.IntBinaryOperator;
|
||||
|
||||
import com.carrotsearch.hppc.sorting.QuickSort;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
|
||||
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
|
||||
@ -84,12 +85,37 @@ public class WorldRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
private float[] sortArrayCacheA = null;
|
||||
private int[] sortArrayCacheB = null;
|
||||
private BitSet sortBitSetCache = null;
|
||||
private final IntBinaryOperator sortArrayCacheLambda = this::sortFunction_func_181674_a;
|
||||
private final IntBinaryOperator swapArrayCacheLambda = this::swapFunction_func_181674_a;
|
||||
|
||||
protected int sortFunction_func_181674_a(int integer, int integer1) {
|
||||
return Float.compare(sortArrayCacheA[sortArrayCacheB[integer1]], sortArrayCacheA[sortArrayCacheB[integer]]);
|
||||
}
|
||||
|
||||
protected int swapFunction_func_181674_a(int i, int j) {
|
||||
int swap = sortArrayCacheB[i];
|
||||
sortArrayCacheB[i] = sortArrayCacheB[j];
|
||||
sortArrayCacheB[j] = swap;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* MOST LIKELY USED TO SORT QUADS BACK TO FRONT
|
||||
*/
|
||||
public void func_181674_a(float parFloat1, float parFloat2, float parFloat3) {
|
||||
int i = this.vertexCount / 4;
|
||||
final float[] afloat = new float[i];
|
||||
if(i == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
float[] afloat = sortArrayCacheA;
|
||||
if(afloat == null || afloat.length < i) {
|
||||
afloat = new float[i];
|
||||
sortArrayCacheA = afloat;
|
||||
}
|
||||
|
||||
for (int j = 0; j < i; ++j) {
|
||||
afloat[j] = func_181665_a(this.floatBuffer, (float) ((double) parFloat1 + this.xOffset),
|
||||
@ -97,30 +123,38 @@ public class WorldRenderer {
|
||||
this.vertexFormat.attribStride >> 2, j * this.vertexFormat.attribStride);
|
||||
}
|
||||
|
||||
Integer[] ainteger = new Integer[i];
|
||||
|
||||
for (int k = 0; k < ainteger.length; ++k) {
|
||||
ainteger[k] = Integer.valueOf(k);
|
||||
int[] ainteger = sortArrayCacheB;
|
||||
if(ainteger == null || ainteger.length < i) {
|
||||
ainteger = new int[i];
|
||||
sortArrayCacheB = ainteger;
|
||||
}
|
||||
|
||||
for (int k = 0; k < i; ++k) {
|
||||
ainteger[k] = k;
|
||||
}
|
||||
|
||||
QuickSort.sort(0, i, sortArrayCacheLambda, swapArrayCacheLambda);
|
||||
|
||||
BitSet bitset = sortBitSetCache;
|
||||
if(bitset == null) {
|
||||
bitset = new BitSet();
|
||||
sortBitSetCache = bitset;
|
||||
}else {
|
||||
bitset.clear();
|
||||
}
|
||||
|
||||
Arrays.sort(ainteger, new Comparator<Integer>() {
|
||||
public int compare(Integer integer, Integer integer1) {
|
||||
return Float.compare(afloat[integer1.intValue()], afloat[integer.intValue()]);
|
||||
}
|
||||
});
|
||||
BitSet bitset = new BitSet();
|
||||
int l = this.vertexFormat.attribStride;
|
||||
int[] aint = new int[l];
|
||||
|
||||
for (int l1 = 0; (l1 = bitset.nextClearBit(l1)) < ainteger.length; ++l1) {
|
||||
int i1 = ainteger[l1].intValue();
|
||||
for (int l1 = 0; (l1 = bitset.nextClearBit(l1)) < i; ++l1) {
|
||||
int i1 = ainteger[l1];
|
||||
if (i1 != l1) {
|
||||
this.intBuffer.limit(i1 * l + l);
|
||||
this.intBuffer.position(i1 * l);
|
||||
this.intBuffer.get(aint);
|
||||
int j1 = i1;
|
||||
|
||||
for (int k1 = ainteger[i1].intValue(); j1 != l1; k1 = ainteger[k1].intValue()) {
|
||||
for (int k1 = ainteger[i1]; j1 != l1; k1 = ainteger[k1]) {
|
||||
this.intBuffer.limit(k1 * l + l);
|
||||
this.intBuffer.position(k1 * l);
|
||||
IntBuffer intbuffer = this.intBuffer.duplicate();
|
||||
|
@ -3,8 +3,8 @@ package net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import com.carrotsearch.hppc.ObjectIntHashMap;
|
||||
import com.carrotsearch.hppc.ObjectIntMap;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
|
||||
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
|
||||
@ -32,7 +32,7 @@ public class BlockVertexIDs implements IResourceManagerReloadListener {
|
||||
|
||||
private static final Logger logger = LogManager.getLogger("BlockVertexIDsCSV");
|
||||
|
||||
public static final Map<String,Integer> modelToID = new HashMap<>();
|
||||
public static final ObjectIntMap<String> modelToID = new ObjectIntHashMap<>();
|
||||
|
||||
public static int builtin_water_still_vertex_id = 0;
|
||||
public static int builtin_water_flow_vertex_id = 0;
|
||||
|
@ -316,6 +316,14 @@ public class DebugFramebufferView {
|
||||
GlStateManager.bindTexture(pipeline.realisticWaterMaskTexture);
|
||||
DrawUtils.drawStandardQuad2D();
|
||||
})),
|
||||
(new DebugFramebufferView("Water: Combined Normals", (pipeline) -> {
|
||||
if(!pipeline.config.is_rendering_realisticWater) throw new NoDataException();
|
||||
PipelineShaderGBufferDebugView dbv = pipeline.useDebugViewShader(1);
|
||||
EaglerDeferredPipeline.uniformMatrixHelper(dbv.uniforms.u_inverseViewMatrix, DeferredStateManager.inverseViewMatrix);
|
||||
GlStateManager.setActiveTexture(GL_TEXTURE0);
|
||||
GlStateManager.bindTexture(pipeline.realisticWaterCombinedNormalsTexture);
|
||||
DrawUtils.drawStandardQuad2D();
|
||||
})),
|
||||
(new DebugFramebufferView("Water: Surface Depth", (pipeline) -> {
|
||||
if(!pipeline.config.is_rendering_realisticWater) throw new NoDataException();
|
||||
float depthStart = 0.001f;
|
||||
|
@ -34,6 +34,7 @@ import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.program.PipelineShaderP
|
||||
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.program.PipelineShaderRealisticWaterControl;
|
||||
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.program.PipelineShaderRealisticWaterNoise;
|
||||
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.program.PipelineShaderRealisticWaterNormalMap;
|
||||
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.program.PipelineShaderRealisticWaterNormalsMix;
|
||||
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.program.PipelineShaderReprojControl;
|
||||
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.program.PipelineShaderReprojSSR;
|
||||
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.program.PipelineShaderSSAOGenerate;
|
||||
@ -43,6 +44,7 @@ import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.program.PipelineShaderS
|
||||
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.program.PipelineShaderSkyboxRender;
|
||||
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.program.PipelineShaderSkyboxRenderEnd;
|
||||
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.program.PipelineShaderTonemap;
|
||||
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.program.ShaderMissingException;
|
||||
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.texture.MetalsLUT;
|
||||
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.texture.TemperaturesLUT;
|
||||
import net.lax1dude.eaglercraft.v1_8.vector.Matrix3f;
|
||||
@ -291,6 +293,7 @@ public class EaglerDeferredPipeline {
|
||||
public PipelineShaderRealisticWaterControl shader_realistic_water_control = null;
|
||||
public PipelineShaderRealisticWaterNoise shader_realistic_water_noise = null;
|
||||
public PipelineShaderRealisticWaterNormalMap shader_realistic_water_normals = null;
|
||||
public PipelineShaderRealisticWaterNormalsMix shader_realistic_water_normals_mix = null;
|
||||
public PipelineShaderHandDepthMask shader_hand_depth_mask = null;
|
||||
public PipelineShaderFXAA shader_post_fxaa = null;
|
||||
public SkyboxRenderer skybox = null;
|
||||
@ -913,6 +916,12 @@ public class EaglerDeferredPipeline {
|
||||
shader_realistic_water_normals = PipelineShaderRealisticWaterNormalMap.compile();
|
||||
shader_realistic_water_normals.loadUniforms();
|
||||
_wglUniform2f(shader_realistic_water_normals.uniforms.u_sampleOffset2f, 0.00390625f, 0.00390625f);
|
||||
try {
|
||||
shader_realistic_water_normals_mix = PipelineShaderRealisticWaterNormalsMix.compile();
|
||||
shader_realistic_water_normals_mix.loadUniforms();
|
||||
}catch(ShaderMissingException exx) {
|
||||
shader_realistic_water_normals_mix = null;
|
||||
}
|
||||
if(!config.is_rendering_raytracing) {
|
||||
shader_reproject_ssr = PipelineShaderReprojSSR.compile();
|
||||
shader_reproject_ssr.loadUniforms();
|
||||
@ -1083,7 +1092,7 @@ public class EaglerDeferredPipeline {
|
||||
double distX = worldX - reprojectionOriginCoordinateX;
|
||||
double distY = worldY - reprojectionOriginCoordinateY;
|
||||
double distZ = worldZ - reprojectionOriginCoordinateZ;
|
||||
if(distX * distX + distY * distY + distZ * distZ > 48.0 * 48.0) {
|
||||
if(distX * distX + distY * distY + distZ * distZ > 72.0 * 72.0) {
|
||||
reprojectionOriginCoordinateX = worldX;
|
||||
reprojectionOriginCoordinateY = worldY;
|
||||
reprojectionOriginCoordinateZ = worldZ;
|
||||
@ -1098,7 +1107,7 @@ public class EaglerDeferredPipeline {
|
||||
}
|
||||
distX = worldX - cloudRenderOriginCoordinateX;
|
||||
distZ = worldZ - cloudRenderOriginCoordinateZ;
|
||||
if(distX * distX + distZ * distZ > 256.0 * 256.0) {
|
||||
if(distX * distX + distZ * distZ > 384.0 * 384.0) {
|
||||
cloudRenderOriginCoordinateX = worldX;
|
||||
cloudRenderOriginCoordinateZ = worldZ;
|
||||
cloudRenderViewerOffsetX = 0.0f;
|
||||
@ -1844,39 +1853,44 @@ public class EaglerDeferredPipeline {
|
||||
_wglUniformMatrix4x2fv(shader_reproject_ssr.uniforms.u_lastInverseProjMatrix4x2f, false, matrixCopyBuffer);
|
||||
_wglUniform1f(shader_reproject_ssr.uniforms.u_sampleStep1f, 0.125f);
|
||||
|
||||
DrawUtils.drawStandardQuad2D(); // sample 1
|
||||
if(shader_reproject_ssr.uniforms.u_sampleDelta1i != null) {
|
||||
_wglUniform1i(shader_reproject_ssr.uniforms.u_sampleDelta1i, 5);
|
||||
DrawUtils.drawStandardQuad2D();
|
||||
}else {
|
||||
DrawUtils.drawStandardQuad2D(); // sample 1
|
||||
|
||||
_wglBindFramebuffer(_GL_FRAMEBUFFER, reprojectionSSRFramebuffer[0]);
|
||||
GlStateManager.setActiveTexture(GL_TEXTURE3);
|
||||
GlStateManager.bindTexture(reprojectionSSRHitVector[1]);
|
||||
GlStateManager.setActiveTexture(GL_TEXTURE2);
|
||||
GlStateManager.bindTexture(reprojectionSSRTexture[1]);
|
||||
_wglBindFramebuffer(_GL_FRAMEBUFFER, reprojectionSSRFramebuffer[0]);
|
||||
GlStateManager.setActiveTexture(GL_TEXTURE3);
|
||||
GlStateManager.bindTexture(reprojectionSSRHitVector[1]);
|
||||
GlStateManager.setActiveTexture(GL_TEXTURE2);
|
||||
GlStateManager.bindTexture(reprojectionSSRTexture[1]);
|
||||
|
||||
DrawUtils.drawStandardQuad2D(); // sample 2
|
||||
DrawUtils.drawStandardQuad2D(); // sample 2
|
||||
|
||||
_wglBindFramebuffer(_GL_FRAMEBUFFER, reprojectionSSRFramebuffer[1]);
|
||||
GlStateManager.setActiveTexture(GL_TEXTURE3);
|
||||
GlStateManager.bindTexture(reprojectionSSRHitVector[0]);
|
||||
GlStateManager.setActiveTexture(GL_TEXTURE2);
|
||||
GlStateManager.bindTexture(reprojectionSSRTexture[0]);
|
||||
_wglBindFramebuffer(_GL_FRAMEBUFFER, reprojectionSSRFramebuffer[1]);
|
||||
GlStateManager.setActiveTexture(GL_TEXTURE3);
|
||||
GlStateManager.bindTexture(reprojectionSSRHitVector[0]);
|
||||
GlStateManager.setActiveTexture(GL_TEXTURE2);
|
||||
GlStateManager.bindTexture(reprojectionSSRTexture[0]);
|
||||
|
||||
DrawUtils.drawStandardQuad2D(); // sample 3
|
||||
DrawUtils.drawStandardQuad2D(); // sample 3
|
||||
|
||||
_wglBindFramebuffer(_GL_FRAMEBUFFER, reprojectionSSRFramebuffer[0]);
|
||||
GlStateManager.setActiveTexture(GL_TEXTURE3);
|
||||
GlStateManager.bindTexture(reprojectionSSRHitVector[1]);
|
||||
GlStateManager.setActiveTexture(GL_TEXTURE2);
|
||||
GlStateManager.bindTexture(reprojectionSSRTexture[1]);
|
||||
_wglBindFramebuffer(_GL_FRAMEBUFFER, reprojectionSSRFramebuffer[0]);
|
||||
GlStateManager.setActiveTexture(GL_TEXTURE3);
|
||||
GlStateManager.bindTexture(reprojectionSSRHitVector[1]);
|
||||
GlStateManager.setActiveTexture(GL_TEXTURE2);
|
||||
GlStateManager.bindTexture(reprojectionSSRTexture[1]);
|
||||
|
||||
DrawUtils.drawStandardQuad2D(); // sample 4
|
||||
DrawUtils.drawStandardQuad2D(); // sample 4
|
||||
|
||||
_wglBindFramebuffer(_GL_FRAMEBUFFER, reprojectionSSRFramebuffer[1]);
|
||||
GlStateManager.setActiveTexture(GL_TEXTURE3);
|
||||
GlStateManager.bindTexture(reprojectionSSRHitVector[0]);
|
||||
GlStateManager.setActiveTexture(GL_TEXTURE2);
|
||||
GlStateManager.bindTexture(reprojectionSSRTexture[0]);
|
||||
_wglBindFramebuffer(_GL_FRAMEBUFFER, reprojectionSSRFramebuffer[1]);
|
||||
GlStateManager.setActiveTexture(GL_TEXTURE3);
|
||||
GlStateManager.bindTexture(reprojectionSSRHitVector[0]);
|
||||
GlStateManager.setActiveTexture(GL_TEXTURE2);
|
||||
GlStateManager.bindTexture(reprojectionSSRTexture[0]);
|
||||
|
||||
DrawUtils.drawStandardQuad2D(); // sample 5
|
||||
DrawUtils.drawStandardQuad2D(); // sample 5
|
||||
}
|
||||
|
||||
DeferredStateManager.checkGLError("combineGBuffersAndIlluminate(): RUN SCREENSPACE REFLECTIONS ALGORITHM");
|
||||
}
|
||||
@ -2663,14 +2677,24 @@ public class EaglerDeferredPipeline {
|
||||
|
||||
_wglBindFramebuffer(_GL_FRAMEBUFFER, realisticWaterCombinedNormalsFramebuffer);
|
||||
GlStateManager.viewport(0, 0, currentWidth, currentHeight);
|
||||
GlStateManager.bindTexture(gBufferNormalsTexture);
|
||||
TextureCopyUtil.blitTexture();
|
||||
|
||||
GlStateManager.bindTexture(realisticWaterMaskTexture);
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
|
||||
TextureCopyUtil.blitTexture();
|
||||
GlStateManager.disableBlend();
|
||||
if(shader_realistic_water_normals_mix != null) {
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.setActiveTexture(GL_TEXTURE1);
|
||||
GlStateManager.bindTexture(realisticWaterMaskTexture);
|
||||
GlStateManager.setActiveTexture(GL_TEXTURE0);
|
||||
GlStateManager.bindTexture(gBufferNormalsTexture);
|
||||
shader_realistic_water_normals_mix.useProgram();
|
||||
DrawUtils.drawStandardQuad2D();
|
||||
}else {
|
||||
GlStateManager.bindTexture(gBufferNormalsTexture);
|
||||
TextureCopyUtil.blitTexture();
|
||||
|
||||
GlStateManager.bindTexture(realisticWaterMaskTexture);
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
|
||||
TextureCopyUtil.blitTexture();
|
||||
GlStateManager.disableBlend();
|
||||
}
|
||||
|
||||
DeferredStateManager.checkGLError("endDrawRealisticWaterMask(): COMBINE NORMALS");
|
||||
|
||||
@ -2773,39 +2797,44 @@ public class EaglerDeferredPipeline {
|
||||
_wglUniformMatrix4x2fv(shader_reproject_ssr.uniforms.u_lastInverseProjMatrix4x2f, false, matrixCopyBuffer);
|
||||
_wglUniform1f(shader_reproject_ssr.uniforms.u_sampleStep1f, 0.5f);
|
||||
|
||||
DrawUtils.drawStandardQuad2D(); // sample 1
|
||||
if(shader_reproject_ssr.uniforms.u_sampleDelta1i != null) {
|
||||
_wglUniform1i(shader_reproject_ssr.uniforms.u_sampleDelta1i, 5);
|
||||
DrawUtils.drawStandardQuad2D();
|
||||
}else {
|
||||
DrawUtils.drawStandardQuad2D(); // sample 1
|
||||
|
||||
_wglBindFramebuffer(_GL_FRAMEBUFFER, realisticWaterSSRFramebuffer[0]);
|
||||
GlStateManager.setActiveTexture(GL_TEXTURE3);
|
||||
GlStateManager.bindTexture(realisticWaterControlHitVectorTexture[1]);
|
||||
GlStateManager.setActiveTexture(GL_TEXTURE2);
|
||||
GlStateManager.bindTexture(realisticWaterControlReflectionTexture[1]);
|
||||
_wglBindFramebuffer(_GL_FRAMEBUFFER, realisticWaterSSRFramebuffer[0]);
|
||||
GlStateManager.setActiveTexture(GL_TEXTURE3);
|
||||
GlStateManager.bindTexture(realisticWaterControlHitVectorTexture[1]);
|
||||
GlStateManager.setActiveTexture(GL_TEXTURE2);
|
||||
GlStateManager.bindTexture(realisticWaterControlReflectionTexture[1]);
|
||||
|
||||
DrawUtils.drawStandardQuad2D(); // sample 2
|
||||
DrawUtils.drawStandardQuad2D(); // sample 2
|
||||
|
||||
_wglBindFramebuffer(_GL_FRAMEBUFFER, realisticWaterSSRFramebuffer[1]);
|
||||
GlStateManager.setActiveTexture(GL_TEXTURE3);
|
||||
GlStateManager.bindTexture(realisticWaterControlHitVectorTexture[0]);
|
||||
GlStateManager.setActiveTexture(GL_TEXTURE2);
|
||||
GlStateManager.bindTexture(realisticWaterControlReflectionTexture[0]);
|
||||
_wglBindFramebuffer(_GL_FRAMEBUFFER, realisticWaterSSRFramebuffer[1]);
|
||||
GlStateManager.setActiveTexture(GL_TEXTURE3);
|
||||
GlStateManager.bindTexture(realisticWaterControlHitVectorTexture[0]);
|
||||
GlStateManager.setActiveTexture(GL_TEXTURE2);
|
||||
GlStateManager.bindTexture(realisticWaterControlReflectionTexture[0]);
|
||||
|
||||
DrawUtils.drawStandardQuad2D(); // sample 3
|
||||
DrawUtils.drawStandardQuad2D(); // sample 3
|
||||
|
||||
_wglBindFramebuffer(_GL_FRAMEBUFFER, realisticWaterSSRFramebuffer[0]);
|
||||
GlStateManager.setActiveTexture(GL_TEXTURE3);
|
||||
GlStateManager.bindTexture(realisticWaterControlHitVectorTexture[1]);
|
||||
GlStateManager.setActiveTexture(GL_TEXTURE2);
|
||||
GlStateManager.bindTexture(realisticWaterControlReflectionTexture[1]);
|
||||
_wglBindFramebuffer(_GL_FRAMEBUFFER, realisticWaterSSRFramebuffer[0]);
|
||||
GlStateManager.setActiveTexture(GL_TEXTURE3);
|
||||
GlStateManager.bindTexture(realisticWaterControlHitVectorTexture[1]);
|
||||
GlStateManager.setActiveTexture(GL_TEXTURE2);
|
||||
GlStateManager.bindTexture(realisticWaterControlReflectionTexture[1]);
|
||||
|
||||
DrawUtils.drawStandardQuad2D(); // sample 4
|
||||
DrawUtils.drawStandardQuad2D(); // sample 4
|
||||
|
||||
_wglBindFramebuffer(_GL_FRAMEBUFFER, realisticWaterSSRFramebuffer[1]);
|
||||
GlStateManager.setActiveTexture(GL_TEXTURE3);
|
||||
GlStateManager.bindTexture(realisticWaterControlHitVectorTexture[0]);
|
||||
GlStateManager.setActiveTexture(GL_TEXTURE2);
|
||||
GlStateManager.bindTexture(realisticWaterControlReflectionTexture[0]);
|
||||
_wglBindFramebuffer(_GL_FRAMEBUFFER, realisticWaterSSRFramebuffer[1]);
|
||||
GlStateManager.setActiveTexture(GL_TEXTURE3);
|
||||
GlStateManager.bindTexture(realisticWaterControlHitVectorTexture[0]);
|
||||
GlStateManager.setActiveTexture(GL_TEXTURE2);
|
||||
GlStateManager.bindTexture(realisticWaterControlReflectionTexture[0]);
|
||||
|
||||
DrawUtils.drawStandardQuad2D(); // sample 5
|
||||
DrawUtils.drawStandardQuad2D(); // sample 5
|
||||
}
|
||||
|
||||
DeferredStateManager.checkGLError("endDrawRealisticWaterMask(): RUN SCREENSPACE REFLECTIONS ALGORITHM");
|
||||
|
||||
@ -3066,6 +3095,8 @@ public class EaglerDeferredPipeline {
|
||||
GlStateManager.clear(GL_DEPTH_BUFFER_BIT);
|
||||
GlStateManager.enableDepth();
|
||||
DeferredStateManager.setDefaultMaterialConstants();
|
||||
DeferredStateManager.disableFog();
|
||||
updateForwardRenderWorldLightingData();
|
||||
DeferredStateManager.checkGLError("Post: beginDrawHandOverlay()");
|
||||
}
|
||||
|
||||
@ -3838,6 +3869,10 @@ public class EaglerDeferredPipeline {
|
||||
shader_realistic_water_normals.destroy();
|
||||
shader_realistic_water_normals = null;
|
||||
}
|
||||
if(shader_realistic_water_normals_mix != null) {
|
||||
shader_realistic_water_normals_mix.destroy();
|
||||
shader_realistic_water_normals_mix = null;
|
||||
}
|
||||
if(shader_post_fxaa != null) {
|
||||
shader_post_fxaa.destroy();
|
||||
shader_post_fxaa = null;
|
||||
|
@ -0,0 +1,57 @@
|
||||
package net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.program;
|
||||
|
||||
import static net.lax1dude.eaglercraft.v1_8.internal.PlatformOpenGL.*;
|
||||
import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.*;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.IProgramGL;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.IShaderGL;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2025 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class PipelineShaderRealisticWaterNormalsMix extends ShaderProgram<PipelineShaderRealisticWaterNormalsMix.Uniforms> {
|
||||
|
||||
public static PipelineShaderRealisticWaterNormalsMix compile() throws ShaderException {
|
||||
IShaderGL normalsMix = ShaderCompiler.compileShader("realistic_water_normals_mix", GL_FRAGMENT_SHADER,
|
||||
ShaderSource.realistic_water_normals_mix_fsh);
|
||||
try {
|
||||
IProgramGL prog = ShaderCompiler.linkProgram("realistic_water_normals_mix",
|
||||
SharedPipelineShaders.deferred_local, normalsMix);
|
||||
return new PipelineShaderRealisticWaterNormalsMix(prog);
|
||||
}finally {
|
||||
if(normalsMix != null) {
|
||||
normalsMix.free();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private PipelineShaderRealisticWaterNormalsMix(IProgramGL program) {
|
||||
super(program, new Uniforms());
|
||||
}
|
||||
|
||||
public static class Uniforms implements IProgramUniforms {
|
||||
|
||||
private Uniforms() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUniforms(IProgramGL prog) {
|
||||
_wglUniform1i(_wglGetUniformLocation(prog, "u_gbufferNormalsTexture"), 0);
|
||||
_wglUniform1i(_wglGetUniformLocation(prog, "u_surfaceNormalsTexture"), 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -48,6 +48,7 @@ public class PipelineShaderReprojSSR extends ShaderProgram<PipelineShaderReprojS
|
||||
public IUniformGL u_inverseProjectionMatrix4f;
|
||||
public IUniformGL u_sampleStep1f;
|
||||
public IUniformGL u_pixelAlignment4f = null;
|
||||
public IUniformGL u_sampleDelta1i;
|
||||
|
||||
@Override
|
||||
public void loadUniforms(IProgramGL prog) {
|
||||
@ -62,6 +63,7 @@ public class PipelineShaderReprojSSR extends ShaderProgram<PipelineShaderReprojS
|
||||
u_inverseProjectionMatrix4f = _wglGetUniformLocation(prog, "u_inverseProjectionMatrix4f");
|
||||
u_sampleStep1f = _wglGetUniformLocation(prog, "u_sampleStep1f");
|
||||
u_pixelAlignment4f = _wglGetUniformLocation(prog, "u_pixelAlignment4f");
|
||||
u_sampleDelta1i = _wglGetUniformLocation(prog, "u_sampleDelta1i");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -33,7 +33,11 @@ public class ShaderCompiler {
|
||||
private static final Logger logger = LogManager.getLogger("DeferredPipelineCompiler");
|
||||
|
||||
public static IShaderGL compileShader(String name, int stage, ResourceLocation filename, String... compileFlags) throws ShaderCompileException {
|
||||
return compileShader(name, stage, filename.toString(), ShaderSource.getSourceFor(filename), Arrays.asList(compileFlags));
|
||||
String src = ShaderSource.getSourceFor(filename);
|
||||
if(src == null) {
|
||||
throw new ShaderMissingException(name, "File not found: " + filename);
|
||||
}
|
||||
return compileShader(name, stage, filename.toString(), src, Arrays.asList(compileFlags));
|
||||
}
|
||||
|
||||
public static IShaderGL compileShader(String name, int stage, String filename, String source, String... compileFlags) throws ShaderCompileException {
|
||||
@ -41,7 +45,11 @@ public class ShaderCompiler {
|
||||
}
|
||||
|
||||
public static IShaderGL compileShader(String name, int stage, ResourceLocation filename, List<String> compileFlags) throws ShaderCompileException {
|
||||
return compileShader(name, stage, filename.toString(), ShaderSource.getSourceFor(filename), compileFlags);
|
||||
String src = ShaderSource.getSourceFor(filename);
|
||||
if(src == null) {
|
||||
throw new ShaderMissingException(name, "File not found: " + filename);
|
||||
}
|
||||
return compileShader(name, stage, filename.toString(), src, compileFlags);
|
||||
}
|
||||
|
||||
public static IShaderGL compileShader(String name, int stage, String filename, String source, List<String> compileFlags) throws ShaderCompileException {
|
||||
|
@ -0,0 +1,24 @@
|
||||
package net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.program;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2025 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class ShaderMissingException extends ShaderException {
|
||||
|
||||
public ShaderMissingException(String shaderName, String msg) {
|
||||
super(shaderName, msg);
|
||||
}
|
||||
|
||||
}
|
@ -54,6 +54,7 @@ public class ShaderSource {
|
||||
public static final ResourceLocation realistic_water_render_fsh = new ResourceLocation("eagler:glsl/deferred/realistic_water_render.fsh");
|
||||
public static final ResourceLocation realistic_water_control_fsh = new ResourceLocation("eagler:glsl/deferred/realistic_water_control.fsh");
|
||||
public static final ResourceLocation realistic_water_normals_fsh = new ResourceLocation("eagler:glsl/deferred/realistic_water_normals.fsh");
|
||||
public static final ResourceLocation realistic_water_normals_mix_fsh = new ResourceLocation("eagler:glsl/deferred/realistic_water_normals_mix.fsh");
|
||||
public static final ResourceLocation realistic_water_noise_fsh = new ResourceLocation("eagler:glsl/deferred/realistic_water_noise.fsh");
|
||||
public static final ResourceLocation gbuffer_debug_view_fsh = new ResourceLocation("eagler:glsl/deferred/gbuffer_debug_view.fsh");
|
||||
public static final ResourceLocation ssao_generate_fsh = new ResourceLocation("eagler:glsl/deferred/ssao_generate.fsh");
|
||||
|
@ -1,10 +1,10 @@
|
||||
package net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.texture;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import com.carrotsearch.hppc.cursors.IntCursor;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.HString;
|
||||
@ -104,10 +104,8 @@ public class EaglerTextureAtlasSpritePBR extends EaglerTextureAtlasSprite {
|
||||
int l = i;
|
||||
this.height = this.width;
|
||||
if (meta.getFrameCount() > 0) {
|
||||
Iterator iterator = meta.getFrameIndexSet().iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
int i1 = ((Integer) iterator.next()).intValue();
|
||||
for (IntCursor cur : meta.getFrameIndexSet()) {
|
||||
int i1 = cur.value;
|
||||
if (i1 >= j1) {
|
||||
throw new RuntimeException("invalid frameindex " + i1);
|
||||
}
|
||||
|
Reference in New Issue
Block a user