Populating missing attribs with default values.

This commit is contained in:
Rinnegatamante
2020-10-22 15:26:05 +02:00
parent cf96e7d39e
commit 57b3457f61
2 changed files with 45 additions and 10 deletions
+29 -10
View File
@@ -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
+16
View File
@@ -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