2023-10-07 19:29:53 +02:00
|
|
|
import Common;
|
2023-11-08 23:27:21 +01:00
|
|
|
import VertexData;
|
|
|
|
|
import MaterialParameter;
|
2023-10-07 19:29:53 +02:00
|
|
|
|
2025-04-11 09:54:09 +02:00
|
|
|
struct StaticMeshVertexData : IVertexData
|
2023-10-07 19:29:53 +02:00
|
|
|
{
|
2024-10-01 11:15:38 +02:00
|
|
|
float uint16ToFloat(uint16_t value)
|
|
|
|
|
{
|
|
|
|
|
return value / 65535.0f;
|
|
|
|
|
}
|
2024-12-21 20:47:57 +01:00
|
|
|
|
2023-11-27 21:08:27 +01:00
|
|
|
VertexAttributes getAttributes(uint index)
|
2023-10-07 19:29:53 +02:00
|
|
|
{
|
2023-11-09 22:15:51 +01:00
|
|
|
VertexAttributes attributes;
|
2024-10-01 11:15:38 +02:00
|
|
|
attributes.position_MS = float3(positions[index * 3 + 0], positions[index * 3 + 1], positions[index * 3 + 2]);
|
2024-06-19 10:33:19 +02:00
|
|
|
#ifndef POS_ONLY
|
2025-01-29 16:29:58 +01:00
|
|
|
//attributes.qTangent = qTangent[index];
|
|
|
|
|
attributes.normal_MS = float3(normals[index * 3 + 0], normals[index * 3 + 1], normals[index * 3 + 2]);
|
2025-05-04 21:30:01 +02:00
|
|
|
attributes.tangent_MS = float3(tangents[index * 3 + 0], tangents[index * 3 + 1], tangents[index * 3 + 2]);
|
|
|
|
|
attributes.biTangent_MS = float3(biTangents[index * 3 + 0], biTangents[index * 3 + 1], biTangents[index * 3 + 2]);;
|
2024-05-06 18:36:16 +02:00
|
|
|
for(uint i = 0; i < MAX_TEXCOORDS; ++i)
|
|
|
|
|
{
|
2024-10-01 11:15:38 +02:00
|
|
|
attributes.texCoords[i] = float2(uint16ToFloat(texCoords[i][index * 2 + 0]), uint16ToFloat(texCoords[i][index * 2 + 1]));
|
2024-05-06 18:36:16 +02:00
|
|
|
}
|
2024-10-01 16:56:04 +02:00
|
|
|
attributes.vertexColor = float3(uint16ToFloat(color[index * 3 + 0]), uint16ToFloat(color[index * 3 + 1]) , uint16ToFloat(color[index * 3 + 2]));
|
2024-06-19 10:33:19 +02:00
|
|
|
#endif
|
2023-11-09 22:15:51 +01:00
|
|
|
return attributes;
|
2023-10-07 19:29:53 +02:00
|
|
|
}
|
2024-10-01 11:15:38 +02:00
|
|
|
StructuredBuffer<float> positions;
|
2025-03-31 11:39:17 +02:00
|
|
|
//StructuredBuffer<float> qTangents;
|
2025-01-29 16:29:58 +01:00
|
|
|
StructuredBuffer<float> normals;
|
2025-05-04 21:30:01 +02:00
|
|
|
StructuredBuffer<float> tangents;
|
|
|
|
|
StructuredBuffer<float> biTangents;
|
2024-10-01 11:15:38 +02:00
|
|
|
StructuredBuffer<uint16_t> color;
|
|
|
|
|
StructuredBuffer<uint16_t> texCoords[MAX_TEXCOORDS];
|
2023-11-08 23:27:21 +01:00
|
|
|
};
|