diff --git a/src/gl/gl3pipe.cpp b/src/gl/gl3pipe.cpp index 8ba7b29..5fd33c8 100644 --- a/src/gl/gl3pipe.cpp +++ b/src/gl/gl3pipe.cpp @@ -201,16 +201,19 @@ defaultInstanceCB(Geometry *geo, InstanceDataHeader *header, bool32 reinstance) a++; } stride += 4; - - // Texture coordinates - for(int32 n = 0; n < geo->numTexCoordSets; n++){ - a->index = ATTRIB_TEXCOORDS0+n; - a->size = 2; - a->type = GL_FLOAT; - a->normalized = GL_FALSE; - a->offset = stride; - stride += 8; - a++; + + if (geo->numTexCoordSets <= 0) stride += 8; + else { + // Texture coordinates + for(int32 n = 0; n < geo->numTexCoordSets; n++){ + a->index = ATTRIB_TEXCOORDS0+n; + a->size = 2; + a->type = GL_FLOAT; + a->normalized = GL_FALSE; + a->offset = stride; + stride += 8; + a++; + } } header->numAttribs = a - tmpAttribs; @@ -252,6 +255,13 @@ defaultInstanceCB(Geometry *geo, InstanceDataHeader *header, bool32 reinstance) instV3d(VERT_FLOAT3, verts + a->offset, geo->morphTargets[0].normals, header->totalNumVertex, a->stride); + } else if (!hasNormals) { + int i = 0; + while (i < header->totalNumVertex) { + float *verts_f = (float*)&verts[12 + i * 36]; + verts_f[0] = verts_f[1] = verts_f[2] = 0; + i++; + } } // Prelighting @@ -268,6 +278,15 @@ defaultInstanceCB(Geometry *geo, InstanceDataHeader *header, bool32 reinstance) inst->numVertices, a->stride); inst++; } + } else if (!isPrelit) { + int i = 0; + while (i < header->totalNumVertex) { + verts[24 + i * 36] = 0; + verts[25 + i * 36] = 0; + verts[26 + i * 36] = 0; + verts[27 + i * 36] = 255; + i++; + } } // Texture coordinates diff --git a/src/gl/gl3skin.cpp b/src/gl/gl3skin.cpp index 85efe32..3d749b4 100644 --- a/src/gl/gl3skin.cpp +++ b/src/gl/gl3skin.cpp @@ -147,6 +147,13 @@ skinInstanceCB(Geometry *geo, InstanceDataHeader *header, bool32 reinstance) instV3d(VERT_FLOAT3, verts + a->offset, geo->morphTargets[0].normals, header->totalNumVertex, a->stride); + } else if (!hasNormals) { + int i = 0; + while (i < header->totalNumVertex) { + float *verts_f = (float*)&verts[12 + i * 56]; + verts_f[0] = verts_f[1] = verts_f[2] = 0; + i++; + } } // Prelighting @@ -156,6 +163,15 @@ skinInstanceCB(Geometry *geo, InstanceDataHeader *header, bool32 reinstance) instColor(VERT_RGBA, verts + a->offset, geo->colors, header->totalNumVertex, a->stride); + } else if (!isPrelit) { + int i = 0; + while (i < header->totalNumVertex) { + verts[24 + i * 56] = 0; + verts[25 + i * 56] = 0; + verts[26 + i * 56] = 0; + verts[27 + i * 56] = 255; + i++; + } } // Texture coordinates