我一直在阅读有关光线追踪和阴影的大量文章,但我的光线追踪图像看起来并不太好.我在谈论镜面高光附近非常明亮的绿色区域.结果绿色在这里最大化,看起来像.如何调整颜色和/或阴影计算以使其看起来正确?
(别担心愚蠢的代码,我只是想先把原则弄清楚).
以下是它的外观:

这里只是漫反射组件:

这是仅镜面反射分量:

编辑:将漫反射更改为颜色diffuseColor = ColorMake(0.0f,0.6f,0.0f); 然后图像看起来像这样:

Point lightPosition = PointMake(-100.0f, 100.0f, -100.0f);
Color diffuseColor = ColorMake(0.0f, 1.0f, 0.0f);
Color specularColor = ColorMake(1.0f, 1.0f, 1.0f);
Color pixelColor = ColorMake(0.0f, 0.0f, 0.0f);
// Trace...
// Diffuse
Point intersectionPosition = PointMake(x, y, z);
Vector intersectionNormal = VectorMake((x - xs) / rs, (y - ys) / rs, (z - zs) / rs);
Vector intersectionNormalN = VectorNormalize(intersectionNormal);
Vector lightVector = VectorSubtract(lightPosition, intersectionPosition);
VectorlightVectorN = VectorNormalize(lightVector);
float cosTheta = VectorDotProduct(intersectionNormalN, lightVectorN);
if (cosTheta …Run Code Online (Sandbox Code Playgroud) Apple建议您在使用Accelerate Framework时将数据对齐16字节.你在实践中如何做到这一点?
如果我有阵列int[10000];,有pragma吗?如何将其与16字节对齐?