Add support for 8 vertex colors. Set up binding for all 8 texcoords.
Some checks failed
CMake on multiple platforms / build (Release, cl, cl, windows-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, clang, clang++, macos-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, clang, clang++, ubuntu-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, gcc, g++, ubuntu-latest) (push) Has been cancelled

This commit is contained in:
2026-06-03 22:44:34 -07:00
parent dbc21d5a5b
commit 8ae009cf92
11 changed files with 157 additions and 45 deletions

View File

@@ -77,6 +77,14 @@ KRPipeline::KRPipeline(KRContext& context, KrDeviceHandle deviceHandle, const KR
KRMesh::KRENGINE_ATTRIB_VERTEX, KRMesh::KRENGINE_ATTRIB_VERTEX,
KRMesh::KRENGINE_ATTRIB_NORMAL, KRMesh::KRENGINE_ATTRIB_NORMAL,
KRMesh::KRENGINE_ATTRIB_TANGENT, KRMesh::KRENGINE_ATTRIB_TANGENT,
KRMesh::KRENGINE_ATTRIB_COLOR0,
KRMesh::KRENGINE_ATTRIB_COLOR1,
KRMesh::KRENGINE_ATTRIB_COLOR2,
KRMesh::KRENGINE_ATTRIB_COLOR3,
KRMesh::KRENGINE_ATTRIB_COLOR4,
KRMesh::KRENGINE_ATTRIB_COLOR5,
KRMesh::KRENGINE_ATTRIB_COLOR6,
KRMesh::KRENGINE_ATTRIB_COLOR7,
KRMesh::KRENGINE_ATTRIB_TEXCOORD0, KRMesh::KRENGINE_ATTRIB_TEXCOORD0,
KRMesh::KRENGINE_ATTRIB_TEXCOORD1, KRMesh::KRENGINE_ATTRIB_TEXCOORD1,
KRMesh::KRENGINE_ATTRIB_TEXCOORD2, KRMesh::KRENGINE_ATTRIB_TEXCOORD2,
@@ -142,10 +150,38 @@ KRPipeline::KRPipeline(KRContext& context, KrDeviceHandle deviceHandle, const KR
attribute_locations[KRMesh::KRENGINE_ATTRIB_NORMAL] = input_var.location + 1; attribute_locations[KRMesh::KRENGINE_ATTRIB_NORMAL] = input_var.location + 1;
} else if (strcmp(input_var.name, "vertex_tangent") == 0) { } else if (strcmp(input_var.name, "vertex_tangent") == 0) {
attribute_locations[KRMesh::KRENGINE_ATTRIB_TANGENT] = input_var.location + 1; attribute_locations[KRMesh::KRENGINE_ATTRIB_TANGENT] = input_var.location + 1;
} else if (strcmp(input_var.name, "vertex_uv") == 0) { } else if (strcmp(input_var.name, "vertex_texcoord0") == 0) {
attribute_locations[KRMesh::KRENGINE_ATTRIB_TEXCOORD0] = input_var.location + 1; attribute_locations[KRMesh::KRENGINE_ATTRIB_TEXCOORD0] = input_var.location + 1;
} else if (strcmp(input_var.name, "vertex_lightmap_uv") == 0) { } else if (strcmp(input_var.name, "vertex_texcoord1") == 0) {
attribute_locations[KRMesh::KRENGINE_ATTRIB_TEXCOORD1] = input_var.location + 1; attribute_locations[KRMesh::KRENGINE_ATTRIB_TEXCOORD1] = input_var.location + 1;
} else if (strcmp(input_var.name, "vertex_texcoord2") == 0) {
attribute_locations[KRMesh::KRENGINE_ATTRIB_TEXCOORD2] = input_var.location + 1;
} else if (strcmp(input_var.name, "vertex_texcoord3") == 0) {
attribute_locations[KRMesh::KRENGINE_ATTRIB_TEXCOORD3] = input_var.location + 1;
} else if (strcmp(input_var.name, "vertex_texcoord4") == 0) {
attribute_locations[KRMesh::KRENGINE_ATTRIB_TEXCOORD4] = input_var.location + 1;
} else if (strcmp(input_var.name, "vertex_texcoord5") == 0) {
attribute_locations[KRMesh::KRENGINE_ATTRIB_TEXCOORD5] = input_var.location + 1;
} else if (strcmp(input_var.name, "vertex_texcoord6") == 0) {
attribute_locations[KRMesh::KRENGINE_ATTRIB_TEXCOORD6] = input_var.location + 1;
} else if (strcmp(input_var.name, "vertex_texcoord7") == 0) {
attribute_locations[KRMesh::KRENGINE_ATTRIB_TEXCOORD7] = input_var.location + 1;
} else if (strcmp(input_var.name, "vertex_color0") == 0) {
attribute_locations[KRMesh::KRENGINE_ATTRIB_COLOR0] = input_var.location + 1;
} else if (strcmp(input_var.name, "vertex_color1") == 0) {
attribute_locations[KRMesh::KRENGINE_ATTRIB_COLOR1] = input_var.location + 1;
} else if (strcmp(input_var.name, "vertex_color2") == 0) {
attribute_locations[KRMesh::KRENGINE_ATTRIB_COLOR2] = input_var.location + 1;
} else if (strcmp(input_var.name, "vertex_color3") == 0) {
attribute_locations[KRMesh::KRENGINE_ATTRIB_COLOR3] = input_var.location + 1;
} else if (strcmp(input_var.name, "vertex_color4") == 0) {
attribute_locations[KRMesh::KRENGINE_ATTRIB_COLOR4] = input_var.location + 1;
} else if (strcmp(input_var.name, "vertex_color5") == 0) {
attribute_locations[KRMesh::KRENGINE_ATTRIB_COLOR5] = input_var.location + 1;
} else if (strcmp(input_var.name, "vertex_color6") == 0) {
attribute_locations[KRMesh::KRENGINE_ATTRIB_COLOR6] = input_var.location + 1;
} else if (strcmp(input_var.name, "vertex_color7") == 0) {
attribute_locations[KRMesh::KRENGINE_ATTRIB_COLOR7] = input_var.location + 1;
} else if (strcmp(input_var.name, "bone_indexes") == 0) { } else if (strcmp(input_var.name, "bone_indexes") == 0) {
attribute_locations[KRMesh::KRENGINE_ATTRIB_BONEINDEXES] = input_var.location + 1; attribute_locations[KRMesh::KRENGINE_ATTRIB_BONEINDEXES] = input_var.location + 1;
} else if (strcmp(input_var.name, "bone_weights") == 0) { } else if (strcmp(input_var.name, "bone_weights") == 0) {

View File

@@ -547,15 +547,6 @@ void KRMesh::LoadData(const KRMesh::mesh_info& mi, bool calculate_normals, bool
} }
} }
} }
if (use_short_texcoord[set]) {
for (std::vector<Vector2>::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_texcoord[set] = false;
break;
}
}
}
} }
__int32_t vertex_attrib_flags = 0; __int32_t vertex_attrib_flags = 0;
@@ -568,38 +559,36 @@ void KRMesh::LoadData(const KRMesh::mesh_info& mi, bool calculate_normals, bool
} }
if (mi.normals.size() || calculate_normals) { if (mi.normals.size() || calculate_normals) {
if (use_short_normals) { if (use_short_normals) {
vertex_attrib_flags += (1 << KRENGINE_ATTRIB_NORMAL_SHORT); vertex_attrib_flags |= (1 << KRENGINE_ATTRIB_NORMAL_SHORT);
} else { } else {
vertex_attrib_flags += (1 << KRENGINE_ATTRIB_NORMAL); vertex_attrib_flags |= (1 << KRENGINE_ATTRIB_NORMAL);
} }
} }
if (mi.tangents.size() || calculate_tangents) { if (mi.tangents.size() || calculate_tangents) {
if (use_short_tangents) { if (use_short_tangents) {
vertex_attrib_flags += (1 << KRENGINE_ATTRIB_TANGENT_SHORT); vertex_attrib_flags |= (1 << KRENGINE_ATTRIB_TANGENT_SHORT);
} else { } else {
vertex_attrib_flags += (1 << KRENGINE_ATTRIB_TANGENT); vertex_attrib_flags |= (1 << KRENGINE_ATTRIB_TANGENT);
} }
} }
for (int set = 0; set < 8; set++) { for (int set = 0; set < 8; set++) {
if (mi.texcoord[set].size()) { if (mi.texcoord[set].size()) {
if (use_short_texcoord[set]) { if (use_short_texcoord[set]) {
vertex_attrib_flags += (1 << (KRENGINE_ATTRIB_TEXCOORD0_SHORT + set)); vertex_attrib_flags |= (1 << (KRENGINE_ATTRIB_TEXCOORD0_SHORT + set));
} else { } else {
vertex_attrib_flags += (1 << (KRENGINE_ATTRIB_TEXCOORD0 + set)); vertex_attrib_flags |= (1 << (KRENGINE_ATTRIB_TEXCOORD0 + set));
} }
} }
if (mi.texcoord[set].size()) {
if (use_short_texcoord[set]) { if (mi.color[set].size()) {
vertex_attrib_flags += (1 << (KRENGINE_ATTRIB_TEXCOORD1_SHORT + set)); vertex_attrib_flags |= (1 << (KRENGINE_ATTRIB_COLOR0 + set));
} else {
vertex_attrib_flags += (1 << (KRENGINE_ATTRIB_TEXCOORD1 + set));
}
} }
} }
if (mi.bone_names.size()) { if (mi.bone_names.size()) {
vertex_attrib_flags += (1 << KRENGINE_ATTRIB_BONEINDEXES) + (1 << KRENGINE_ATTRIB_BONEWEIGHTS); vertex_attrib_flags += (1 << KRENGINE_ATTRIB_BONEINDEXES) + (1 << KRENGINE_ATTRIB_BONEWEIGHTS);
} }
size_t vertex_size = VertexSizeForAttributes(vertex_attrib_flags); size_t vertex_size = VertexSizeForAttributes(vertex_attrib_flags);
size_t index_count = mi.vertex_indexes.size(); size_t index_count = mi.vertex_indexes.size();
size_t index_base_count = mi.vertex_index_bases.size(); size_t index_base_count = mi.vertex_index_bases.size();
size_t submesh_count = mi.submesh_lengths.size(); size_t submesh_count = mi.submesh_lengths.size();
@@ -662,6 +651,10 @@ void KRMesh::LoadData(const KRMesh::mesh_info& mi, bool calculate_normals, bool
if ((int)mi.texcoord[set].size() > iVertex) { if ((int)mi.texcoord[set].size() > iVertex) {
setVertexTexCoord(set, iVertex, mi.texcoord[set][iVertex]); setVertexTexCoord(set, iVertex, mi.texcoord[set][iVertex]);
} }
if ((int)mi.color[set].size() > iVertex) {
setVertexColor(set, iVertex, mi.color[set][iVertex]);
}
} }
if ((int)mi.normals.size() > iVertex) { if ((int)mi.normals.size() > iVertex) {
setVertexNormal(iVertex, Vector3::Normalize(mi.normals[iVertex])); setVertexNormal(iVertex, Vector3::Normalize(mi.normals[iVertex]));
@@ -907,7 +900,7 @@ Vector2 KRMesh::getVertexTexCoord(int set, int index) const
{ {
if (has_vertex_attribute((vertex_attrib_t)(KRENGINE_ATTRIB_TEXCOORD0_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]); 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); return Vector2::Create((float)v[0] / 32767.0f);
} else if (has_vertex_attribute((vertex_attrib_t)(KRENGINE_ATTRIB_TEXCOORD0 + 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])); return Vector2::Create((float*)(getVertexData(index) + m_vertex_attribute_offset[KRENGINE_ATTRIB_TEXCOORD0 + set]));
} else { } else {
@@ -915,6 +908,16 @@ Vector2 KRMesh::getVertexTexCoord(int set, int index) const
} }
} }
Vector4 KRMesh::getVertexColor(int set, int index) const
{
if (has_vertex_attribute((vertex_attrib_t)(KRENGINE_ATTRIB_COLOR0 + set))) {
uint8_t* v = (uint8_t*)(getVertexData(index) + m_vertex_attribute_offset[KRENGINE_ATTRIB_COLOR0 + set]);
return Vector4::Create((float)v[0] / 255.0f, (float)v[1] / 255.0f, (float)v[2] / 255.0f, (float)v[3] / 255.0f);
} else {
return Vector4::Zero();
}
}
void KRMesh::setVertexPosition(int index, const Vector3& v) void KRMesh::setVertexPosition(int index, const Vector3& v)
{ {
if (has_vertex_attribute(KRENGINE_ATTRIB_VERTEX_SHORT)) { if (has_vertex_attribute(KRENGINE_ATTRIB_VERTEX_SHORT)) {
@@ -974,6 +977,17 @@ void KRMesh::setVertexTexCoord(int set, int index, const Vector2& v)
} }
} }
void KRMesh::setVertexColor(int set, int index, const Vector4& v)
{
if (has_vertex_attribute((vertex_attrib_t)(KRENGINE_ATTRIB_COLOR0 + set))) {
uint8_t* vert = (uint8_t*)(getVertexData(index) + m_vertex_attribute_offset[KRENGINE_ATTRIB_COLOR0 + set]);
vert[0] = (uint8_t)(v.x * 255.0f);
vert[1] = (uint8_t)(v.y * 255.0f);
vert[2] = (uint8_t)(v.z * 255.0f);
vert[3] = (uint8_t)(v.w * 255.0f);
}
}
int KRMesh::getBoneIndex(int index, int weight_index) const int KRMesh::getBoneIndex(int index, int weight_index) const
{ {
unsigned char* vert = (unsigned char*)(getVertexData(index) + m_vertex_attribute_offset[KRENGINE_ATTRIB_BONEINDEXES]); unsigned char* vert = (unsigned char*)(getVertexData(index) + m_vertex_attribute_offset[KRENGINE_ATTRIB_BONEINDEXES]);
@@ -1010,6 +1024,30 @@ size_t KRMesh::VertexSizeForAttributes(__int32_t vertex_attrib_flags)
if (has_vertex_attribute(vertex_attrib_flags, KRENGINE_ATTRIB_TANGENT)) { if (has_vertex_attribute(vertex_attrib_flags, KRENGINE_ATTRIB_TANGENT)) {
data_size += sizeof(float) * 3; data_size += sizeof(float) * 3;
} }
if (has_vertex_attribute(vertex_attrib_flags, KRENGINE_ATTRIB_COLOR0)) {
data_size += 4;
}
if (has_vertex_attribute(vertex_attrib_flags, KRENGINE_ATTRIB_COLOR1)) {
data_size += 4;
}
if (has_vertex_attribute(vertex_attrib_flags, KRENGINE_ATTRIB_COLOR2)) {
data_size += 4;
}
if (has_vertex_attribute(vertex_attrib_flags, KRENGINE_ATTRIB_COLOR3)) {
data_size += 4;
}
if (has_vertex_attribute(vertex_attrib_flags, KRENGINE_ATTRIB_COLOR4)) {
data_size += 4;
}
if (has_vertex_attribute(vertex_attrib_flags, KRENGINE_ATTRIB_COLOR5)) {
data_size += 4;
}
if (has_vertex_attribute(vertex_attrib_flags, KRENGINE_ATTRIB_COLOR6)) {
data_size += 4;
}
if (has_vertex_attribute(vertex_attrib_flags, KRENGINE_ATTRIB_COLOR7)) {
data_size += 4;
}
if (has_vertex_attribute(vertex_attrib_flags, KRENGINE_ATTRIB_TEXCOORD0)) { if (has_vertex_attribute(vertex_attrib_flags, KRENGINE_ATTRIB_TEXCOORD0)) {
data_size += sizeof(float) * 2; data_size += sizeof(float) * 2;
} }
@@ -1110,8 +1148,23 @@ VkFormat KRMesh::AttributeVulkanFormat(__int32_t vertex_attrib)
case KRENGINE_ATTRIB_TANGENT: case KRENGINE_ATTRIB_TANGENT:
case KRENGINE_ATTRIB_BONEWEIGHTS: case KRENGINE_ATTRIB_BONEWEIGHTS:
return VK_FORMAT_R32G32B32_SFLOAT; return VK_FORMAT_R32G32B32_SFLOAT;
case KRENGINE_ATTRIB_COLOR0:
case KRENGINE_ATTRIB_COLOR1:
case KRENGINE_ATTRIB_COLOR2:
case KRENGINE_ATTRIB_COLOR3:
case KRENGINE_ATTRIB_COLOR4:
case KRENGINE_ATTRIB_COLOR5:
case KRENGINE_ATTRIB_COLOR6:
case KRENGINE_ATTRIB_COLOR7:
return VK_FORMAT_R8G8B8A8_UNORM;
case KRENGINE_ATTRIB_TEXCOORD0: case KRENGINE_ATTRIB_TEXCOORD0:
case KRENGINE_ATTRIB_TEXCOORD1: case KRENGINE_ATTRIB_TEXCOORD1:
case KRENGINE_ATTRIB_TEXCOORD2:
case KRENGINE_ATTRIB_TEXCOORD3:
case KRENGINE_ATTRIB_TEXCOORD4:
case KRENGINE_ATTRIB_TEXCOORD5:
case KRENGINE_ATTRIB_TEXCOORD6:
case KRENGINE_ATTRIB_TEXCOORD7:
return VK_FORMAT_R32G32_SFLOAT; return VK_FORMAT_R32G32_SFLOAT;
case KRENGINE_ATTRIB_BONEINDEXES: case KRENGINE_ATTRIB_BONEINDEXES:
return VK_FORMAT_R8G8B8A8_UINT; return VK_FORMAT_R8G8B8A8_UINT;
@@ -1121,6 +1174,12 @@ VkFormat KRMesh::AttributeVulkanFormat(__int32_t vertex_attrib)
return VK_FORMAT_R16G16B16A16_SNORM; return VK_FORMAT_R16G16B16A16_SNORM;
case KRENGINE_ATTRIB_TEXCOORD0_SHORT: case KRENGINE_ATTRIB_TEXCOORD0_SHORT:
case KRENGINE_ATTRIB_TEXCOORD1_SHORT: case KRENGINE_ATTRIB_TEXCOORD1_SHORT:
case KRENGINE_ATTRIB_TEXCOORD2_SHORT:
case KRENGINE_ATTRIB_TEXCOORD3_SHORT:
case KRENGINE_ATTRIB_TEXCOORD4_SHORT:
case KRENGINE_ATTRIB_TEXCOORD5_SHORT:
case KRENGINE_ATTRIB_TEXCOORD6_SHORT:
case KRENGINE_ATTRIB_TEXCOORD7_SHORT:
return VK_FORMAT_R16G16_SNORM; return VK_FORMAT_R16G16_SNORM;
} }
return VK_FORMAT_UNDEFINED; return VK_FORMAT_UNDEFINED;
@@ -1380,8 +1439,10 @@ void KRMesh::convertToIndexed()
Vector3 vertex_position = getVertexPosition(source_index); Vector3 vertex_position = getVertexPosition(source_index);
Vector2 vertex_texcoord[8]; Vector2 vertex_texcoord[8];
Vector4 vertex_color[8];
for (int set = 0; set < 8; set++) { for (int set = 0; set < 8; set++) {
vertex_texcoord[set] = getVertexTexCoord(set, source_index); vertex_texcoord[set] = getVertexTexCoord(set, source_index);
vertex_color[set] = getVertexColor(set, source_index);
} }
Vector3 vertex_normal = getVertexNormal(source_index); Vector3 vertex_normal = getVertexNormal(source_index);
Vector3 vertex_tangent = getVertexTangent(source_index); Vector3 vertex_tangent = getVertexTangent(source_index);
@@ -1428,6 +1489,10 @@ void KRMesh::convertToIndexed()
if (has_vertex_attribute((vertex_attrib_t)(KRENGINE_ATTRIB_TEXCOORD0 + set)) || has_vertex_attribute((vertex_attrib_t)(KRENGINE_ATTRIB_TEXCOORD0_SHORT + 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]); mi.texcoord[set].push_back(vertex_texcoord[set]);
} }
if (has_vertex_attribute((vertex_attrib_t)(KRENGINE_ATTRIB_COLOR0 + set))) {
mi.color[set].push_back(vertex_color[set]);
}
} }
if (has_vertex_attribute(KRENGINE_ATTRIB_BONEINDEXES)) { if (has_vertex_attribute(KRENGINE_ATTRIB_BONEINDEXES)) {
mi.bone_indexes.push_back(vertex_bone_indexes); mi.bone_indexes.push_back(vertex_bone_indexes);

View File

@@ -87,6 +87,14 @@ public:
KRENGINE_ATTRIB_VERTEX = 0, KRENGINE_ATTRIB_VERTEX = 0,
KRENGINE_ATTRIB_NORMAL, KRENGINE_ATTRIB_NORMAL,
KRENGINE_ATTRIB_TANGENT, KRENGINE_ATTRIB_TANGENT,
KRENGINE_ATTRIB_COLOR0,
KRENGINE_ATTRIB_COLOR1,
KRENGINE_ATTRIB_COLOR2,
KRENGINE_ATTRIB_COLOR3,
KRENGINE_ATTRIB_COLOR4,
KRENGINE_ATTRIB_COLOR5,
KRENGINE_ATTRIB_COLOR6,
KRENGINE_ATTRIB_COLOR7,
KRENGINE_ATTRIB_TEXCOORD0, KRENGINE_ATTRIB_TEXCOORD0,
KRENGINE_ATTRIB_TEXCOORD1, KRENGINE_ATTRIB_TEXCOORD1,
KRENGINE_ATTRIB_TEXCOORD2, KRENGINE_ATTRIB_TEXCOORD2,
@@ -118,6 +126,7 @@ public:
std::vector<__uint16_t> vertex_indexes; std::vector<__uint16_t> vertex_indexes;
std::vector<std::pair<int, int> > vertex_index_bases; std::vector<std::pair<int, int> > vertex_index_bases;
std::vector<hydra::Vector2> texcoord[8]; std::vector<hydra::Vector2> texcoord[8];
std::vector<hydra::Vector4> color[8];
std::vector<hydra::Vector3> normals; std::vector<hydra::Vector3> normals;
std::vector<hydra::Vector3> tangents; std::vector<hydra::Vector3> tangents;
std::vector<int> submesh_starts; std::vector<int> submesh_starts;
@@ -216,6 +225,7 @@ public:
hydra::Vector3 getVertexNormal(int index) const; hydra::Vector3 getVertexNormal(int index) const;
hydra::Vector3 getVertexTangent(int index) const; hydra::Vector3 getVertexTangent(int index) const;
hydra::Vector2 getVertexTexCoord(int set, int index) const; hydra::Vector2 getVertexTexCoord(int set, int index) const;
hydra::Vector4 getVertexColor(int set, int index) const;
int getBoneIndex(int index, int weight_index) const; int getBoneIndex(int index, int weight_index) const;
float getBoneWeight(int index, int weight_index) const; float getBoneWeight(int index, int weight_index) const;
@@ -223,6 +233,7 @@ public:
void setVertexNormal(int index, const hydra::Vector3& v); void setVertexNormal(int index, const hydra::Vector3& v);
void setVertexTangent(int index, const hydra::Vector3& v); void setVertexTangent(int index, const hydra::Vector3& v);
void setVertexTexCoord(int set, int index, const hydra::Vector2& v); void setVertexTexCoord(int set, int index, const hydra::Vector2& v);
void setVertexColor(int set, int index, const hydra::Vector4& v);
void setBoneIndex(int index, int weight_index, int bone_index); void setBoneIndex(int index, int weight_index, int bone_index);
void setBoneWeight(int index, int weight_index, float bone_weight); void setBoneWeight(int index, int weight_index, float bone_weight);

View File

@@ -46,7 +46,7 @@ void main()
gl_Position.z += SHADOW_BIAS; gl_Position.z += SHADOW_BIAS;
/* /*
// Pass UV co-ordinates // Pass UV co-ordinates
texCoord = vertex_uv.st; texCoord = vertex_texcoord0.st;
*/ */
} }

