C++ 光子映射中的俄罗斯轮盘赌有什么不对?
我不能让我的对象透明,我认为俄罗斯轮盘赌第四部分出了问题。找出光子继续的概率C++ 光子映射中的俄罗斯轮盘赌有什么不对?,c++,graphics,rendering,raytracing,C++,Graphics,Rendering,Raytracing,我不能让我的对象透明,我认为俄罗斯轮盘赌第四部分出了问题。找出光子继续的概率 // 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. St
// 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.
}
我在这里做错了什么?你能给我们一些图片吗:这段代码当前呈现的内容,以及你希望它呈现的内容?另外,你的代码缺少部分,如1、2和6-请添加这些。你能给我们一些图片吗:这段代码当前呈现的内容,以及你希望它呈现的内容?另外,你的代码缺少部分,比如1,2,6,请加上这些。