glgsg: Fix skinning shader being unable to render unskinned models
Panda was adding a column with weights (0, 0, 0, 0), but these weights don't add up to 1 so no useful identity matrix can be produced. Instead it's better to fall back to the OpenGL default, (0, 0, 0, 1). I'm also defaulting the transform_index values to (0, 1, 2, 3) to support non-indexed skinning (although that's pretty esoteric, given that that only supports 4 transforms...)
This commit is contained in:
parent
a30f4be157
commit
3a2048e44a
|
|
@ -123,8 +123,9 @@ munge_data_impl(const GeomVertexData *data) {
|
|||
}
|
||||
|
||||
GeomVertexAnimationSpec animation = new_data->get_format()->get_animation();
|
||||
if (_shader_skinning || (_auto_shader && hardware_animated_vertices &&
|
||||
!basic_shaders_only && animation.get_animation_type() == AT_panda)) {
|
||||
if ((_shader_skinning && animation.get_animation_type() != AT_none) ||
|
||||
(_auto_shader && hardware_animated_vertices &&
|
||||
!basic_shaders_only && animation.get_animation_type() == AT_panda)) {
|
||||
animation.set_hardware(4, true);
|
||||
|
||||
} else if (hardware_animated_vertices &&
|
||||
|
|
|
|||
|
|
@ -1909,6 +1909,8 @@ reset() {
|
|||
get_extension_func("glUniform3uiv");
|
||||
_glUniform4uiv = (PFNGLUNIFORM4UIVPROC)
|
||||
get_extension_func("glUniform4uiv");
|
||||
_glVertexAttribI4ui = (PFNGLVERTEXATTRIBI4UIPROC)
|
||||
get_extension_func("glVertexAttribI4ui");
|
||||
|
||||
} else if (has_extension("GL_EXT_gpu_shader4")) {
|
||||
_glBindFragDataLocation = (PFNGLBINDFRAGDATALOCATIONPROC)
|
||||
|
|
@ -1923,10 +1925,13 @@ reset() {
|
|||
get_extension_func("glUniform3uivEXT");
|
||||
_glUniform4uiv = (PFNGLUNIFORM4UIVPROC)
|
||||
get_extension_func("glUniform4uivEXT");
|
||||
_glVertexAttribI4ui = (PFNGLVERTEXATTRIBI4UIPROC)
|
||||
get_extension_func("glVertexAttribI4uiEXT");
|
||||
|
||||
} else {
|
||||
_glBindFragDataLocation = nullptr;
|
||||
_glVertexAttribIPointer = nullptr;
|
||||
_glVertexAttribI4ui = nullptr;
|
||||
}
|
||||
if (is_at_least_gl_version(4, 1) ||
|
||||
has_extension("GL_ARB_vertex_attrib_64bit")) {
|
||||
|
|
@ -1955,8 +1960,11 @@ reset() {
|
|||
get_extension_func("glVertexAttribPointerARB");
|
||||
|
||||
_glBindFragDataLocation = nullptr;
|
||||
_glVertexAttribI4ui = nullptr;
|
||||
_glVertexAttribIPointer = nullptr;
|
||||
_glVertexAttribLPointer = nullptr;
|
||||
} else {
|
||||
_glVertexAttribI4ui = nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -2003,8 +2011,11 @@ reset() {
|
|||
if (is_at_least_gles_version(3, 0)) {
|
||||
_glVertexAttribIPointer = (PFNGLVERTEXATTRIBIPOINTERPROC)
|
||||
get_extension_func("glVertexAttribIPointer");
|
||||
_glVertexAttribI4ui = (PFNGLVERTEXATTRIBI4UIPROC)
|
||||
get_extension_func("glVertexAttribI4ui");
|
||||
} else {
|
||||
_glVertexAttribIPointer = nullptr;
|
||||
_glVertexAttribI4ui = nullptr;
|
||||
}
|
||||
|
||||
if (has_extension("GL_EXT_blend_func_extended")) {
|
||||
|
|
|
|||
|
|
@ -186,6 +186,7 @@ typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei coun
|
|||
typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
|
||||
|
|
@ -1010,6 +1011,7 @@ public:
|
|||
PFNGLVALIDATEPROGRAMPROC _glValidateProgram;
|
||||
PFNGLVERTEXATTRIB4FVPROC _glVertexAttrib4fv;
|
||||
PFNGLVERTEXATTRIB4DVPROC _glVertexAttrib4dv;
|
||||
PFNGLVERTEXATTRIBI4UIPROC _glVertexAttribI4ui;
|
||||
PFNGLVERTEXATTRIBPOINTERPROC _glVertexAttribPointer;
|
||||
PFNGLVERTEXATTRIBIPOINTERPROC _glVertexAttribIPointer;
|
||||
PFNGLVERTEXATTRIBLPOINTERPROC _glVertexAttribLPointer;
|
||||
|
|
|
|||
|
|
@ -2529,6 +2529,10 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) {
|
|||
_glgsg->_glVertexAttrib4fv(p, _glgsg->_scene_graph_color.get_data());
|
||||
#endif
|
||||
}
|
||||
else if (name == InternalName::get_transform_index() &&
|
||||
_glgsg->_glVertexAttribI4ui != nullptr) {
|
||||
_glgsg->_glVertexAttribI4ui(p, 0, 1, 2, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue