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
+4 -4
View File
@@ -29,9 +29,9 @@ void closestHit(inout RayPayload hitValue, in BuiltInTriangleIntersectionAttribu
float3 normalLight = dot(vert.normal, WorldRayDirection()) < 0 ? vert.normal : -vert.normal;
MaterialParameter mat; // TOOD:
hitValue.depth++;
MaterialParameter mat = pParams.materialData[m.materialIndex];
float3 emissive = mat.emissive_type.xyz;
float3 localAccRad = float3(0);
float3 rnd = rand01(uint3(vertexIndex0, vertexIndex1, vertexIndex2));
//float kt = ka + ks;
@@ -103,7 +103,7 @@ void closestHit(inout RayPayload hitValue, in BuiltInTriangleIntersectionAttribu
localAccRad += mat.shade(vert.normal, -WorldRayDirection(), normalize(l), pParams.pointLights[i].color);
}
}
hitValue.light += localAccRad;
hitValue.light += localAccRad + emissive;
// Indirect Illumination: cosine-weighted importance sampling
if(hitValue.depth < 12) {
float r1 = 2 * PI * rnd.x, r2 = rnd.y, r2s = sqrt(r2);