diff --git a/assets/Shaders/FragmentShader.fs b/assets/Shaders/FragmentShader.fs index 9606e939..12e98e71 100644 --- a/assets/Shaders/FragmentShader.fs +++ b/assets/Shaders/FragmentShader.fs @@ -49,6 +49,11 @@ struct Cluster { uint lightIndices[MAX_LIGHTS_PER_CLUSTER]; }; +/** +Cutoff for fragment alpha +*/ +#define FRAGMENT_ALPHA_CUTOFF 0.001 + out vec4 FragColor; layout(std430, binding = CLUSTER_SSBO_BIND_POINT) restrict buffer clusterGridSSBO { @@ -106,7 +111,7 @@ float calcLightIntensityTotal(vec3 normal); float ShadowCalculation(vec4 fragPosLightSpace, vec3 lightDir, vec3 normal); void main(){ - if(texture(material.diffuse, TexCoord).a < 0.01){ + if(texture(material.diffuse, TexCoord).a < FRAGMENT_ALPHA_CUTOFF){ discard; } vec3 norm = normalize(Normal); diff --git a/assets/Textures/Leaf_Pine_C.png b/assets/Textures/Leaf_Pine_C.png index 9e5f082a..77cf6d52 100644 Binary files a/assets/Textures/Leaf_Pine_C.png and b/assets/Textures/Leaf_Pine_C.png differ diff --git a/buildNumber.properties b/buildNumber.properties index 8e132c94..2e5e90dc 100644 --- a/buildNumber.properties +++ b/buildNumber.properties @@ -1,3 +1,3 @@ #maven.buildNumber.plugin properties file -#Wed Nov 13 21:13:23 EST 2024 -buildNumber=384 +#Fri Nov 15 15:38:56 EST 2024 +buildNumber=385 diff --git a/docs/src/progress/bigthings.md b/docs/src/progress/bigthings.md index 6d732764..a63abd03 100644 --- a/docs/src/progress/bigthings.md +++ b/docs/src/progress/bigthings.md @@ -25,3 +25,6 @@ TODO(?): - Some css support - Language file for translation + - Live reloading of scripts + + - Async asset reloading (including data files) diff --git a/docs/src/progress/renderertodo.md b/docs/src/progress/renderertodo.md index 689f61cc..24ecaacf 100644 --- a/docs/src/progress/renderertodo.md +++ b/docs/src/progress/renderertodo.md @@ -1049,6 +1049,8 @@ Script engine preloading Fix YogaUtils.refreshComponent breaking when passed null window Remove FontUtils .testcache creation File watching scripts source dir +Fix STBImage flipping bug (set flag statically) +Update visuals on pine tree diff --git a/src/main/java/electrosphere/entity/state/equip/ServerToolbarState.java b/src/main/java/electrosphere/entity/state/equip/ServerToolbarState.java index 8b923874..33a77006 100644 --- a/src/main/java/electrosphere/entity/state/equip/ServerToolbarState.java +++ b/src/main/java/electrosphere/entity/state/equip/ServerToolbarState.java @@ -271,10 +271,14 @@ public class ServerToolbarState implements BehaviorTree { // //Visual transforms if(targetHasWhitelist){ - ServerEntityUtils.destroyEntity(this.realWorldItem); + if(this.realWorldItem != null){ + ServerEntityUtils.destroyEntity(this.realWorldItem); + } this.realWorldItem = null; } else { - ServerEntityUtils.destroyEntity(this.realWorldItem); + if(this.realWorldItem != null){ + ServerEntityUtils.destroyEntity(this.realWorldItem); + } this.realWorldItem = null; } diff --git a/src/main/java/electrosphere/renderer/loading/ModelLoader.java b/src/main/java/electrosphere/renderer/loading/ModelLoader.java index ceefbfb2..d212659e 100644 --- a/src/main/java/electrosphere/renderer/loading/ModelLoader.java +++ b/src/main/java/electrosphere/renderer/loading/ModelLoader.java @@ -11,7 +11,7 @@ import electrosphere.util.FileUtils; import java.io.File; import org.lwjgl.assimp.AIScene; -import static org.lwjgl.assimp.Assimp.*; +import org.lwjgl.assimp.Assimp; /** * Main model loading class @@ -26,16 +26,16 @@ public class ModelLoader { public static AIScene loadAIScene(String path){ AIScene rVal; File toRead = FileUtils.getAssetFile(path); - rVal = aiImportFile(toRead.getAbsolutePath(), - aiProcess_GenSmoothNormals | - aiProcess_JoinIdenticalVertices | - aiProcess_Triangulate | - aiProcess_FixInfacingNormals | - aiProcess_LimitBoneWeights | - aiProcess_GlobalScale - ); + rVal = Assimp.aiImportFile(toRead.getAbsolutePath(), + Assimp.aiProcess_GenSmoothNormals | + Assimp.aiProcess_JoinIdenticalVertices | + Assimp.aiProcess_Triangulate | + Assimp.aiProcess_FixInfacingNormals | + Assimp.aiProcess_LimitBoneWeights | + Assimp.aiProcess_GlobalScale + ); if(rVal == null){ - LoggerInterface.loggerRenderer.ERROR(new IllegalStateException(aiGetErrorString())); + LoggerInterface.loggerRenderer.ERROR(new IllegalStateException(Assimp.aiGetErrorString())); } return rVal; } @@ -69,9 +69,9 @@ public class ModelLoader { for(Mesh mesh : m.getMeshes()){ MeshTextureData meshTextureData = Globals.textureMapDefault.getMeshTextures(path, mesh.getMeshName()); if(meshTextureData != null){ - setMaterial(mesh,meshTextureData); + ModelLoader.setMaterial(mesh,meshTextureData); } else if(defaultMeshData != null){ - setMaterial(mesh,defaultMeshData); + ModelLoader.setMaterial(mesh,defaultMeshData); } else { LoggerInterface.loggerRenderer.WARNING("Model " + path + " does not have texture data defined for \"" + mesh.getMeshName() + "\""); } @@ -84,9 +84,9 @@ public class ModelLoader { for(Mesh mesh : m.getMeshes()){ MeshTextureData meshTextureData = localTextureMap.getMeshTextures(path, mesh.getMeshName()); if(meshTextureData != null){ - setMaterial(mesh,meshTextureData); + ModelLoader.setMaterial(mesh,meshTextureData); } else if(defaultMeshData != null){ - setMaterial(mesh,defaultMeshData); + ModelLoader.setMaterial(mesh,defaultMeshData); } else { LoggerInterface.loggerRenderer.WARNING("Model " + path + " does not have texture data defined for \"" + mesh.getMeshName() + "\""); } diff --git a/src/main/java/electrosphere/renderer/model/Material.java b/src/main/java/electrosphere/renderer/model/Material.java index 881f124e..b20ae519 100644 --- a/src/main/java/electrosphere/renderer/model/Material.java +++ b/src/main/java/electrosphere/renderer/model/Material.java @@ -116,18 +116,11 @@ public class Material { Globals.renderingEngine.checkError(); } } - public void apply_material(OpenGLState openGLState, int diffuse_channel, int specular_channel){ - Texture diffuseTexture = Globals.assetManager.fetchTexture(diffuse); - if(diffuseTexture != null){ - diffuseTexture.bind(openGLState,diffuse_channel); - } - Texture specularTexture = Globals.assetManager.fetchTexture(specular); - if(specularTexture != null){ - specularTexture.bind(openGLState,specular_channel); - } - Globals.renderingEngine.checkError(); - } + /** + * Checks if this material has transparency + * @return true if there is transparency, false otherwise + */ public boolean isTransparent(){ boolean rVal = false; Texture diffuseTexture = Globals.assetManager.fetchTexture(diffuse); diff --git a/src/main/java/electrosphere/renderer/model/Mesh.java b/src/main/java/electrosphere/renderer/model/Mesh.java index 9858ff9e..aee2bab2 100644 --- a/src/main/java/electrosphere/renderer/model/Mesh.java +++ b/src/main/java/electrosphere/renderer/model/Mesh.java @@ -387,7 +387,7 @@ public class Mesh { if(renderPipelineState.getUseMaterial() && textureMask == null){ Globals.renderingEngine.checkError(); if(material == null){ - Globals.materialDefault.apply_material(openGLState,0,1); + Globals.materialDefault.apply_material(openGLState); openGLState.getActiveShader().setUniform(openGLState, "hasTransparency", 0); } else { material.apply_material(openGLState); diff --git a/src/main/java/electrosphere/renderer/texture/Texture.java b/src/main/java/electrosphere/renderer/texture/Texture.java index 3d8f986d..fc53d6ad 100644 --- a/src/main/java/electrosphere/renderer/texture/Texture.java +++ b/src/main/java/electrosphere/renderer/texture/Texture.java @@ -30,6 +30,13 @@ import static org.lwjgl.opengl.GL30.*; */ public class Texture { + /** + * Makes sure images are flipped the way opengl expects + */ + static { + STBImage.stbi_set_flip_vertically_on_load(true); + } + /** * Pointer for an uninitialized texture */