本文整理汇总了C#中ShadingState.traceShadow方法的典型用法代码示例。如果您正苦于以下问题:C# ShadingState.traceShadow方法的具体用法?C# ShadingState.traceShadow怎么用?C# ShadingState.traceShadow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShadingState
的用法示例。
在下文中一共展示了ShadingState.traceShadow方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getIrradiance
public Color getIrradiance(ShadingState state, Color diffuseReflectance)
{
OrthoNormalBasis onb = state.getBasis();
Vector3 w = new Vector3();
Color result = Color.black();
for (int i = 0; i < samples; i++)
{
float xi = (float)state.getRandom(i, 0, samples);
float xj = (float)state.getRandom(i, 1, samples);
float phi = (float)(2 * Math.PI * xi);
float cosPhi = (float)Math.Cos(phi);
float sinPhi = (float)Math.Sin(phi);
float sinTheta = (float)Math.Sqrt(xj);
float cosTheta = (float)Math.Sqrt(1.0f - xj);
w.x = cosPhi * sinTheta;
w.y = sinPhi * sinTheta;
w.z = cosTheta;
onb.transform(w);
Ray r = new Ray(state.getPoint(), w);
r.setMax(maxDist);
result.add(Color.blend(bright, dark, state.traceShadow(r)));
}
return result.mul((float)Math.PI / samples);
}
示例2: getIrradiance
public Color getIrradiance(ShadingState state, Color diffuseReflectance)
{
float b = (float)Math.PI * c / diffuseReflectance.getMax();
Color irr = Color.black();
Point3 p = state.getPoint();
Vector3 n = state.getNormal();
int set = (int)(state.getRandom(0, 1, 1) * numSets);
foreach (PointLight vpl in virtualLights[set])
{
Ray r = new Ray(p, vpl.p);
float dotNlD = -(r.dx * vpl.n.x + r.dy * vpl.n.y + r.dz * vpl.n.z);
float dotND = r.dx * n.x + r.dy * n.y + r.dz * n.z;
if (dotNlD > 0 && dotND > 0)
{
float r2 = r.getMax() * r.getMax();
Color opacity = state.traceShadow(r);
Color power = Color.blend(vpl.power, Color.BLACK, opacity);
float g = (dotND * dotNlD) / r2;
irr.madd(0.25f * Math.Min(g, b), power);
}
}
// bias compensation
int nb = (state.getDiffuseDepth() == 0 || numBias <= 0) ? numBias : 1;
if (nb <= 0)
return irr;
OrthoNormalBasis onb = state.getBasis();
Vector3 w = new Vector3();
float scale = (float)Math.PI / nb;
for (int i = 0; i < nb; i++)
{
float xi = (float)state.getRandom(i, 0, nb);
float xj = (float)state.getRandom(i, 1, nb);
float phi = (float)(xi * 2 * Math.PI);
float cosPhi = (float)Math.Cos(phi);
float sinPhi = (float)Math.Sin(phi);
float sinTheta = (float)Math.Sqrt(xj);
float cosTheta = (float)Math.Sqrt(1.0f - xj);
w.x = cosPhi * sinTheta;
w.y = sinPhi * sinTheta;
w.z = cosTheta;
onb.transform(w);
Ray r = new Ray(state.getPoint(), w);
r.setMax((float)Math.Sqrt(cosTheta / b));
ShadingState temp = state.traceFinalGather(r, i);
if (temp != null)
{
temp.getInstance().prepareShadingState(temp);
if (temp.getShader() != null)
{
float dist = temp.getRay().getMax();
float r2 = dist * dist;
float cosThetaY = -Vector3.dot(w, temp.getNormal());
if (cosThetaY > 0)
{
float g = (cosTheta * cosThetaY) / r2;
// was this path accounted for yet?
if (g > b)
irr.madd(scale * (g - b) / g, temp.getShader().getRadiance(temp));
}
}
}
}
return irr;
}
示例3: traceShadow
/**
* Trace the shadow ray, attenuating the sample's color by the opacity of
* intersected objects.
*
* @param state shading state representing the point to be shaded
*/
public void traceShadow(ShadingState state)
{
Color opacity = state.traceShadow(shadowRay);
Color.blend(ldiff, Color.BLACK, opacity, ldiff);
Color.blend(lspec, Color.BLACK, opacity, lspec);
}