Reworked mesh asset loading

This commit is contained in:
Dynamitos
2024-05-01 14:10:52 +02:00
parent 19922f4624
commit 2c1669aab4
23 changed files with 647 additions and 460 deletions
+1 -1
View File
@@ -10,7 +10,7 @@ struct BlinnPhong : IBRDF
float3 baseColor;
float metallic;
float3 normal;
float specular;
float3 specular;
float roughness;
float sheen;
+13 -5
View File
@@ -1,9 +1,11 @@
import Common;
#define MAX_NUM_TEXCOORDS 8
struct MaterialParameter
{
float3 position_WS;
float2 texCoords;
float2 texCoords[MAX_NUM_TEXCOORDS];
float3 vertexColor;
};
@@ -24,14 +26,17 @@ struct FragmentParameter
float3 tangent_WS : TANGENT0;
float3 biTangent_WS : TANGENT1;
float3 position_WS : POSITION2;
float2 texCoords : TEXCOORD0;
float3 vertexColor : COLOR0;
float2 texCoords[MAX_NUM_TEXCOORDS] : TEXCOORD0;
MaterialParameter getMaterialParameter()
{
MaterialParameter result;
result.position_WS = position_WS;
result.texCoords = texCoords;
result.vertexColor = vertexColor;
for(int i = 0; i < MAX_NUM_TEXCOORDS; ++i)
{
result.texCoords[i] = texCoords[i];
}
return result;
}
LightingParameter getLightingParameter()
@@ -51,8 +56,8 @@ struct VertexAttributes
float3 normal_MS;
float3 tangent_MS;
float3 biTangent_MS;
float2 texCoords;
float3 vertexColor;
float2 texCoords[MAX_NUM_TEXCOORDS];
FragmentParameter getParameter(float4x4 transformMatrix)
{
float4 modelPos = float4(position_MS, 1);
@@ -69,8 +74,11 @@ struct VertexAttributes
result.biTangent_WS = biTangent_WS;
result.position_WS = worldPos.xyz;
result.position_CS = clipPos;
result.texCoords = texCoords;
result.vertexColor = vertexColor;
for(int i = 0; i < MAX_NUM_TEXCOORDS; ++i)
{
result.texCoords[i] = texCoords[i];
}
return result;
}
};
+1 -1
View File
@@ -11,7 +11,7 @@ struct StaticMeshVertexData : IVertexData
attributes.normal_MS = float3(normals[3 * index + 0], normals[3 * index + 1], normals[3 * index + 2]);
attributes.tangent_MS = float3(tangents[3 * index + 0], tangents[3 * index + 1], tangents[3 * index + 2]);
attributes.biTangent_MS = float3(biTangents[3 * index + 0], biTangents[3 * index + 1], biTangents[3 * index + 2]);
attributes.texCoords = float2(texCoords[2 * index + 0], texCoords[2 * index + 1]);
attributes.texCoords[0] = float2(texCoords[2 * index + 0], texCoords[2 * index + 1]);
attributes.vertexColor = float3(color[3 * index + 0], color[3 * index + 1], color[3 * index + 2]);
return attributes;
}