diff --git a/assets/Shaders/VertexShader.vs b/assets/Shaders/VertexShader.vs index 0729e111..e977ca9e 100644 --- a/assets/Shaders/VertexShader.vs +++ b/assets/Shaders/VertexShader.vs @@ -22,8 +22,6 @@ uniform mat4 lightSpaceMatrix; const int MAX_WEIGHTS = 4; const int MAX_BONES = 100; uniform mat4 bones[MAX_BONES]; -uniform int hasBones; -uniform int numBones; diff --git a/assets/Shaders/core/anime/renderNormals.vs b/assets/Shaders/core/anime/renderNormals.vs index 71bddb6e..293f55db 100644 --- a/assets/Shaders/core/anime/renderNormals.vs +++ b/assets/Shaders/core/anime/renderNormals.vs @@ -20,8 +20,6 @@ uniform mat4 projection; const int MAX_WEIGHTS = 4; const int MAX_BONES = 100; uniform mat4 bones[MAX_BONES]; -uniform int hasBones; -uniform int numBones; @@ -38,18 +36,16 @@ void main() { vec4 FinalVertex = vec4(aPos, 1.0); vec4 FinalNormal = vec4(aNormal, 1.0); - if(hasBones==1){ - //calculate bone transform - mat4 BoneTransform = (bones[int(aIndex[0])] * aWeights[0]); - BoneTransform = BoneTransform + (bones[int(aIndex[1])] * aWeights[1]); - BoneTransform = BoneTransform + (bones[int(aIndex[2])] * aWeights[2]); - BoneTransform = BoneTransform + (bones[int(aIndex[3])] * aWeights[3]); + //calculate bone transform + mat4 BoneTransform = (bones[int(aIndex[0])] * aWeights[0]); + BoneTransform = BoneTransform + (bones[int(aIndex[1])] * aWeights[1]); + BoneTransform = BoneTransform + (bones[int(aIndex[2])] * aWeights[2]); + BoneTransform = BoneTransform + (bones[int(aIndex[3])] * aWeights[3]); - - //apply bone transform to position vectors - FinalVertex = BoneTransform * vec4(aPos, 1.0); - FinalNormal = BoneTransform * vec4(aNormal, 1.0); - } + + //apply bone transform to position vectors + FinalVertex = BoneTransform * vec4(aPos, 1.0); + FinalNormal = BoneTransform * vec4(aNormal, 1.0); //make sure the W component is 1.0 FinalVertex = vec4(FinalVertex.xyz, 1.0); diff --git a/assets/Shaders/core/lightDepth/lightDepth.vs b/assets/Shaders/core/lightDepth/lightDepth.vs index 67837eea..9ee21066 100644 --- a/assets/Shaders/core/lightDepth/lightDepth.vs +++ b/assets/Shaders/core/lightDepth/lightDepth.vs @@ -10,8 +10,6 @@ uniform mat4 model; const int MAX_WEIGHTS = 4; const int MAX_BONES = 100; uniform mat4 bones[MAX_BONES]; -uniform int numBones; -uniform int hasBones; void main(){ mat4 BoneTransform = (bones[int(aIndex[0])] * aWeights[0]); @@ -23,9 +21,7 @@ void main(){ //normalize w component FinalVertex = vec4(FinalVertex.xyz, 1.0); - if(hasBones == 0){ - FinalVertex = vec4(aPos, 1.0); - } + FinalVertex = vec4(aPos, 1.0); gl_Position = lightSpaceMatrix * model * FinalVertex; } \ No newline at end of file diff --git a/assets/Shaders/core/oit/general/VertexShader.vs b/assets/Shaders/core/oit/general/VertexShader.vs index 78e31d64..b017a842 100644 --- a/assets/Shaders/core/oit/general/VertexShader.vs +++ b/assets/Shaders/core/oit/general/VertexShader.vs @@ -22,8 +22,6 @@ uniform mat4 lightSpaceMatrix; const int MAX_WEIGHTS = 4; const int MAX_BONES = 100; uniform mat4 bones[MAX_BONES]; -uniform int hasBones; -uniform int numBones; diff --git a/assets/Shaders/core/volumeBuffer/volumetric.vs b/assets/Shaders/core/volumeBuffer/volumetric.vs index 9d8f828b..5006ebd9 100644 --- a/assets/Shaders/core/volumeBuffer/volumetric.vs +++ b/assets/Shaders/core/volumeBuffer/volumetric.vs @@ -12,8 +12,6 @@ uniform mat4 projection; const int MAX_WEIGHTS = 4; const int MAX_BONES = 100; uniform mat4 bones[MAX_BONES]; -uniform int numBones; -uniform int hasBones; void main() { @@ -32,9 +30,7 @@ void main() FinalVertex = vec4(FinalVertex.xyz, 1.0); //have to account for if dont have bones - if(hasBones == 0){ - FinalVertex = vec4(aPos, 1.0); - } + FinalVertex = vec4(aPos, 1.0); gl_Position = projection * view * model * FinalVertex; } \ No newline at end of file diff --git a/docs/src/progress/renderertodo.md b/docs/src/progress/renderertodo.md index 4f5c7d7e..3ed38b6b 100644 --- a/docs/src/progress/renderertodo.md +++ b/docs/src/progress/renderertodo.md @@ -1897,6 +1897,7 @@ Renderer code cleanup Renderer code cleanup Shader uniform parsing from source code Visual shader uniform location caching +Remove old uniforms from shaders and code to push uniforms diff --git a/src/main/java/electrosphere/renderer/model/Mesh.java b/src/main/java/electrosphere/renderer/model/Mesh.java index 8b90f2ba..f833bcc3 100644 --- a/src/main/java/electrosphere/renderer/model/Mesh.java +++ b/src/main/java/electrosphere/renderer/model/Mesh.java @@ -463,14 +463,8 @@ public class Mesh { Globals.renderingEngine.checkError(); if(material == null){ Globals.renderingEngine.getDefaultMaterial().applyMaterial(openGLState); - openGLState.getActiveShader().setUniform(openGLState, "hasTransparency", 0); } else { material.applyMaterial(openGLState); - if(material.hasTransparency){ - openGLState.getActiveShader().setUniform(openGLState, "hasTransparency", 1); - } else { - openGLState.getActiveShader().setUniform(openGLState, "hasTransparency", 0); - } } Globals.renderingEngine.checkError(); } @@ -518,13 +512,12 @@ public class Mesh { } + boolean sentBones = false; if(renderPipelineState.getUseBones()){ // //Handle bones // if(bones != null && !bones.isEmpty()){ - openGLState.getActiveShader().setUniform(openGLState, "hasBones", 1); - openGLState.getActiveShader().setUniform(openGLState, "numBones", bones.size()); Iterator boneIterator = boneIdList.iterator(); int incrementer = 0; while (boneIterator.hasNext()){ @@ -539,11 +532,14 @@ public class Mesh { } incrementer++; } - } else { - openGLState.getActiveShader().setUniform(openGLState, "hasBones", 0); + sentBones = true; + } + } + if(!sentBones){ + for(int i = 0; i < 4; i++){ + String currentUniform = "bones[" + i + "]"; + openGLState.getActiveShader().setUniform(openGLState, currentUniform, new Matrix4d().identity()); } - } else { - openGLState.getActiveShader().setUniform(openGLState, "hasBones", 0); }