noahn567

11-08-2014, 12:01 PM

Okay, so currently i have 3 attributes being used by the vertex shader. Position, Normal and texture cords. Recently i've added a Rig object to each rawmodel object. If i have these attributes,

List<Matrix4f> boneMatrixs;

ArrayList<ArrayList<Integer>> boneChains;

private float vertexWeights[];

private int vertexBoneCount[];

private float BoneVertexAttatch[][][];

How would i go about adding these attributes to effect each vertex? Thanks in advance!

Vertex Shader:

in vec3 position;

in vec2 textureCoords;

in vec3 normal;

out vec2 pass_textureCoords;

out vec3 surfaceNormal;

out vec3 toLightVector;

out vec3 toCameraVector;

uniform mat4 transformationMatrix;

uniform mat4 projectionMatrix;

uniform mat4 viewMatrix;

uniform vec3 lightPosition;

void main(void){

vec4 worldPosition = (transformationMatrix * vec4(position,1.0));

gl_Position = projectionMatrix * viewMatrix * worldPosition;

pass_textureCoords = textureCoords;

surfaceNormal = (transformationMatrix * vec4(normal,0.0)).xyz;

toLightVector = lightPosition - worldPosition.xyz;

toCameraVector = (inverse(viewMatrix) * vec4(0.0,0.0,0.0,1.0)).xyz - worldPosition.xyz;

}

Loader:

in vec3 position;

in vec2 textureCoords;

in vec3 normal;

out vec2 pass_textureCoords;

out vec3 surfaceNormal;

out vec3 toLightVector;

out vec3 toCameraVector;

uniform mat4 transformationMatrix;

uniform mat4 projectionMatrix;

uniform mat4 viewMatrix;

uniform vec3 lightPosition;

void main(void){

vec4 worldPosition = (transformationMatrix * vec4(position,1.0));

gl_Position = projectionMatrix * viewMatrix * worldPosition;

pass_textureCoords = textureCoords;

surfaceNormal = (transformationMatrix * vec4(normal,0.0)).xyz;

toLightVector = lightPosition - worldPosition.xyz;

toCameraVector = (inverse(viewMatrix) * vec4(0.0,0.0,0.0,1.0)).xyz - worldPosition.xyz;

}

Please ask if more information is needed.

List<Matrix4f> boneMatrixs;

ArrayList<ArrayList<Integer>> boneChains;

private float vertexWeights[];

private int vertexBoneCount[];

private float BoneVertexAttatch[][][];

How would i go about adding these attributes to effect each vertex? Thanks in advance!

Vertex Shader:

in vec3 position;

in vec2 textureCoords;

in vec3 normal;

out vec2 pass_textureCoords;

out vec3 surfaceNormal;

out vec3 toLightVector;

out vec3 toCameraVector;

uniform mat4 transformationMatrix;

uniform mat4 projectionMatrix;

uniform mat4 viewMatrix;

uniform vec3 lightPosition;

void main(void){

vec4 worldPosition = (transformationMatrix * vec4(position,1.0));

gl_Position = projectionMatrix * viewMatrix * worldPosition;

pass_textureCoords = textureCoords;

surfaceNormal = (transformationMatrix * vec4(normal,0.0)).xyz;

toLightVector = lightPosition - worldPosition.xyz;

toCameraVector = (inverse(viewMatrix) * vec4(0.0,0.0,0.0,1.0)).xyz - worldPosition.xyz;

}

Loader:

in vec3 position;

in vec2 textureCoords;

in vec3 normal;

out vec2 pass_textureCoords;

out vec3 surfaceNormal;

out vec3 toLightVector;

out vec3 toCameraVector;

uniform mat4 transformationMatrix;

uniform mat4 projectionMatrix;

uniform mat4 viewMatrix;

uniform vec3 lightPosition;

void main(void){

vec4 worldPosition = (transformationMatrix * vec4(position,1.0));

gl_Position = projectionMatrix * viewMatrix * worldPosition;

pass_textureCoords = textureCoords;

surfaceNormal = (transformationMatrix * vec4(normal,0.0)).xyz;

toLightVector = lightPosition - worldPosition.xyz;

toCameraVector = (inverse(viewMatrix) * vec4(0.0,0.0,0.0,1.0)).xyz - worldPosition.xyz;

}

Please ask if more information is needed.