removing old uniforms
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
This commit is contained in:
parent
501d2898b7
commit
a6aa34a0f7
@ -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;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -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);
|
||||||
|
|||||||
@ -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;
|
||||||
}
|
}
|
||||||
@ -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;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -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;
|
||||||
}
|
}
|
||||||
@ -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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user