Fix for blending on models.

This commit is contained in:
Andrzej Kapolka 2014-09-12 17:31:03 -07:00
parent 982ab75b61
commit 72f38900bb
5 changed files with 8 additions and 5 deletions

View file

@ -19,7 +19,7 @@ void main(void) {
normal = normalize(gl_ModelViewMatrix * vec4(gl_Normal, 0.0)); normal = normalize(gl_ModelViewMatrix * vec4(gl_Normal, 0.0));
// pass along the vertex color // pass along the vertex color
gl_FrontColor = gl_Color; gl_FrontColor = vec4(gl_Color.rgb, 0.0);
// and the texture coordinates // and the texture coordinates
gl_TexCoord[0] = gl_MultiTexCoord0; gl_TexCoord[0] = gl_MultiTexCoord0;

View file

@ -26,7 +26,7 @@ void main(void) {
interpolatedTangent = gl_ModelViewMatrix * vec4(tangent, 0.0); interpolatedTangent = gl_ModelViewMatrix * vec4(tangent, 0.0);
// pass along the vertex color // pass along the vertex color
gl_FrontColor = gl_Color; gl_FrontColor = vec4(gl_Color.rgb, 0.0);
// and the texture coordinates // and the texture coordinates
gl_TexCoord[0] = gl_MultiTexCoord0; gl_TexCoord[0] = gl_MultiTexCoord0;

View file

@ -35,7 +35,7 @@ void main(void) {
normal = normalize(gl_ModelViewMatrix * normal); normal = normalize(gl_ModelViewMatrix * normal);
// pass along the vertex color // pass along the vertex color
gl_FrontColor = vec4(1.0, 1.0, 1.0, 1.0); gl_FrontColor = vec4(gl_Color.rgb, 0.0);
// and the texture coordinates // and the texture coordinates
gl_TexCoord[0] = gl_MultiTexCoord0; gl_TexCoord[0] = gl_MultiTexCoord0;

View file

@ -43,7 +43,7 @@ void main(void) {
interpolatedTangent = gl_ModelViewMatrix * interpolatedTangent; interpolatedTangent = gl_ModelViewMatrix * interpolatedTangent;
// pass along the vertex color // pass along the vertex color
gl_FrontColor = vec4(1.0, 1.0, 1.0, 1.0); gl_FrontColor = vec4(gl_Color.rgb, 0.0);
// and the texture coordinates // and the texture coordinates
gl_TexCoord[0] = gl_MultiTexCoord0; gl_TexCoord[0] = gl_MultiTexCoord0;

View file

@ -428,8 +428,9 @@ bool Model::render(float alpha, RenderMode mode) {
// render opaque meshes with alpha testing // render opaque meshes with alpha testing
glDisable(GL_BLEND);
glEnable(GL_ALPHA_TEST); glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0.5f * alpha); glAlphaFunc(GL_EQUAL, 0.0f);
Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers( Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(
mode == DEFAULT_RENDER_MODE || mode == DIFFUSE_RENDER_MODE, mode == DEFAULT_RENDER_MODE || mode == DIFFUSE_RENDER_MODE,
@ -452,6 +453,8 @@ bool Model::render(float alpha, RenderMode mode) {
glCullFace(GL_BACK); glCullFace(GL_BACK);
} }
glEnable(GL_BLEND);
// deactivate vertex arrays after drawing // deactivate vertex arrays after drawing
glDisableClientState(GL_NORMAL_ARRAY); glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_VERTEX_ARRAY);