Completed Metal implementation
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user