summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2016-03-08 15:34:36 -0300
committerJuan Linietsky <reduzio@gmail.com>2016-03-08 15:34:36 -0300
commita3d6768199c2100391343083900177c129a683d6 (patch)
treeaaad294dca3e730c5455f28c675e4eb20e7200db
parent9157a13aef46c0642fb46fcbe5c14892d42583b2 (diff)
parent23a4683879f4da5b09f05e79a43e061e78ccdb43 (diff)
Merge pull request #3958 from SaracenOne/cpu_skinning_path_fix
Fix to CPU skinning path when using GPU skinning (meshes with morphs)
-rw-r--r--drivers/gles2/rasterizer_gles2.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp
index 7740c9054b..0aff730916 100644
--- a/drivers/gles2/rasterizer_gles2.cpp
+++ b/drivers/gles2/rasterizer_gles2.cpp
@@ -6371,6 +6371,7 @@ void RasterizerGLES2::_render_list_forward(RenderList *p_render_list,const Trans
uint8_t prev_sort_flags=0xFF;
const BakedLightData *prev_baked_light=NULL;
RID prev_baked_light_texture;
+ const float *prev_morph_values=NULL;
Geometry::Type prev_geometry_type=Geometry::GEOMETRY_INVALID;
@@ -6409,6 +6410,7 @@ void RasterizerGLES2::_render_list_forward(RenderList *p_render_list,const Trans
const Skeleton *skeleton = e->skeleton;
const Geometry *geometry_cmp = e->geometry_cmp;
const BakedLightData *baked_light = e->instance->baked_light;
+ const float *morph_values = e->instance->morph_values.ptr();
bool rebind=false;
bool bind_baked_light_octree=false;
@@ -6431,6 +6433,7 @@ void RasterizerGLES2::_render_list_forward(RenderList *p_render_list,const Trans
prev_overrides=NULL; // make it diferent than NULL
prev_skeleton =NULL;
prev_sort_flags=0xFF;
+ prev_morph_values=NULL;
prev_geometry_type=Geometry::GEOMETRY_INVALID;
glEnable(GL_BLEND);
glDepthMask(GL_TRUE);
@@ -6643,10 +6646,14 @@ void RasterizerGLES2::_render_list_forward(RenderList *p_render_list,const Trans
rebind=true;
}
- if (use_hw_skeleton_xform && skeleton!=prev_skeleton) {
+ if (use_hw_skeleton_xform && (skeleton!=prev_skeleton||morph_values!=prev_morph_values)) {
if (!prev_skeleton || !skeleton)
rebind=true; //went from skeleton <-> no skeleton, needs rebind
- _setup_skeleton(skeleton);
+
+ if (morph_values==NULL)
+ _setup_skeleton(skeleton);
+ else
+ _setup_skeleton(NULL);
}
if (material!=prev_material || rebind) {
@@ -6734,7 +6741,7 @@ void RasterizerGLES2::_render_list_forward(RenderList *p_render_list,const Trans
}
if (skeleton != prev_skeleton || rebind) {
- if (skeleton) {
+ if (skeleton && morph_values == NULL) {
material_shader.set_uniform(MaterialShaderGLES2::SKELETON_MATRICES, max_texture_units - 2);
material_shader.set_uniform(MaterialShaderGLES2::SKELTEX_PIXEL_SIZE, skeleton->pixel_size);
}
@@ -6791,6 +6798,7 @@ void RasterizerGLES2::_render_list_forward(RenderList *p_render_list,const Trans
prev_light_type=e->light_type;
prev_sort_flags=sort_flags;
prev_baked_light=baked_light;
+ prev_morph_values=morph_values;
// prev_geometry_type=geometry->type;
}