我不能让我的对象变得透明,我认为俄罗斯轮盘赌是第4部分出了问题。找出光子继续存在的可能性。
// Trace a ray from the light
{
// 1. Find first object hit by photon.
// 2. Store the photon if it has already has a specular reflection and if this is a diffuse surface.
}
// 3. Stop if at max depth.
if (depth == 0)
return;
// 4. Find the probability that the photon continues.
vec3 pd = vec3(mat->ks.x + mat->kd.x, mat->ks.y + mat->kd.y, mat->ks.z + mat->kd.z);
float prob;
if (pd.x > pd.y && pd.x > pd.z)
prob = pd.x;
else if (pd.y > pd.x && pd.y > pd.z)
prob = pd.y;
else
prob = pd.z;
float p_s = prob * (mat->ks.x + mat->ks.y + mat->ks.z) / (mat->ks.x + mat->ks.y + mat->ks.z + mat->kd.x + mat->kd.y + mat->kd.z) ;
float p_d = prob * (mat->kd.x + mat->kd.y + mat->kd.z) / (mat->ks.x + mat->ks.y + mat->ks.z + mat->kd.x + mat->kd.y + mat->kd.z);
// 5. Generate random number. If that shows that the photon dies, return.
float rnd = randIn01() ;
if (rnd > prob)
return;
// 6. Probabilistically determine the action (one of diffuse or
// specular reflection for all surfaces, plus refracted
// transmission for non-opaque surfaces). Based on the action,
// compute the power loss (maybe!) and a direction to follow.
}
我在这里做错了什么?