diff --git a/kraken/KRPipeline.cpp b/kraken/KRPipeline.cpp index 7fc63df..a9db344 100644 --- a/kraken/KRPipeline.cpp +++ b/kraken/KRPipeline.cpp @@ -77,27 +77,27 @@ KRPipeline::KRPipeline(KRContext& context, KrDeviceHandle deviceHandle, const KR KRMesh::KRENGINE_ATTRIB_VERTEX, KRMesh::KRENGINE_ATTRIB_NORMAL, KRMesh::KRENGINE_ATTRIB_TANGENT, - KRMesh::KRENGINE_ATTRIB_TEXUVA, - KRMesh::KRENGINE_ATTRIB_TEXUVB, - KRMesh::KRENGINE_ATTRIB_TEXUVC, - KRMesh::KRENGINE_ATTRIB_TEXUVD, - KRMesh::KRENGINE_ATTRIB_TEXUVE, - KRMesh::KRENGINE_ATTRIB_TEXUVF, - KRMesh::KRENGINE_ATTRIB_TEXUVG, - KRMesh::KRENGINE_ATTRIB_TEXUVH, + KRMesh::KRENGINE_ATTRIB_TEXCOORD0, + KRMesh::KRENGINE_ATTRIB_TEXCOORD1, + KRMesh::KRENGINE_ATTRIB_TEXCOORD2, + KRMesh::KRENGINE_ATTRIB_TEXCOORD3, + KRMesh::KRENGINE_ATTRIB_TEXCOORD4, + KRMesh::KRENGINE_ATTRIB_TEXCOORD5, + KRMesh::KRENGINE_ATTRIB_TEXCOORD6, + KRMesh::KRENGINE_ATTRIB_TEXCOORD7, KRMesh::KRENGINE_ATTRIB_BONEINDEXES, KRMesh::KRENGINE_ATTRIB_BONEWEIGHTS, KRMesh::KRENGINE_ATTRIB_VERTEX, KRMesh::KRENGINE_ATTRIB_NORMAL, KRMesh::KRENGINE_ATTRIB_TANGENT, - KRMesh::KRENGINE_ATTRIB_TEXUVA, - KRMesh::KRENGINE_ATTRIB_TEXUVB, - KRMesh::KRENGINE_ATTRIB_TEXUVC, - KRMesh::KRENGINE_ATTRIB_TEXUVD, - KRMesh::KRENGINE_ATTRIB_TEXUVE, - KRMesh::KRENGINE_ATTRIB_TEXUVF, - KRMesh::KRENGINE_ATTRIB_TEXUVG, - KRMesh::KRENGINE_ATTRIB_TEXUVH, + KRMesh::KRENGINE_ATTRIB_TEXCOORD0, + KRMesh::KRENGINE_ATTRIB_TEXCOORD1, + KRMesh::KRENGINE_ATTRIB_TEXCOORD2, + KRMesh::KRENGINE_ATTRIB_TEXCOORD3, + KRMesh::KRENGINE_ATTRIB_TEXCOORD4, + KRMesh::KRENGINE_ATTRIB_TEXCOORD5, + KRMesh::KRENGINE_ATTRIB_TEXCOORD6, + KRMesh::KRENGINE_ATTRIB_TEXCOORD7, }; uint32_t attribute_locations[KRMesh::KRENGINE_NUM_ATTRIBUTES] = {}; @@ -143,9 +143,9 @@ KRPipeline::KRPipeline(KRContext& context, KrDeviceHandle deviceHandle, const KR } else if (strcmp(input_var.name, "vertex_tangent") == 0) { attribute_locations[KRMesh::KRENGINE_ATTRIB_TANGENT] = input_var.location + 1; } else if (strcmp(input_var.name, "vertex_uv") == 0) { - attribute_locations[KRMesh::KRENGINE_ATTRIB_TEXUVA] = input_var.location + 1; + attribute_locations[KRMesh::KRENGINE_ATTRIB_TEXCOORD0] = input_var.location + 1; } else if (strcmp(input_var.name, "vertex_lightmap_uv") == 0) { - attribute_locations[KRMesh::KRENGINE_ATTRIB_TEXUVB] = input_var.location + 1; + attribute_locations[KRMesh::KRENGINE_ATTRIB_TEXCOORD1] = input_var.location + 1; } else if (strcmp(input_var.name, "bone_indexes") == 0) { attribute_locations[KRMesh::KRENGINE_ATTRIB_BONEINDEXES] = input_var.location + 1; } else if (strcmp(input_var.name, "bone_weights") == 0) { diff --git a/kraken/nodes/KRCamera.cpp b/kraken/nodes/KRCamera.cpp index a5c7c90..90fcdaa 100755 --- a/kraken/nodes/KRCamera.cpp +++ b/kraken/nodes/KRCamera.cpp @@ -91,7 +91,7 @@ KRCamera::KRCamera(KRScene& scene, std::string name) m_fade_color = Vector4::Zero(); - m_debug_text_vbo_data.init(m_pContext->getMeshManager(), &m_debug_text_vertices, nullptr, (1 << KRMesh::KRENGINE_ATTRIB_VERTEX) | (1 << KRMesh::KRENGINE_ATTRIB_TEXUVA), true, KRMeshManager::KRVBOData::IMMEDIATE + m_debug_text_vbo_data.init(m_pContext->getMeshManager(), &m_debug_text_vertices, nullptr, (1 << KRMesh::KRENGINE_ATTRIB_VERTEX) | (1 << KRMesh::KRENGINE_ATTRIB_TEXCOORD0), true, KRMeshManager::KRVBOData::IMMEDIATE #if KRENGINE_DEBUG_GPU_LABELS , "Debug Text" #endif @@ -616,7 +616,7 @@ void KRCamera::renderDebug(RenderInfo& ri) info.renderPass = ri.renderPass; info.rasterMode = RasterMode::kAlphaBlendNoTest; info.cullMode = CullMode::kCullNone; - info.vertexAttributes = (1 << KRMesh::KRENGINE_ATTRIB_VERTEX) | (1 << KRMesh::KRENGINE_ATTRIB_TEXUVA); + info.vertexAttributes = (1 << KRMesh::KRENGINE_ATTRIB_VERTEX) | (1 << KRMesh::KRENGINE_ATTRIB_TEXCOORD0); info.modelFormat = ModelFormat::KRENGINE_MODEL_FORMAT_TRIANGLES; KRPipeline* fontShader = m_pContext->getPipelineManager()->getPipeline(*ri.surface, info); diff --git a/kraken/nodes/KRLight.cpp b/kraken/nodes/KRLight.cpp index 1476b26..cea7d53 100755 --- a/kraken/nodes/KRLight.cpp +++ b/kraken/nodes/KRLight.cpp @@ -238,7 +238,7 @@ void KRLight::render(RenderInfo& ri) info.renderPass = ri.renderPass; info.rasterMode = RasterMode::kAdditive; info.cullMode = CullMode::kCullNone; - info.vertexAttributes = (1 << KRMesh::KRENGINE_ATTRIB_VERTEX) | (1 << KRMesh::KRENGINE_ATTRIB_TEXUVA); + info.vertexAttributes = (1 << KRMesh::KRENGINE_ATTRIB_VERTEX) | (1 << KRMesh::KRENGINE_ATTRIB_TEXCOORD0); info.modelFormat = ModelFormat::KRENGINE_MODEL_FORMAT_TRIANGLES; KRPipeline* pParticleShader = m_pContext->getPipelineManager()->getPipeline(*ri.surface, info); if (pParticleShader && pParticleShader->bind(ri, getParticleModelMatrix(*ri.viewport))) { // TODO: Pass light index to shader diff --git a/kraken/nodes/KRParticleSystemNewtonian.cpp b/kraken/nodes/KRParticleSystemNewtonian.cpp index d8b5781..13af7e3 100755 --- a/kraken/nodes/KRParticleSystemNewtonian.cpp +++ b/kraken/nodes/KRParticleSystemNewtonian.cpp @@ -98,7 +98,7 @@ void KRParticleSystemNewtonian::render(RenderInfo& ri) info.renderPass = ri.renderPass; info.rasterMode = RasterMode::kAdditive; info.cullMode = CullMode::kCullNone; - info.vertexAttributes = (1 << KRMesh::KRENGINE_ATTRIB_VERTEX) | (1 << KRMesh::KRENGINE_ATTRIB_TEXUVA); + info.vertexAttributes = (1 << KRMesh::KRENGINE_ATTRIB_VERTEX) | (1 << KRMesh::KRENGINE_ATTRIB_TEXCOORD0); info.modelFormat = ModelFormat::KRENGINE_MODEL_FORMAT_TRIANGLES; KRPipeline* pParticleShader = m_pContext->getPipelineManager()->getPipeline(*ri.surface, info); diff --git a/kraken/resources/KRResource+fbx.cpp b/kraken/resources/KRResource+fbx.cpp index d347cbb..7563524 100755 --- a/kraken/resources/KRResource+fbx.cpp +++ b/kraken/resources/KRResource+fbx.cpp @@ -1397,7 +1397,7 @@ void LoadMesh(KRContext& context, FbxScene* pFbxScene, FbxGeometryConverter* pGe // std::vector > bone_indexes; // // std::vector vertices; -// std::vector uva; +// std::vector texcoord0; // std::vector uvb; // std::vector normals; // std::vector tangents; @@ -1479,7 +1479,7 @@ void LoadMesh(KRContext& context, FbxScene* pFbxScene, FbxGeometryConverter* pGe new_uva = Vector2(uv[0], uv[1]); } } - mi.uva.push_back(new_uva); + mi.texcoord0.push_back(new_uva); } if (uv_count >= 2) { diff --git a/kraken/resources/KRResource+obj.cpp b/kraken/resources/KRResource+obj.cpp index be70078..e69ab7a 100755 --- a/kraken/resources/KRResource+obj.cpp +++ b/kraken/resources/KRResource+obj.cpp @@ -287,11 +287,11 @@ KRMesh* KRResource::LoadObj(KRContext& context, const std::string& path) iVertex += 2; mi.vertices.push_back(firstFaceVertex); - mi.uv[0].push_back(firstFaceUva); + mi.texcoord[0].push_back(firstFaceUva); mi.normals.push_back(firstFaceNormal); mi.vertices.push_back(prevFaceVertex); - mi.uv[0].push_back(prevFaceUva); + mi.texcoord[0].push_back(prevFaceUva); mi.normals.push_back(prevFaceNormal); } Vector3 vertex = indexed_vertices[pFace[iFaceVertex * 3 + 1]]; @@ -305,7 +305,7 @@ KRMesh* KRResource::LoadObj(KRContext& context, const std::string& path) } mi.vertices.push_back(vertex); - mi.uv[0].push_back(new_uva); + mi.texcoord[0].push_back(new_uva); mi.normals.push_back(normal); if (iFaceVertex == 0) { diff --git a/kraken/resources/mesh/KRMesh.cpp b/kraken/resources/mesh/KRMesh.cpp index ac16a03..5bd8253 100755 --- a/kraken/resources/mesh/KRMesh.cpp +++ b/kraken/resources/mesh/KRMesh.cpp @@ -528,7 +528,7 @@ void KRMesh::LoadData(const KRMesh::mesh_info& mi, bool calculate_normals, bool bool use_short_vertexes = false; bool use_short_normals = true; bool use_short_tangents = true; - bool use_short_uv[8] = { true, true, true, true, true, true, true, true }; + bool use_short_texcoord[8] = { true, true, true, true, true, true, true, true }; if (use_short_vertexes) { for (std::vector::const_iterator itr = mi.vertices.begin(); itr != mi.vertices.end(); itr++) { @@ -539,19 +539,19 @@ void KRMesh::LoadData(const KRMesh::mesh_info& mi, bool calculate_normals, bool } for (int set = 0; set < 8; set++) { - if (use_short_uv[set]) { - for (std::vector::const_iterator itr = mi.uv[set].begin(); itr != mi.uv[set].end(); itr++) { + if (use_short_texcoord[set]) { + for (std::vector::const_iterator itr = mi.texcoord[set].begin(); itr != mi.texcoord[set].end(); itr++) { if (fabsf((*itr).x) > 1.0f || fabsf((*itr).y) > 1.0f) { - use_short_uv[set] = false; + use_short_texcoord[set] = false; break; } } } - if (use_short_uv[set]) { - for (std::vector::const_iterator itr = mi.uv[set].begin(); itr != mi.uv[set].end(); itr++) { + if (use_short_texcoord[set]) { + for (std::vector::const_iterator itr = mi.texcoord[set].begin(); itr != mi.texcoord[set].end(); itr++) { if (fabsf((*itr).x) > 1.0f || fabsf((*itr).y) > 1.0f) { - use_short_uv[set] = false; + use_short_texcoord[set] = false; break; } } @@ -581,18 +581,18 @@ void KRMesh::LoadData(const KRMesh::mesh_info& mi, bool calculate_normals, bool } } for (int set = 0; set < 8; set++) { - if (mi.uv[set].size()) { - if (use_short_uv[set]) { - vertex_attrib_flags += (1 << (KRENGINE_ATTRIB_TEXUVA_SHORT + set)); + if (mi.texcoord[set].size()) { + if (use_short_texcoord[set]) { + vertex_attrib_flags += (1 << (KRENGINE_ATTRIB_TEXCOORD0_SHORT + set)); } else { - vertex_attrib_flags += (1 << (KRENGINE_ATTRIB_TEXUVA + set)); + vertex_attrib_flags += (1 << (KRENGINE_ATTRIB_TEXCOORD0 + set)); } } - if (mi.uv[set].size()) { - if (use_short_uv[set]) { - vertex_attrib_flags += (1 << (KRENGINE_ATTRIB_TEXUVB_SHORT + set)); + if (mi.texcoord[set].size()) { + if (use_short_texcoord[set]) { + vertex_attrib_flags += (1 << (KRENGINE_ATTRIB_TEXCOORD1_SHORT + set)); } else { - vertex_attrib_flags += (1 << (KRENGINE_ATTRIB_TEXUVB + set)); + vertex_attrib_flags += (1 << (KRENGINE_ATTRIB_TEXCOORD1 + set)); } } } @@ -659,8 +659,8 @@ void KRMesh::LoadData(const KRMesh::mesh_info& mi, bool calculate_normals, bool m_extents.encapsulate(source_vertex); } for (int set = 0; set < 8; set++) { - if ((int)mi.uv[set].size() > iVertex) { - setVertexUV(set, iVertex, mi.uv[set][iVertex]); + if ((int)mi.texcoord[set].size() > iVertex) { + setVertexTexCoord(set, iVertex, mi.texcoord[set][iVertex]); } } if ((int)mi.normals.size() > iVertex) { @@ -716,9 +716,9 @@ void KRMesh::LoadData(const KRMesh::mesh_info& mi, bool calculate_normals, bool Vector3 first_tangent = getVertexTangent(iVertex); if (first_tangent.x == 0.0f && first_tangent.y == 0.0f && first_tangent.z == 0.0f) { - Vector2 uv0 = getVertexUV(0, iVertex); - Vector2 uv1 = getVertexUV(0, iVertex + 1); - Vector2 uv2 = getVertexUV(0, iVertex + 2); + Vector2 uv0 = getVertexTexCoord(0, iVertex); + Vector2 uv1 = getVertexTexCoord(0, iVertex + 1); + Vector2 uv2 = getVertexTexCoord(0, iVertex + 2); Vector2 st1 = Vector2::Create(uv1.x - uv0.x, uv1.y - uv0.y); Vector2 st2 = Vector2::Create(uv2.x - uv0.x, uv2.y - uv0.y); @@ -903,13 +903,13 @@ Vector3 KRMesh::getVertexTangent(int index) const } } -Vector2 KRMesh::getVertexUV(int set, int index) const +Vector2 KRMesh::getVertexTexCoord(int set, int index) const { - if (has_vertex_attribute((vertex_attrib_t)(KRENGINE_ATTRIB_TEXUVA_SHORT + set))) { - short* v = (short*)(getVertexData(index) + m_vertex_attribute_offset[KRENGINE_ATTRIB_TEXUVA_SHORT + set]); + if (has_vertex_attribute((vertex_attrib_t)(KRENGINE_ATTRIB_TEXCOORD0_SHORT + set))) { + short* v = (short*)(getVertexData(index) + m_vertex_attribute_offset[KRENGINE_ATTRIB_TEXCOORD0_SHORT + set]); return Vector2::Create((float)v[0] / 32767.0f, (float)v[1] / 32767.0f); - } else if (has_vertex_attribute((vertex_attrib_t)(KRENGINE_ATTRIB_TEXUVA + set))) { - return Vector2::Create((float*)(getVertexData(index) + m_vertex_attribute_offset[KRENGINE_ATTRIB_TEXUVA + set])); + } else if (has_vertex_attribute((vertex_attrib_t)(KRENGINE_ATTRIB_TEXCOORD0 + set))) { + return Vector2::Create((float*)(getVertexData(index) + m_vertex_attribute_offset[KRENGINE_ATTRIB_TEXCOORD0 + set])); } else { return Vector2::Zero(); } @@ -960,15 +960,15 @@ void KRMesh::setVertexTangent(int index, const Vector3& v) } } -void KRMesh::setVertexUV(int set, int index, const Vector2& v) +void KRMesh::setVertexTexCoord(int set, int index, const Vector2& v) { - if (has_vertex_attribute((vertex_attrib_t)((KRENGINE_ATTRIB_TEXUVA_SHORT + set)))) + if (has_vertex_attribute((vertex_attrib_t)((KRENGINE_ATTRIB_TEXCOORD0_SHORT + set)))) { - short* vert = (short*)(getVertexData(index) + m_vertex_attribute_offset[KRENGINE_ATTRIB_TEXUVA_SHORT + set]); + short* vert = (short*)(getVertexData(index) + m_vertex_attribute_offset[KRENGINE_ATTRIB_TEXCOORD0_SHORT + set]); vert[0] = (short)(v.x * 32767.0f); vert[1] = (short)(v.y * 32767.0f); - } else if (has_vertex_attribute((vertex_attrib_t)(KRENGINE_ATTRIB_TEXUVA + set))) { - float* vert = (float*)(getVertexData(index) + m_vertex_attribute_offset[KRENGINE_ATTRIB_TEXUVA + set]); + } else if (has_vertex_attribute((vertex_attrib_t)(KRENGINE_ATTRIB_TEXCOORD0 + set))) { + float* vert = (float*)(getVertexData(index) + m_vertex_attribute_offset[KRENGINE_ATTRIB_TEXCOORD0 + set]); vert[0] = v.x; vert[1] = v.y; } @@ -1010,28 +1010,28 @@ size_t KRMesh::VertexSizeForAttributes(__int32_t vertex_attrib_flags) if (has_vertex_attribute(vertex_attrib_flags, KRENGINE_ATTRIB_TANGENT)) { data_size += sizeof(float) * 3; } - if (has_vertex_attribute(vertex_attrib_flags, KRENGINE_ATTRIB_TEXUVA)) { + if (has_vertex_attribute(vertex_attrib_flags, KRENGINE_ATTRIB_TEXCOORD0)) { data_size += sizeof(float) * 2; } - if (has_vertex_attribute(vertex_attrib_flags, KRENGINE_ATTRIB_TEXUVB)) { + if (has_vertex_attribute(vertex_attrib_flags, KRENGINE_ATTRIB_TEXCOORD1)) { data_size += sizeof(float) * 2; } - if (has_vertex_attribute(vertex_attrib_flags, KRENGINE_ATTRIB_TEXUVC)) { + if (has_vertex_attribute(vertex_attrib_flags, KRENGINE_ATTRIB_TEXCOORD2)) { data_size += sizeof(float) * 2; } - if (has_vertex_attribute(vertex_attrib_flags, KRENGINE_ATTRIB_TEXUVD)) { + if (has_vertex_attribute(vertex_attrib_flags, KRENGINE_ATTRIB_TEXCOORD3)) { data_size += sizeof(float) * 2; } - if (has_vertex_attribute(vertex_attrib_flags, KRENGINE_ATTRIB_TEXUVE)) { + if (has_vertex_attribute(vertex_attrib_flags, KRENGINE_ATTRIB_TEXCOORD4)) { data_size += sizeof(float) * 2; } - if (has_vertex_attribute(vertex_attrib_flags, KRENGINE_ATTRIB_TEXUVF)) { + if (has_vertex_attribute(vertex_attrib_flags, KRENGINE_ATTRIB_TEXCOORD5)) { data_size += sizeof(float) * 2; } - if (has_vertex_attribute(vertex_attrib_flags, KRENGINE_ATTRIB_TEXUVG)) { + if (has_vertex_attribute(vertex_attrib_flags, KRENGINE_ATTRIB_TEXCOORD6)) { data_size += sizeof(float) * 2; } - if (has_vertex_attribute(vertex_attrib_flags, KRENGINE_ATTRIB_TEXUVH)) { + if (has_vertex_attribute(vertex_attrib_flags, KRENGINE_ATTRIB_TEXCOORD7)) { data_size += sizeof(float) * 2; } if (has_vertex_attribute(vertex_attrib_flags, KRENGINE_ATTRIB_BONEINDEXES)) { @@ -1049,28 +1049,28 @@ size_t KRMesh::VertexSizeForAttributes(__int32_t vertex_attrib_flags) if (has_vertex_attribute(vertex_attrib_flags, KRENGINE_ATTRIB_TANGENT_SHORT)) { data_size += sizeof(short) * 4; // Extra short added in order to maintain 32-bit alignment. TODO, FINDME - Perhaps we can bind this as a vec4 and use the 4th component for another attribute... } - if (has_vertex_attribute(vertex_attrib_flags, KRENGINE_ATTRIB_TEXUVA_SHORT)) { + if (has_vertex_attribute(vertex_attrib_flags, KRENGINE_ATTRIB_TEXCOORD0_SHORT)) { data_size += sizeof(short) * 2; } - if (has_vertex_attribute(vertex_attrib_flags, KRENGINE_ATTRIB_TEXUVB_SHORT)) { + if (has_vertex_attribute(vertex_attrib_flags, KRENGINE_ATTRIB_TEXCOORD1_SHORT)) { data_size += sizeof(short) * 2; } - if (has_vertex_attribute(vertex_attrib_flags, KRENGINE_ATTRIB_TEXUVC_SHORT)) { + if (has_vertex_attribute(vertex_attrib_flags, KRENGINE_ATTRIB_TEXCOORD2_SHORT)) { data_size += sizeof(short) * 2; } - if (has_vertex_attribute(vertex_attrib_flags, KRENGINE_ATTRIB_TEXUVD_SHORT)) { + if (has_vertex_attribute(vertex_attrib_flags, KRENGINE_ATTRIB_TEXCOORD3_SHORT)) { data_size += sizeof(short) * 2; } - if (has_vertex_attribute(vertex_attrib_flags, KRENGINE_ATTRIB_TEXUVE_SHORT)) { + if (has_vertex_attribute(vertex_attrib_flags, KRENGINE_ATTRIB_TEXCOORD4_SHORT)) { data_size += sizeof(short) * 2; } - if (has_vertex_attribute(vertex_attrib_flags, KRENGINE_ATTRIB_TEXUVF_SHORT)) { + if (has_vertex_attribute(vertex_attrib_flags, KRENGINE_ATTRIB_TEXCOORD5_SHORT)) { data_size += sizeof(short) * 2; } - if (has_vertex_attribute(vertex_attrib_flags, KRENGINE_ATTRIB_TEXUVG_SHORT)) { + if (has_vertex_attribute(vertex_attrib_flags, KRENGINE_ATTRIB_TEXCOORD6_SHORT)) { data_size += sizeof(short) * 2; } - if (has_vertex_attribute(vertex_attrib_flags, KRENGINE_ATTRIB_TEXUVH_SHORT)) { + if (has_vertex_attribute(vertex_attrib_flags, KRENGINE_ATTRIB_TEXCOORD7_SHORT)) { data_size += sizeof(short) * 2; } return data_size; @@ -1110,8 +1110,8 @@ VkFormat KRMesh::AttributeVulkanFormat(__int32_t vertex_attrib) case KRENGINE_ATTRIB_TANGENT: case KRENGINE_ATTRIB_BONEWEIGHTS: return VK_FORMAT_R32G32B32_SFLOAT; - case KRENGINE_ATTRIB_TEXUVA: - case KRENGINE_ATTRIB_TEXUVB: + case KRENGINE_ATTRIB_TEXCOORD0: + case KRENGINE_ATTRIB_TEXCOORD1: return VK_FORMAT_R32G32_SFLOAT; case KRENGINE_ATTRIB_BONEINDEXES: return VK_FORMAT_R8G8B8A8_UINT; @@ -1119,8 +1119,8 @@ VkFormat KRMesh::AttributeVulkanFormat(__int32_t vertex_attrib) case KRENGINE_ATTRIB_NORMAL_SHORT: case KRENGINE_ATTRIB_TANGENT_SHORT: return VK_FORMAT_R16G16B16A16_SNORM; - case KRENGINE_ATTRIB_TEXUVA_SHORT: - case KRENGINE_ATTRIB_TEXUVB_SHORT: + case KRENGINE_ATTRIB_TEXCOORD0_SHORT: + case KRENGINE_ATTRIB_TEXCOORD1_SHORT: return VK_FORMAT_R16G16_SNORM; } return VK_FORMAT_UNDEFINED; @@ -1379,9 +1379,9 @@ void KRMesh::convertToIndexed() for (int i = 0; i < vertex_count; i++) { Vector3 vertex_position = getVertexPosition(source_index); - Vector2 vertex_uv[8]; + Vector2 vertex_texcoord[8]; for (int set = 0; set < 8; set++) { - vertex_uv[set] = getVertexUV(set, source_index); + vertex_texcoord[set] = getVertexTexCoord(set, source_index); } Vector3 vertex_normal = getVertexNormal(source_index); Vector3 vertex_tangent = getVertexTangent(source_index); @@ -1411,46 +1411,7 @@ void KRMesh::convertToIndexed() szKey[m_vertex_size * 2] = '\0'; vertex_key_t vertex_key = szKey; - /* - - vertex_key_t vertex_key = std::make_pair(std::vector(), std::vector()); - - if(has_vertex_attribute(KRENGINE_ATTRIB_VERTEX) || has_vertex_attribute(KRENGINE_ATTRIB_VERTEX_SHORT)) { - vertex_key.first.push_back(vertex_position.x); - vertex_key.first.push_back(vertex_position.y); - vertex_key.first.push_back(vertex_position.z); - } - if(has_vertex_attribute(KRENGINE_ATTRIB_NORMAL) || has_vertex_attribute(KRENGINE_ATTRIB_NORMAL_SHORT)) { - vertex_key.first.push_back(vertex_normal.x); - vertex_key.first.push_back(vertex_normal.y); - vertex_key.first.push_back(vertex_normal.z); - } - if(has_vertex_attribute(KRENGINE_ATTRIB_TEXUVA) || has_vertex_attribute(KRENGINE_ATTRIB_TEXUVA_SHORT)) { - vertex_key.first.push_back(vertex_uva.x); - vertex_key.first.push_back(vertex_uva.y); - } - if(has_vertex_attribute(KRENGINE_ATTRIB_TEXUVB) || has_vertex_attribute(KRENGINE_ATTRIB_TEXUVB_SHORT)) { - vertex_key.first.push_back(vertex_uvb.x); - vertex_key.first.push_back(vertex_uvb.y); - } - if(has_vertex_attribute(KRENGINE_ATTRIB_TANGENT) || has_vertex_attribute(KRENGINE_ATTRIB_TANGENT_SHORT)) { - vertex_key.first.push_back(vertex_tangent.x); - vertex_key.first.push_back(vertex_tangent.y); - vertex_key.first.push_back(vertex_tangent.z); - } - if(has_vertex_attribute(KRENGINE_ATTRIB_BONEINDEXES)) { - vertex_key.second.push_back(vertex_bone_indexes[0]); - vertex_key.second.push_back(vertex_bone_indexes[1]); - vertex_key.second.push_back(vertex_bone_indexes[2]); - vertex_key.second.push_back(vertex_bone_indexes[3]); - } - if(has_vertex_attribute(KRENGINE_ATTRIB_BONEWEIGHTS)) { - vertex_key.first.push_back(vertex_bone_weights[0]); - vertex_key.first.push_back(vertex_bone_weights[1]); - vertex_key.first.push_back(vertex_bone_weights[2]); - vertex_key.first.push_back(vertex_bone_weights[3]); - } - */ + int found_index = -1; if (prev_indexes.count(vertex_key) == 0) { found_index = (int)mi.vertices.size() - vertex_index_base_start_vertex; @@ -1464,8 +1425,8 @@ void KRMesh::convertToIndexed() mi.tangents.push_back(vertex_tangent); } for (int set = 0; set < 8; set++) { - if (has_vertex_attribute((vertex_attrib_t)(KRENGINE_ATTRIB_TEXUVA + set)) || has_vertex_attribute((vertex_attrib_t)(KRENGINE_ATTRIB_TEXUVA_SHORT + set))) { - mi.uv[set].push_back(vertex_uv[set]); + if (has_vertex_attribute((vertex_attrib_t)(KRENGINE_ATTRIB_TEXCOORD0 + set)) || has_vertex_attribute((vertex_attrib_t)(KRENGINE_ATTRIB_TEXCOORD0_SHORT + set))) { + mi.texcoord[set].push_back(vertex_texcoord[set]); } } if (has_vertex_attribute(KRENGINE_ATTRIB_BONEINDEXES)) { diff --git a/kraken/resources/mesh/KRMesh.h b/kraken/resources/mesh/KRMesh.h index ea40243..31d7690 100755 --- a/kraken/resources/mesh/KRMesh.h +++ b/kraken/resources/mesh/KRMesh.h @@ -87,27 +87,27 @@ public: KRENGINE_ATTRIB_VERTEX = 0, KRENGINE_ATTRIB_NORMAL, KRENGINE_ATTRIB_TANGENT, - KRENGINE_ATTRIB_TEXUVA, - KRENGINE_ATTRIB_TEXUVB, - KRENGINE_ATTRIB_TEXUVC, - KRENGINE_ATTRIB_TEXUVD, - KRENGINE_ATTRIB_TEXUVE, - KRENGINE_ATTRIB_TEXUVF, - KRENGINE_ATTRIB_TEXUVG, - KRENGINE_ATTRIB_TEXUVH, + KRENGINE_ATTRIB_TEXCOORD0, + KRENGINE_ATTRIB_TEXCOORD1, + KRENGINE_ATTRIB_TEXCOORD2, + KRENGINE_ATTRIB_TEXCOORD3, + KRENGINE_ATTRIB_TEXCOORD4, + KRENGINE_ATTRIB_TEXCOORD5, + KRENGINE_ATTRIB_TEXCOORD6, + KRENGINE_ATTRIB_TEXCOORD7, KRENGINE_ATTRIB_BONEINDEXES, KRENGINE_ATTRIB_BONEWEIGHTS, KRENGINE_ATTRIB_VERTEX_SHORT, KRENGINE_ATTRIB_NORMAL_SHORT, KRENGINE_ATTRIB_TANGENT_SHORT, - KRENGINE_ATTRIB_TEXUVA_SHORT, - KRENGINE_ATTRIB_TEXUVB_SHORT, - KRENGINE_ATTRIB_TEXUVC_SHORT, - KRENGINE_ATTRIB_TEXUVD_SHORT, - KRENGINE_ATTRIB_TEXUVE_SHORT, - KRENGINE_ATTRIB_TEXUVF_SHORT, - KRENGINE_ATTRIB_TEXUVG_SHORT, - KRENGINE_ATTRIB_TEXUVH_SHORT, + KRENGINE_ATTRIB_TEXCOORD0_SHORT, + KRENGINE_ATTRIB_TEXCOORD1_SHORT, + KRENGINE_ATTRIB_TEXCOORD2_SHORT, + KRENGINE_ATTRIB_TEXCOORD3_SHORT, + KRENGINE_ATTRIB_TEXCOORD4_SHORT, + KRENGINE_ATTRIB_TEXCOORD5_SHORT, + KRENGINE_ATTRIB_TEXCOORD6_SHORT, + KRENGINE_ATTRIB_TEXCOORD7_SHORT, KRENGINE_NUM_ATTRIBUTES } vertex_attrib_t; @@ -117,7 +117,7 @@ public: std::vector vertices; std::vector<__uint16_t> vertex_indexes; std::vector > vertex_index_bases; - std::vector uv[8]; + std::vector texcoord[8]; std::vector normals; std::vector tangents; std::vector submesh_starts; @@ -215,14 +215,14 @@ public: hydra::Vector3 getVertexPosition(int index) const; hydra::Vector3 getVertexNormal(int index) const; hydra::Vector3 getVertexTangent(int index) const; - hydra::Vector2 getVertexUV(int set, int index) const; + hydra::Vector2 getVertexTexCoord(int set, int index) const; int getBoneIndex(int index, int weight_index) const; float getBoneWeight(int index, int weight_index) const; void setVertexPosition(int index, const hydra::Vector3& v); void setVertexNormal(int index, const hydra::Vector3& v); void setVertexTangent(int index, const hydra::Vector3& v); - void setVertexUV(int set, int index, const hydra::Vector2& v); + void setVertexTexCoord(int set, int index, const hydra::Vector2& v); void setBoneIndex(int index, int weight_index, int bone_index); void setBoneWeight(int index, int weight_index, float bone_weight); diff --git a/kraken/resources/mesh/KRMeshManager.cpp b/kraken/resources/mesh/KRMeshManager.cpp index 84aa7de..fec7607 100755 --- a/kraken/resources/mesh/KRMeshManager.cpp +++ b/kraken/resources/mesh/KRMeshManager.cpp @@ -98,7 +98,7 @@ void KRMeshManager::init() -1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f }; - KRENGINE_VBO_2D_SQUARE_ATTRIBS = (1 << KRMesh::KRENGINE_ATTRIB_VERTEX) | (1 << KRMesh::KRENGINE_ATTRIB_TEXUVA); + KRENGINE_VBO_2D_SQUARE_ATTRIBS = (1 << KRMesh::KRENGINE_ATTRIB_VERTEX) | (1 << KRMesh::KRENGINE_ATTRIB_TEXCOORD0); KRENGINE_VBO_2D_SQUARE_VERTICES.expand(sizeof(float) * 5 * 4); KRENGINE_VBO_2D_SQUARE_VERTICES.lock(); memcpy(KRENGINE_VBO_2D_SQUARE_VERTICES.getStart(), _KRENGINE_VBO_2D_SQUARE_VERTEX_DATA, sizeof(float) * 5 * 4); @@ -374,26 +374,26 @@ void KRMeshManager::initRandomParticles() vertex_data[iVertex].vertex.x = (float)(rand() % 2000) / 1000.0f - 1000.0f; vertex_data[iVertex].vertex.y = (float)(rand() % 2000) / 1000.0f - 1000.0f; vertex_data[iVertex].vertex.z = (float)(rand() % 2000) / 1000.0f - 1000.0f; - vertex_data[iVertex].uva.x = -0.5f; - vertex_data[iVertex].uva.y = -inscribed_circle_radius; + vertex_data[iVertex].texcoord0.x = -0.5f; + vertex_data[iVertex].texcoord0.y = -inscribed_circle_radius; iVertex++; vertex_data[iVertex].vertex.x = vertex_data[iVertex - 1].vertex.x; vertex_data[iVertex].vertex.y = vertex_data[iVertex - 1].vertex.y; vertex_data[iVertex].vertex.z = vertex_data[iVertex - 1].vertex.z; - vertex_data[iVertex].uva.x = 0.5f; - vertex_data[iVertex].uva.y = -inscribed_circle_radius; + vertex_data[iVertex].texcoord0.x = 0.5f; + vertex_data[iVertex].texcoord0.y = -inscribed_circle_radius; iVertex++; vertex_data[iVertex].vertex.x = vertex_data[iVertex - 1].vertex.x; vertex_data[iVertex].vertex.y = vertex_data[iVertex - 1].vertex.y; vertex_data[iVertex].vertex.z = vertex_data[iVertex - 1].vertex.z; - vertex_data[iVertex].uva.x = 0.0f; - vertex_data[iVertex].uva.y = -inscribed_circle_radius + equilateral_triangle_height; + vertex_data[iVertex].texcoord0.x = 0.0f; + vertex_data[iVertex].texcoord0.y = -inscribed_circle_radius + equilateral_triangle_height; iVertex++; } - KRENGINE_VBO_DATA_RANDOM_PARTICLES.init(this, &m_randomParticleVertexData, nullptr, (1 << KRMesh::KRENGINE_ATTRIB_VERTEX) | (1 << KRMesh::KRENGINE_ATTRIB_TEXUVA), false, KRVBOData::CONSTANT + KRENGINE_VBO_DATA_RANDOM_PARTICLES.init(this, &m_randomParticleVertexData, nullptr, (1 << KRMesh::KRENGINE_ATTRIB_VERTEX) | (1 << KRMesh::KRENGINE_ATTRIB_TEXCOORD0), false, KRVBOData::CONSTANT #if KRENGINE_DEBUG_GPU_LABELS , "Random Particles [built-in]" #endif diff --git a/kraken/resources/mesh/KRMeshManager.h b/kraken/resources/mesh/KRMeshManager.h index cf01dec..d5c65be 100755 --- a/kraken/resources/mesh/KRMeshManager.h +++ b/kraken/resources/mesh/KRMeshManager.h @@ -177,7 +177,7 @@ public: typedef struct { hydra::Vector3 vertex; - hydra::Vector2 uva; + hydra::Vector2 texcoord0; } RandomParticleVertexData; typedef struct diff --git a/kraken/resources/mesh/KRMeshQuad.cpp b/kraken/resources/mesh/KRMeshQuad.cpp index ad5b60f..38f81e0 100755 --- a/kraken/resources/mesh/KRMeshQuad.cpp +++ b/kraken/resources/mesh/KRMeshQuad.cpp @@ -44,10 +44,10 @@ KRMeshQuad::KRMeshQuad(KRContext& context) : KRMesh(context, "__quad") mi.vertices.push_back(Vector3::Create(-1.0f, 1.0f, 0.0f)); mi.vertices.push_back(Vector3::Create(1.0f, 1.0f, 0.0f)); - mi.uv[0].push_back(Vector2::Create(0.0f, 0.0f)); - mi.uv[0].push_back(Vector2::Create(1.0f, 0.0f)); - mi.uv[0].push_back(Vector2::Create(0.0f, 1.0f)); - mi.uv[0].push_back(Vector2::Create(1.0f, 1.0f)); + mi.texcoord[0].push_back(Vector2::Create(0.0f, 0.0f)); + mi.texcoord[0].push_back(Vector2::Create(1.0f, 0.0f)); + mi.texcoord[0].push_back(Vector2::Create(0.0f, 1.0f)); + mi.texcoord[0].push_back(Vector2::Create(1.0f, 1.0f)); mi.submesh_starts.push_back(0);