Completed Metal implementation

This commit is contained in:
Dynamitos
2026-07-09 14:11:51 +02:00
parent df3af75801
commit a857051eea
20 changed files with 173 additions and 33 deletions
+10 -6
View File
@@ -10,20 +10,23 @@ struct Camera
float ks;
float A;
float ka;
float2 sensorSize;
uint width;
uint height;
};
struct MaterialParameter
{
float3 albedo = float3(1, 1, 1);
float alpha = 1;
float3 specularColor = float3(1, 1, 1);
float shininess = 0.04;
float3 emissive = float3(0, 0, 0);
float4 albedo_alpha; // xyz: albedo, w: alpha
float4 specularColor_sh; // xyz: specularColor, w: shininess
float4 emissive_type; // xyz: emissive, w: materialType (as float)
float3 shade(float3 normal, float3 viewDir, float3 lightDir, float3 lightColor)
{
float3 albedo = albedo_alpha.xyz;
float shininess = specularColor_sh.w;
float diffuse = max(dot(normal, lightDir), 0);
float3 h = normalize(lightDir + viewDir);
float specular = pow(clamp(dot(normal, h), 0, 1), shininess);
float specular = pow(clamp(dot(normal, h), 0.0f, 1.0f), shininess);
return (albedo * diffuse * lightColor);
}
@@ -34,6 +37,7 @@ struct ModelReference
uint32_t positionOffset = 0;
uint32_t indicesOffset = 0;
uint32_t numIndices = 0;
uint32_t materialIndex = 0;
};
struct PointLight