View File

@@ -33,12 +33,12 @@
layout(location = 0) out mediump vec2 textureCoordinate; layout(location = 0) out mediump vec2 textureCoordinate;
layout(location = 0) in vec3 vertex_position; layout(location = 0) in vec3 vertex_position;
layout(location = 1) in lowp vec2 vertex_uv; layout(location = 1) in lowp vec2 vertex_texcoord0;
void main() void main()
{ {
gl_Position = vec4(vertex_position, 1.0); gl_Position = vec4(vertex_position, 1.0);
textureCoordinate = vertex_uv; textureCoordinate = vertex_texcoord0;
} }

View File

@@ -30,7 +30,7 @@
// //
in mediump vec2 vertex_uv; in mediump vec2 vertex_texcoord0;
uniform highp mat4 mvp_matrix; // mvp_matrix is the result of multiplying the model, view, and projection matrices uniform highp mat4 mvp_matrix; // mvp_matrix is the result of multiplying the model, view, and projection matrices
uniform mediump vec4 viewport; uniform mediump vec4 viewport;
uniform mediump float flare_size; uniform mediump float flare_size;
@@ -49,8 +49,8 @@ void main() {
offset_center.xyz += vec3(sin((time_absolute + vertex_position.x * 100.0) * 0.05), sin((time_absolute + vertex_position.y * 100.0) * 0.07), sin((time_absolute + vertex_position.z * 100.0) * 0.03)) * 0.05; offset_center.xyz += vec3(sin((time_absolute + vertex_position.x * 100.0) * 0.05), sin((time_absolute + vertex_position.y * 100.0) * 0.07), sin((time_absolute + vertex_position.z * 100.0) * 0.03)) * 0.05;
offset_center = vec4(mod(offset_center.x + 1.0, 2.0) - 1.0, mod(offset_center.y + 1.0, 2.0) - 1.0, mod(offset_center.z + 1.0, 2.0) - 1.0, 1.0); offset_center = vec4(mod(offset_center.x + 1.0, 2.0) - 1.0, mod(offset_center.y + 1.0, 2.0) - 1.0, mod(offset_center.z + 1.0, 2.0) - 1.0, 1.0);
highp vec4 particle_center = mvp_matrix * offset_center; highp vec4 particle_center = mvp_matrix * offset_center;
texCoord = vertex_uv * 3.46410161513775; // 3.46410161513775 = 2 * sqrt(3); 1 / (2 * sqrt(3)) is the radius of a circle encompased by a equilateral triangle with a side length of 1. texCoord = vertex_texcoord0 * 3.46410161513775; // 3.46410161513775 = 2 * sqrt(3); 1 / (2 * sqrt(3)) is the radius of a circle encompased by a equilateral triangle with a side length of 1.
gl_Position = particle_center + vec4(vertex_uv.x * viewport.w / viewport.z * 2.0 - 1.0, vertex_uv.y * 2.0 - 1.0, 0.0, 0.0) * flare_size; gl_Position = particle_center + vec4(vertex_texcoord0.x * viewport.w / viewport.z * 2.0 - 1.0, vertex_texcoord0.y * 2.0 - 1.0, 0.0, 0.0) * flare_size;
shadowMapCoord1 = shadow_mvp1 * offset_center; shadowMapCoord1 = shadow_mvp1 * offset_center;

View File

@@ -30,7 +30,7 @@
// //
in vec2 vertex_uv; in vec2 vertex_texcoord0;
uniform mat4 mvp_matrix; // mvp_matrix is the result of multiplying the model, view, and projection matrices uniform mat4 mvp_matrix; // mvp_matrix is the result of multiplying the model, view, and projection matrices
uniform vec4 viewport; uniform vec4 viewport;
uniform float flare_size; uniform float flare_size;
@@ -38,6 +38,6 @@ uniform float flare_size;
out vec2 texCoord; out vec2 texCoord;
void main() { void main() {
texCoord = vertex_uv; texCoord = vertex_texcoord0;
gl_Position = mvp_matrix * vec4(0.0, 0.0, 0.0, 1.0) + vec4(vertex_uv.x * viewport.w / viewport.z * 2.0 - 1.0, vertex_uv.y * 2.0 - 1.0, 0.0, 0.0) * flare_size; gl_Position = mvp_matrix * vec4(0.0, 0.0, 0.0, 1.0) + vec4(vertex_texcoord0.x * viewport.w / viewport.z * 2.0 - 1.0, vertex_texcoord0.y * 2.0 - 1.0, 0.0, 0.0) * flare_size;
} }

View File

@@ -42,10 +42,10 @@ layout(location = 1) in vec3 vertex_normal;
#if HAS_NORMAL_MAP == 1 #if HAS_NORMAL_MAP == 1
layout(location = 2) in vec3 vertex_tangent; layout(location = 2) in vec3 vertex_tangent;
#endif #endif
layout(location = 3) in lowp vec3 vertex_uv; layout(location = 3) in lowp vec3 vertex_texcoord0;
#if BONE_COUNT > 0 #if BONE_COUNT > 0
layout(location = 4) in lowp vec3 vertex_uv; layout(location = 4) in lowp vec3 vertex_texcoord0;
layout(location = 5) in highp vec4 bone_weights; layout(location = 5) in highp vec4 bone_weights;
layout(location = 6) in highp vec4 bone_indexes; layout(location = 6) in highp vec4 bone_indexes;
#else #else
@@ -60,7 +60,7 @@ layout(location = 3) in lowp vec3 vertex_uv;
#endif #endif
#else #else
#if HAS_LIGHT_MAP == 1 #if HAS_LIGHT_MAP == 1
layout(loction = 7) in mediump vec2 vertex_lightmap_uv; layout(loction = 7) in mediump vec2 vertex_texcoord1;
#endif //HAS_LIGHT_MAP #endif //HAS_LIGHT_MAP
#endif // GBUFFER_PASS #endif // GBUFFER_PASS
@@ -357,7 +357,7 @@ void main()
#if HAS_DIFFUSE_MAP == 1 || (HAS_NORMAL_MAP == 1 && ENABLE_PER_PIXEL == 1) || (HAS_SPEC_MAP == 1 && ENABLE_PER_PIXEL == 1) || (HAS_REFLECTION_MAP == 1 && ENABLE_PER_PIXEL == 1) #if HAS_DIFFUSE_MAP == 1 || (HAS_NORMAL_MAP == 1 && ENABLE_PER_PIXEL == 1) || (HAS_SPEC_MAP == 1 && ENABLE_PER_PIXEL == 1) || (HAS_REFLECTION_MAP == 1 && ENABLE_PER_PIXEL == 1)
// Pass UV co-ordinates // Pass UV co-ordinates
texCoord = vertex_uv.st; texCoord = vertex_texcoord0.st;
#endif #endif
@@ -421,7 +421,7 @@ void main()
#if HAS_LIGHT_MAP == 1 #if HAS_LIGHT_MAP == 1
// Pass shadow UV co-ordinates // Pass shadow UV co-ordinates
lightmap_uv = vertex_lightmap_uv.st; lightmap_uv = vertex_texcoord1.st;
#endif #endif

View File

@@ -30,12 +30,12 @@
// //
in vec4 vertex_position; in vec4 vertex_position;
in vec4 vertex_uv; in vec4 vertex_texcoord0;
out vec2 textureCoordinate; out vec2 textureCoordinate;
void main() void main()
{ {
gl_Position = vertex_position; gl_Position = vertex_position;
textureCoordinate = vertex_uv.xy; textureCoordinate = vertex_texcoord0.xy;
} }

View File

@@ -38,10 +38,10 @@ layout (std140, binding = 0) uniform buf {
mat4 mvp_matrix; // mvp_matrix is the result of multiplying the model, view, and projection matrices mat4 mvp_matrix; // mvp_matrix is the result of multiplying the model, view, and projection matrices
} ubuf; } ubuf;
layout (location = 0) in vec4 vertex_position; layout (location = 0) in vec4 vertex_position;
layout (location = 1) in vec2 vertex_uv; layout (location = 1) in vec2 vertex_texcoord0;
layout (location = 0) out vec2 textureCoordinate; layout (location = 0) out vec2 textureCoordinate;
void main() { void main() {
textureCoordinate = vertex_uv; textureCoordinate = vertex_texcoord0;
gl_Position = ubuf.mvp_matrix * vertex_position; gl_Position = ubuf.mvp_matrix * vertex_position;
} }

View File

@@ -38,10 +38,10 @@ layout (std140, binding = 0) uniform buf {
mat4 mvp_matrix; // mvp_matrix is the result of multiplying the model, view, and projection matrices mat4 mvp_matrix; // mvp_matrix is the result of multiplying the model, view, and projection matrices
vec4 viewport; vec4 viewport;
} ubuf; } ubuf;
layout (location = 0) in vec2 vertex_uv; layout (location = 0) in vec2 vertex_texcoord0;
layout (location = 0) out vec2 textureCoordinate; layout (location = 0) out vec2 textureCoordinate;
void main() { void main() {
textureCoordinate = vertex_uv; textureCoordinate = vertex_texcoord0;
gl_Position = ubuf.mvp_matrix * vec4(vertex_uv.x * 2.0 - 1.0, vertex_uv.y * 2.0 - 1.0, 0.0, 1.0); gl_Position = ubuf.mvp_matrix * vec4(vertex_texcoord0.x * 2.0 - 1.0, vertex_texcoord0.y * 2.0 - 1.0, 0.0, 1.0);
} }