我使用GFX框架渲染了一件衣服,已经开启了深度测试,但是依然出现以下的渲染结果。
正面:

反面:

左侧:

右侧:

正面左侧45度:

正面右侧45度:

反面左侧45度:

反面右侧45度:

上面:

下面:

渐渐将摄像机拉近之后,透明的区域会缩小:


最终变正常:



但在某些角度看稍远一点的地方还是不正常:

经过多台设备的测试发现魅族和360手机上出现了这种问题,华为、小米、努比亚没有这种问题。
所以想问一下在座的大神们这是什么原因。
这是我的draw函数和init函数,C++的:
void OBJDrawInit( int width, int height ) {
GFX_start();
glViewport( 0.0f, 0.0f, width, height );
obj = OBJ_load( OBJ_FILE, PATH_RELATIVE_OBJ );
//计算视点
GFX_set_matrix_mode(PROJECTION_MATRIX);
GFX_load_identity();
GFX_set_perspective(60.0f, (float)width / (float)height, 0.1, obj->bounding_box.max_length * 5, 0.0f);
distanceScale = (float)height / (float)width * 1.25;
e.y = -obj->bounding_box.max_length * distanceScale;
rot_angle.x = 0.0f;
rot_angle.z = 0.0f;
c = obj->bounding_box.center;
unsigned int i = 0;
while(i != obj->n_objmesh)
{
OBJ_build_mesh( obj, i );
OBJ_free_mesh_vertex_data( obj, i );
++i;
}
i = 0;
while( i != obj->n_texture ) {
OBJDrawLoadTextureAt(i);
++i;
}
i = 0;
while(i != obj->n_objmaterial)
{
OBJDrawLoadMaterialAt(i);
++i;
}
}
void OBJDrawDraw( void ) {
static unsigned int start = get_milli_time(), fps = 0;
if (get_milli_time() - start >= 1000)
{
console_print("FPS:%d", fps);
start = get_milli_time();
fps = 0;
}
++fps;
glClearColor(0.8f, 1.0f, 1.0f, 1.0f);
glClear( GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_COLOR_BUFFER_BIT );
GFX_set_matrix_mode(MODELVIEW_MATRIX);
GFX_load_identity();
vec3 current = {0.0f, 0.0f, 0.0f};
GFX_look_at(&e, ¤t, &u);
GFX_rotate(rot_angle.x, 1.0f, 0.0f, 0.0f);
GFX_rotate(rot_angle.z, 0.0f, 0.0f, 1.0f);
GFX_translate(-c.x, -c.y, -c.z);
unsigned int i = 0;
while (i != obj->n_objmesh)
{
OBJMATERIAL *objmaterial = obj->objmesh[i].objtrianglelist[0].objmaterial;
if(objmaterial == NULL)
{
console_print("Mtl is null!\n");
GFX_push_matrix();
GFX_translate(obj->objmesh[i].location.x, obj->objmesh[i].location.y, obj->objmesh[i].location.z);
OBJ_draw_mesh(obj, i);
GFX_pop_matrix();
continue;
}
if(objmaterial->dissolve == 1.0f)
{
GFX_push_matrix();
GFX_translate(obj->objmesh[i].location.x, obj->objmesh[i].location.y, obj->objmesh[i].location.z);
OBJ_draw_mesh(obj, i);
GFX_pop_matrix();
}
++i;
}
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
i = 0;
while(i != obj->n_objmesh)
{
OBJMATERIAL *objmaterial = obj->objmesh[i].objtrianglelist[0].objmaterial;
if(objmaterial == NULL)
{
console_print("Mtl is null!\n");
GFX_push_matrix();
GFX_translate(obj->objmesh[i].location.x, obj->objmesh[i].location.y, obj->objmesh[i].location.z);
OBJ_draw_mesh(obj, i);
GFX_pop_matrix();
continue;
}
if(objmaterial->dissolve != 1.0f)
{
GFX_push_matrix();
GFX_translate(obj->objmesh[i].location.x, obj->objmesh[i].location.y, obj->objmesh[i].location.z);
glCullFace(GL_FRONT);
OBJ_draw_mesh(obj, i);
glCullFace(GL_BACK);
OBJ_draw_mesh(obj, i);
GFX_pop_matrix();
}
++i;
}
glDisable(GL_BLEND);
}
这是我的GLSurfaceView的配置:
setEGLContextClientVersion(2);
setEGLConfigChooser(true);
setEGLConfigChooser(8, 8, 8, 8, 8, 8);
r = new Renderer();
setRenderer( r );
我需要你们的帮助!非常感谢!
正面:

