removing old uniforms
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good

This commit is contained in:
austin 2025-05-19 11:22:00 -04:00
parent 501d2898b7
commit a6aa34a0f7
7 changed files with 20 additions and 39 deletions

View File

@ -22,8 +22,6 @@ uniform mat4 lightSpaceMatrix;
const int MAX_WEIGHTS = 4; const int MAX_WEIGHTS = 4;
const int MAX_BONES = 100; const int MAX_BONES = 100;
uniform mat4 bones[MAX_BONES]; uniform mat4 bones[MAX_BONES];
uniform int hasBones;
uniform int numBones;

View File

@ -20,8 +20,6 @@ uniform mat4 projection;
const int MAX_WEIGHTS = 4; const int MAX_WEIGHTS = 4;
const int MAX_BONES = 100; const int MAX_BONES = 100;
uniform mat4 bones[MAX_BONES]; uniform mat4 bones[MAX_BONES];
uniform int hasBones;
uniform int numBones;
@ -38,18 +36,16 @@ void main() {
vec4 FinalVertex = vec4(aPos, 1.0); vec4 FinalVertex = vec4(aPos, 1.0);
vec4 FinalNormal = vec4(aNormal, 1.0); vec4 FinalNormal = vec4(aNormal, 1.0);
if(hasBones==1){ //calculate bone transform
//calculate bone transform mat4 BoneTransform = (bones[int(aIndex[0])] * aWeights[0]);
mat4 BoneTransform = (bones[int(aIndex[0])] * aWeights[0]); BoneTransform = BoneTransform + (bones[int(aIndex[1])] * aWeights[1]);
BoneTransform = BoneTransform + (bones[int(aIndex[1])] * aWeights[1]); BoneTransform = BoneTransform + (bones[int(aIndex[2])] * aWeights[2]);
BoneTransform = BoneTransform + (bones[int(aIndex[2])] * aWeights[2]); BoneTransform = BoneTransform + (bones[int(aIndex[3])] * aWeights[3]);
BoneTransform = BoneTransform + (bones[int(aIndex[3])] * aWeights[3]);
//apply bone transform to position vectors //apply bone transform to position vectors
FinalVertex = BoneTransform * vec4(aPos, 1.0); FinalVertex = BoneTransform * vec4(aPos, 1.0);
FinalNormal = BoneTransform * vec4(aNormal, 1.0); FinalNormal = BoneTransform * vec4(aNormal, 1.0);
}
//make sure the W component is 1.0 //make sure the W component is 1.0
FinalVertex = vec4(FinalVertex.xyz, 1.0); FinalVertex = vec4(FinalVertex.xyz, 1.0);

View File

@ -10,8 +10,6 @@ uniform mat4 model;
const int MAX_WEIGHTS = 4; const int MAX_WEIGHTS = 4;
const int MAX_BONES = 100; const int MAX_BONES = 100;
uniform mat4 bones[MAX_BONES]; uniform mat4 bones[MAX_BONES];
uniform int numBones;
uniform int hasBones;
void main(){ void main(){
mat4 BoneTransform = (bones[int(aIndex[0])] * aWeights[0]); mat4 BoneTransform = (bones[int(aIndex[0])] * aWeights[0]);
@ -23,9 +21,7 @@ void main(){
//normalize w component //normalize w component
FinalVertex = vec4(FinalVertex.xyz, 1.0); FinalVertex = vec4(FinalVertex.xyz, 1.0);
if(hasBones == 0){ FinalVertex = vec4(aPos, 1.0);
FinalVertex = vec4(aPos, 1.0);
}
gl_Position = lightSpaceMatrix * model * FinalVertex; gl_Position = lightSpaceMatrix * model * FinalVertex;
} }

View File

@ -22,8 +22,6 @@ uniform mat4 lightSpaceMatrix;
const int MAX_WEIGHTS = 4; const int MAX_WEIGHTS = 4;
const int MAX_BONES = 100; const int MAX_BONES = 100;
uniform mat4 bones[MAX_BONES]; uniform mat4 bones[MAX_BONES];
uniform int hasBones;
uniform int numBones;

View File

@ -12,8 +12,6 @@ uniform mat4 projection;
const int MAX_WEIGHTS = 4; const int MAX_WEIGHTS = 4;
const int MAX_BONES = 100; const int MAX_BONES = 100;
uniform mat4 bones[MAX_BONES]; uniform mat4 bones[MAX_BONES];
uniform int numBones;
uniform int hasBones;
void main() void main()
{ {
@ -32,9 +30,7 @@ void main()
FinalVertex = vec4(FinalVertex.xyz, 1.0); FinalVertex = vec4(FinalVertex.xyz, 1.0);
//have to account for if dont have bones //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; gl_Position = projection * view * model * FinalVertex;
} }

View File

@ -1897,6 +1897,7 @@ Renderer code cleanup
Renderer code cleanup Renderer code cleanup
Shader uniform parsing from source code Shader uniform parsing from source code
Visual shader uniform location caching Visual shader uniform location caching
Remove old uniforms from shaders and code to push uniforms

View File

@ -463,14 +463,8 @@ public class Mesh {
Globals.renderingEngine.checkError(); Globals.renderingEngine.checkError();
if(material == null){ if(material == null){
Globals.renderingEngine.getDefaultMaterial().applyMaterial(openGLState); Globals.renderingEngine.getDefaultMaterial().applyMaterial(openGLState);
openGLState.getActiveShader().setUniform(openGLState, "hasTransparency", 0);
} else { } else {
material.applyMaterial(openGLState); material.applyMaterial(openGLState);
if(material.hasTransparency){
openGLState.getActiveShader().setUniform(openGLState, "hasTransparency", 1);
} else {
openGLState.getActiveShader().setUniform(openGLState, "hasTransparency", 0);
}
} }
Globals.renderingEngine.checkError(); Globals.renderingEngine.checkError();
} }
@ -518,13 +512,12 @@ public class Mesh {
} }
boolean sentBones = false;
if(renderPipelineState.getUseBones()){ if(renderPipelineState.getUseBones()){
// //
//Handle bones //Handle bones
// //
if(bones != null && !bones.isEmpty()){ if(bones != null && !bones.isEmpty()){
openGLState.getActiveShader().setUniform(openGLState, "hasBones", 1);
openGLState.getActiveShader().setUniform(openGLState, "numBones", bones.size());
Iterator<String> boneIterator = boneIdList.iterator(); Iterator<String> boneIterator = boneIdList.iterator();
int incrementer = 0; int incrementer = 0;
while (boneIterator.hasNext()){ while (boneIterator.hasNext()){
@ -539,11 +532,14 @@ public class Mesh {
} }
incrementer++; incrementer++;
} }
} else { sentBones = true;
openGLState.getActiveShader().setUniform(openGLState, "hasBones", 0); }
}
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);
} }