diff --git a/assets/Shaders/entities/particle/particle.fs b/assets/Shaders/entities/particle/particle.fs index 9e8cfb6f..04b5954f 100644 --- a/assets/Shaders/entities/particle/particle.fs +++ b/assets/Shaders/entities/particle/particle.fs @@ -2,6 +2,7 @@ #extension GL_ARB_shading_language_include : require #include "../../lib/lights.fs" #include "../../lib/material.fs" +#include "../../lib/standarduniform.fs" //foliage.fs @@ -34,41 +35,26 @@ float easeIn(float interpolator); float easeOut(float interpolator); void main(){ + vec3 norm = normalize(Normal); vec3 viewDir = normalize(vec3(viewPos) - FragPos); - - //grab light intensity - vec3 lightIntensity = vec3(calcLightIntensityTotal(Normal)); //get color of base texture - // vec3 textureColor = vec3((norm.x + 1) / 2.0, norm.y, 1.0 - (norm.x + 1) / 2.0); vec4 textureColor = texture(material.diffuse,TexCoord) * instanceColor; - // vec3 textureColor = vec3(0.17647,0.4,0.09411);//texture(material.diffuse, TexCoord).rgb; - //shadow - float shadow = ShadowCalculation(FragPosLightSpace, normalize(-directLight.direction), Normal); - - // - //point light calculations - uint clusterIndex = findCluster(ViewFragPos, zNear, zFar); - uint pointLightCount = clusters[clusterIndex].count; - for(int i = 0; i < pointLightCount; i++){ - uint pointLightIndex = clusters[clusterIndex].lightIndices[i]; - PointLight pointLight = pointLight[pointLightIndex]; - lightIntensity = lightIntensity + CalcPointLight(pointLight, Normal, FragPos, viewDir); - } - //error checking on light clusters - if(pointLightCount > MAX_LIGHTS_PER_CLUSTER){ - accum = vec4(1.0f,0.0f,0.0f,1); - reveal = textureColor.a; - return; - } + //the light level + vec3 light = getTotalLight( + material, + TexCoord, + vec3(viewPos.xyz), + FragPosLightSpace, + ViewFragPos, + FragPos, + norm, + viewDir + ); //calculate final color - vec4 finalColor = textureColor.rgba * vec4(lightIntensity,1.0);// * max(shadow,0.4); - // vec3 lightAmount = CalcDirLight(norm, viewDir); - // for(int i = 0; i < NR_POINT_LIGHTS; i++){ - // lightAmount += CalcPointLight(i, norm, FragPos, viewDir); - // } + vec4 finalColor = textureColor.rgba * vec4(light,1.0); //calculate weight function float weight = clamp(pow(min(1.0, finalColor.a * 10.0) + 0.01, 3.0) * 1e3 * diff --git a/assets/Shaders/entities/particle/particle.vs b/assets/Shaders/entities/particle/particle.vs index 2f85a1e7..4a5d06c1 100644 --- a/assets/Shaders/entities/particle/particle.vs +++ b/assets/Shaders/entities/particle/particle.vs @@ -1,5 +1,7 @@ //Vertex Shader #version 450 core +#extension GL_ARB_shading_language_include : require +#include "../../lib/standarduniform.fs" /** Bind points for different SSBOs @@ -28,9 +30,6 @@ layout(std430, binding = PARTICLE_SSBO_BIND_POINT) restrict buffer particleSSBO //coordinate space transformation matrices uniform mat4 transform; -uniform mat4 view; -uniform mat4 projection; -uniform mat4 lightSpaceMatrix; @@ -61,7 +60,7 @@ void main() { //push frag, normal, and texture positions to fragment shader FragPos = vec3(model * FinalVertex); - ViewFragPos = vec3(view * model * FinalVertex); + ViewFragPos = vec3(standardUniforms.view * model * FinalVertex); Normal = mat3(transpose(inverse(model))) * aNormal; //offset based on data stored in particle data @@ -70,9 +69,9 @@ void main() { //shadow map stuff - FragPosLightSpace = lightSpaceMatrix * vec4(FragPos, 1.0); + FragPosLightSpace = standardUniforms.lightSpaceMatrix * vec4(FragPos, 1.0); //set final position with opengl space - gl_Position = projection * view * model * FinalVertex; + gl_Position = standardUniforms.projection * standardUniforms.view * model * FinalVertex; } diff --git a/docs/src/progress/renderertodo.md b/docs/src/progress/renderertodo.md index 78b56104..2d7b6aad 100644 --- a/docs/src/progress/renderertodo.md +++ b/docs/src/progress/renderertodo.md @@ -2114,6 +2114,7 @@ Reorder main content draw calls to support non-OIT transparencies better Content debug supports rendering paths Rendering ai pathfinding paths Simplify part of transvoxel algo +Work on repairing particle system diff --git a/src/main/java/electrosphere/renderer/model/Mesh.java b/src/main/java/electrosphere/renderer/model/Mesh.java index 3c466e43..7539388f 100644 --- a/src/main/java/electrosphere/renderer/model/Mesh.java +++ b/src/main/java/electrosphere/renderer/model/Mesh.java @@ -618,11 +618,10 @@ public class Mesh { Globals.profiler.beginAggregateCpuSample("Mesh.complexDraw - Draw call"); if(renderPipelineState.getInstanced()){ - if(renderPipelineState.getInstanceCount() < 1){ - throw new Error("Failed to render instanced mesh with invalid instance count! " + this.getDebugData()); + if(renderPipelineState.getInstanceCount() > 0){ + GL45.glDrawElementsInstanced(GL45.GL_TRIANGLES, this.elementCount, GL45.GL_UNSIGNED_INT, 0, renderPipelineState.getInstanceCount()); + Globals.renderingEngine.checkError(); } - GL45.glDrawElementsInstanced(GL45.GL_TRIANGLES, this.elementCount, GL45.GL_UNSIGNED_INT, 0, renderPipelineState.getInstanceCount()); - Globals.renderingEngine.checkError(); } else if(this.useElementArray){ if(this.elementCount < 1){ throw new Error("Failed to render mesh with invalid element count! " + this.getDebugData()); diff --git a/src/main/java/electrosphere/renderer/ui/elements/Window.java b/src/main/java/electrosphere/renderer/ui/elements/Window.java index 24d3cfff..714d955a 100644 --- a/src/main/java/electrosphere/renderer/ui/elements/Window.java +++ b/src/main/java/electrosphere/renderer/ui/elements/Window.java @@ -645,6 +645,9 @@ public class Window implements DrawableElement, ContainerElement, NavigableEleme if(child instanceof DrawableElement){ DrawableElement drawableChild = (DrawableElement) child; drawableChild.setVisible(false); + if(drawableChild.getYogaNode() == Element.UNINITIALIZED_ID){ + throw new Error("Drawable child is uninitialized!"); + } Yoga.YGNodeInsertChild(yogaNode, drawableChild.getYogaNode(), childList.size() - 1); } }