debugging - How to debug transforms in glsl vertex shaders in lwjgl -


i have been working on skeletal animation in game engine creating in lwjgl. can render entities not animated animated entities not draw, makes hard debug using methods suggested here. how can debug vertex shader when nothing drawing?


here vertex shader:

animated vertex shader

#version 330 core  in vec3 position; in vec2 texturecoordinates; in vec3 normal; in vec4 bones; in vec4 weights;  out vec2 pass_texturecoordinates; out vec3 surfacenormal; out vec3 tolightvector; out vec3 tocameravector;  uniform mat4 transformationmatrix; uniform mat4 projectionmatrix; uniform mat4 viewmatrix; uniform vec3 lightposition;  uniform mat4 joints[100];  void main(void){      vec4 originalposition = vec4(position, 1.0);      int index = int(bones.x);     vec4 animatedposition = (joints[index] * originalposition) * weights.x;     vec4 animatednormal = (joints[index] * vec4(normal, 0.0)) * weights.x;      index = int(bones.y);     animatedposition = (joints[index] * originalposition) * weights.y;     animatednormal = (joints[index] * vec4(normal, 0.0)) * weights.y;      index = int(bones.z);     animatedposition = (joints[index] * originalposition) * weights.z;     animatednormal = (joints[index] * vec4(position,1.0)) * weights.z;      index = int(bones.w);     animatedposition = (joints[index] * originalposition) * weights.w;     animatednormal = (joints[index] * vec4(normal, 0.0)) * weights.w;      vec4 worldposition = transformationmatrix * vec4(animatedposition.xyz,1.0);     gl_position = projectionmatrix * viewmatrix * worldposition;     pass_texturecoordinates = texturecoordinates;     surfacenormal = (transformationmatrix * vec4(animatednormal.x,animatednormal.y,animatednormal.z,0.0)).xyz;     tolightvector = lightposition - worldposition.xyz;     tocameravector = (inverse(viewmatrix) * vec4(0.0,0.0,0.0,1.0)).xyz - worldposition.xyz; } 

edit:

so there possibility error in uploading joints matrix array. in case, here loadmatrices method:

loading matrices

protected void loadmatrices(int location, matrix4f matrices[]){     floatbuffer matrixbuffer = bufferutils.createfloatbuffer(matrices.length * 16);      for(int = 0; < matrices.length; i++){         if(matrices[i] != null){             matrices[i].store(matrixbuffer);         }     }     matrixbuffer.flip();     gl20.gluniformmatrix4(location, false, matrixbuffer); } 

update:

using advice jozxyqk, simplified shader make sure running. did change this:

vec4 worldposition = transformationmatrix * vec4(animatedposition.xyz,1.0); 

to this:

vec4 worldposition = transformationmatrix * vec4(position.xyz,1.0); 

now renders entity fine (not using armature of course) lot easier me debug. unfortunately able start debugging right in car long time tomorrow debug , posting updates. jozxyqk!

update:

i got working, problem forgot activate attribute arrays. thanks!


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -