I based the project in the great work of pspplayer and pspsdk.
Currently I'm trying to implement more complicated GE stuff like Skinning. But skinning is broken at this moment:
Without morphing (emulator):
With morphing (emulator) (bad implemented):
With morphing (psp):
I'm using opengl shaders to implement GE rendering.
Vertex shader:
Code: Select all
// Transform2D flag
uniform bool transform2D;
uniform mat4 boneMatrix;
uniform vec2 boneOffset;
// Sprites
uniform vec4 spriteCenter;
attribute int spriteCorner;
// Morphing
uniform mat4 BoneMatrix[8];
uniform int morphCount;
attribute float morphWeight[8];
void doSkinning(inout vec4 vertex) {
vec4 pos = vec4(0, 0, 0, 0);
for (int n = 0; n < morphCount; n++) {
pos += (morphWeight[n] * vertex) * (transpose(BoneMatrix[n]) * morphWeight[n]);
}
vertex = pos;
}
void main() {
vec4 pos = gl_Vertex;
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
//lightDir = normalize(vec3(gl_LightSource[0].position));
gl_FrontColor = gl_Color;
if (transform2D) {
gl_Position = ftransform();
return;
}
if (morphCount) {
doSkinning(pos);
}
gl_Position = gl_ModelViewProjectionMatrix * pos;
}
Code: Select all
// Color LookUp Table
uniform sampler1D clut;
uniform bool clutUse;
uniform int clutOffset;
uniform bool textureUse;
// Texture
uniform sampler2D tex;
void main() {
vec4 color;
// If there is clut
if (clutUse) {
// tex must have GL_NEAR
color = texture2D(tex, gl_TexCoord[0].st);
color = texture1D(clut, color.r + clutOffset);
} else {
if (textureUse) {
color = gl_Color * texture2D(tex, gl_TexCoord[0].st);
} else {
color = gl_Color;
}
}
gl_FragColor = color;
}
But it's obviusly bad implemented:
Code: Select all
void doSkinning(inout vec4 vertex) {
vec4 pos = vec4(0, 0, 0, 0);
for (int n = 0; n < morphCount; n++) {
pos += (morphWeight[n] * vertex) * (transpose(BoneMatrix[n]) * morphWeight[n]);
}
vertex = pos;
}
but I'm a completly newbie in skinning.
Someone can help me with that?
(Sorry about my bad english)
Thanks in advance,