FIx the lightmap not displaying when using the texcoord0

This commit is contained in:
Sam Gateau 2015-02-03 16:10:31 -08:00
parent b5e62922a2
commit 5719e277dd
3 changed files with 13 additions and 3 deletions

View file

@ -1303,6 +1303,8 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping,
QString jointRightHandID; QString jointRightHandID;
QString jointLeftToeID; QString jointLeftToeID;
QString jointRightToeID; QString jointRightToeID;
float lightmapOffset = 0.0f;
QVector<QString> humanIKJointNames; QVector<QString> humanIKJointNames;
for (int i = 0;; i++) { for (int i = 0;; i++) {
@ -2123,6 +2125,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping,
FBXTexture emissiveTexture; FBXTexture emissiveTexture;
glm::vec2 emissiveParams(0.f, 1.f); glm::vec2 emissiveParams(0.f, 1.f);
emissiveParams.x = lightmapOffset;
emissiveParams.y = lightmapLevel; emissiveParams.y = lightmapLevel;
QString emissiveTextureID = emissiveTextures.value(childID); QString emissiveTextureID = emissiveTextures.value(childID);
QString ambientTextureID = ambientTextures.value(childID); QString ambientTextureID = ambientTextures.value(childID);

View file

@ -49,7 +49,7 @@ static const GLenum _elementTypeToGLType[NUM_TYPES]= {
GL_UNSIGNED_BYTE GL_UNSIGNED_BYTE
}; };
#define CHECK_GL_ERROR() ::gpu::GLBackend::checkGLError() //#define CHECK_GL_ERROR() ::gpu::GLBackend::checkGLError()
//#define CHECK_GL_ERROR() #define CHECK_GL_ERROR()
#endif #endif

View file

@ -2120,6 +2120,7 @@ void NetworkGeometry::setGeometry(const FBXGeometry& geometry) {
NetworkMesh networkMesh; NetworkMesh networkMesh;
int totalIndices = 0; int totalIndices = 0;
bool checkForTexcoordLightmap = false;
foreach (const FBXMeshPart& part, mesh.parts) { foreach (const FBXMeshPart& part, mesh.parts) {
NetworkMeshPart networkPart; NetworkMeshPart networkPart;
if (!part.diffuseTexture.filename.isEmpty()) { if (!part.diffuseTexture.filename.isEmpty()) {
@ -2149,6 +2150,7 @@ void NetworkGeometry::setGeometry(const FBXGeometry& geometry) {
false, part.emissiveTexture.content); false, part.emissiveTexture.content);
networkPart.emissiveTextureName = part.emissiveTexture.name; networkPart.emissiveTextureName = part.emissiveTexture.name;
networkPart.emissiveTexture->setLoadPriorities(_loadPriorities); networkPart.emissiveTexture->setLoadPriorities(_loadPriorities);
checkForTexcoordLightmap = true;
} }
networkMesh.parts.append(networkPart); networkMesh.parts.append(networkPart);
@ -2215,7 +2217,12 @@ void NetworkGeometry::setGeometry(const FBXGeometry& geometry) {
if (mesh.tangents.size()) networkMesh._vertexFormat->setAttribute(gpu::Stream::TANGENT, channelNum++, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ)); if (mesh.tangents.size()) networkMesh._vertexFormat->setAttribute(gpu::Stream::TANGENT, channelNum++, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ));
if (mesh.colors.size()) networkMesh._vertexFormat->setAttribute(gpu::Stream::COLOR, channelNum++, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::RGB)); if (mesh.colors.size()) networkMesh._vertexFormat->setAttribute(gpu::Stream::COLOR, channelNum++, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::RGB));
if (mesh.texCoords.size()) networkMesh._vertexFormat->setAttribute(gpu::Stream::TEXCOORD, channelNum++, gpu::Element(gpu::VEC2, gpu::FLOAT, gpu::UV)); if (mesh.texCoords.size()) networkMesh._vertexFormat->setAttribute(gpu::Stream::TEXCOORD, channelNum++, gpu::Element(gpu::VEC2, gpu::FLOAT, gpu::UV));
if (mesh.texCoords1.size()) networkMesh._vertexFormat->setAttribute(gpu::Stream::TEXCOORD1, channelNum++, gpu::Element(gpu::VEC2, gpu::FLOAT, gpu::UV)); if (mesh.texCoords1.size()) {
networkMesh._vertexFormat->setAttribute(gpu::Stream::TEXCOORD1, channelNum++, gpu::Element(gpu::VEC2, gpu::FLOAT, gpu::UV));
} else if (checkForTexcoordLightmap && mesh.texCoords.size()) {
// need lightmap texcoord UV but doesn't have uv#1 so just reuse the same channel
networkMesh._vertexFormat->setAttribute(gpu::Stream::TEXCOORD1, channelNum - 1, gpu::Element(gpu::VEC2, gpu::FLOAT, gpu::UV));
}
if (mesh.clusterIndices.size()) networkMesh._vertexFormat->setAttribute(gpu::Stream::SKIN_CLUSTER_INDEX, channelNum++, gpu::Element(gpu::VEC4, gpu::NFLOAT, gpu::XYZW)); if (mesh.clusterIndices.size()) networkMesh._vertexFormat->setAttribute(gpu::Stream::SKIN_CLUSTER_INDEX, channelNum++, gpu::Element(gpu::VEC4, gpu::NFLOAT, gpu::XYZW));
if (mesh.clusterWeights.size()) networkMesh._vertexFormat->setAttribute(gpu::Stream::SKIN_CLUSTER_WEIGHT, channelNum++, gpu::Element(gpu::VEC4, gpu::NFLOAT, gpu::XYZW)); if (mesh.clusterWeights.size()) networkMesh._vertexFormat->setAttribute(gpu::Stream::SKIN_CLUSTER_WEIGHT, channelNum++, gpu::Element(gpu::VEC4, gpu::NFLOAT, gpu::XYZW));
} }