反面:

左侧:

右侧:

正面左侧45度:

正面右侧45度:

反面左侧45度:

反面右侧45度:

上面:

下面:

渐渐将摄像机拉近之后,透明的区域会缩小:


最终变正常:



但在某些角度看稍远一点的地方还是不正常:

经过多台设备的测试发现魅族和360手机上出现了这种问题,华为、小米、努比亚没有这种问题。
所以想问一下在座的大神们这是什么原因。
这是我的draw函数和init函数,C++的:
void OBJDrawInit( int width, int height ) {
GFX_start();
glViewport( 0.0f, 0.0f, width, height );
obj = OBJ_load( OBJ_FILE, PATH_RELATIVE_OBJ );
//计算视点
GFX_set_matrix_mode(PROJECTION_MATRIX);
GFX_load_identity();
GFX_set_perspective(60.0f, (float)width / (float)height, 0.1, obj->bounding_box.max_length * 5, 0.0f);
distanceScale = (float)height / (float)width * 1.25;
e.y = -obj->bounding_box.max_length * distanceScale;
rot_angle.x = 0.0f;
rot_angle.z = 0.0f;
c = obj->bounding_box.center;
unsigned int i = 0;
while(i != obj->n_objmesh)
{
OBJ_build_mesh( obj, i );
OBJ_free_mesh_vertex_data( obj, i );
++i;
}
i = 0;
while( i != obj->n_texture ) {
OBJDrawLoadTextureAt(i);
++i;
}
i = 0;
while(i != obj->n_objmaterial)
{
OBJDrawLoadMaterialAt(i);
++i;
}
}
void OBJDrawDraw( void ) {
static unsigned int start = get_milli_time(), fps = 0;
if (get_milli_time() - start >= 1000)
{
console_print("FPS:%d", fps);
start = get_milli_time();
fps = 0;
}
++fps;
glClearColor(0.8f, 1.0f, 1.0f, 1.0f);
glClear( GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_COLOR_BUFFER_BIT );
GFX_set_matrix_mode(MODELVIEW_MATRIX);
GFX_load_identity();
vec3 current = {0.0f, 0.0f, 0.0f};
GFX_look_at(&e, ¤t, &u);
GFX_rotate(rot_angle.x, 1.0f, 0.0f, 0.0f);
GFX_rotate(rot_angle.z, 0.0f, 0.0f, 1.0f);
GFX_translate(-c.x, -c.y, -c.z);
unsigned int i = 0;
while (i != obj->n_objmesh)
{
OBJMATERIAL *objmaterial = obj->objmesh[i].objtrianglelist[0].objmaterial;
if(objmaterial == NULL)
{
console_print("Mtl is null!\n");
GFX_push_matrix();
GFX_translate(obj->objmesh[i].location.x, obj->objmesh[i].location.y, obj->objmesh[i].location.z);
OBJ_draw_mesh(obj, i);
GFX_pop_matrix();
continue;
}
if(objmaterial->dissolve == 1.0f)
{
GFX_push_matrix();
GFX_translate(obj->objmesh[i].location.x, obj->objmesh[i].location.y, obj->objmesh[i].location.z);
OBJ_draw_mesh(obj, i);
GFX_pop_matrix();
}
++i;
}
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
i = 0;
while(i != obj->n_objmesh)
{
OBJMATERIAL *objmaterial = obj->objmesh[i].objtrianglelist[0].objmaterial;
if(objmaterial == NULL)
{
console_print("Mtl is null!\n");
GFX_push_matrix();
GFX_translate(obj->objmesh[i].location.x, obj->objmesh[i].location.y, obj->objmesh[i].location.z);
OBJ_draw_mesh(obj, i);
GFX_pop_matrix();
continue;
}
if(objmaterial->dissolve != 1.0f)
{
GFX_push_matrix();
GFX_translate(obj->objmesh[i].location.x, obj->objmesh[i].location.y, obj->objmesh[i].location.z);
glCullFace(GL_FRONT);
OBJ_draw_mesh(obj, i);
glCullFace(GL_BACK);
OBJ_draw_mesh(obj, i);
GFX_pop_matrix();
}
++i;
}
glDisable(GL_BLEND);
}
这是我的GLSurfaceView的配置:
setEGLContextClientVersion(2);
setEGLConfigChooser(true);
setEGLConfigChooser(8, 8, 8, 8, 8, 8);
r = new Renderer();
setRenderer( r );
我需要你们的帮助!非常感谢!