本文整理汇总了C#中RayDen.Library.Core.Primitives.RgbSpectrum.MaxAsSingle方法的典型用法代码示例。如果您正苦于以下问题:C# RgbSpectrum.MaxAsSingle方法的具体用法?C# RgbSpectrum.MaxAsSingle怎么用?C# RgbSpectrum.MaxAsSingle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RayDen.Library.Core.Primitives.RgbSpectrum
的用法示例。
在下文中一共展示了RgbSpectrum.MaxAsSingle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Sample_f
public override void Sample_f(ref Vector wo, ref Normal Normal, ref Normal shadeNormal, ref RgbSpectrum in_f, float u0, float u1, float u2, ref SurfaceTextureData surfaceData, out BsdfSampleData result)
{
result.Lambda = 0f;
EvalParams(ref surfaceData);
Assert.IsTrue(!Krefl.IsBlack());
Assert.IsTrue(!Krefrct.IsBlack());
Vector rayDir = -wo;
var N = shadeNormal;
var shadeN = shadeNormal;
var wi = new Vector();
var N1 = N.ToVec();
var reflDir = rayDir - (2f * (Normal.Dot(ref N, ref rayDir))) * N1;
// Ray from outside going in ?
bool into = ((Normal.Dot(ref N, ref shadeN)) > 0);
float nc = ousideIor;
bool disperse = in_f.y() > u0;
float nt = ior + (disperse ? (1f - in_f.y())/10f : 0f);
if (disperse)
{
Krefrct = in_f.MaxAsSingle()*in_f;
//SampledSpectrum.ReflRainbow[(int) Math.Round((SampledSpectrum.ReflRainbow.Length-1)*u2)];
}
float nnt = into ? (nc / nt) : (nt / nc);
float ddn = (rayDir & shadeN.ToVec());
float cos2t = 1f - nnt * nnt * (1f - ddn * ddn);
result.F = RgbSpectrum.UnitSpectrum();
// Total internal reflection
if (cos2t < 0f)
{
wi = reflDir;
result.Pdf = 1f;
result.Type = reflectionSpecularBounce ? BrdfType.Specular : BrdfType.Glossy;
result.F = Krefl;
result.Wi = wi;
return;
}
float kk = (into ? 1f : -1f) * (ddn * nnt + MathLab.Sqrt((cos2t)));
Vector nkk = kk * N1;
Vector transDir = (nnt * rayDir - nkk).Normalize();
float c = 1f - (into ? -ddn : (transDir & N1));
float Re = R0 + (1f - R0) * c * c * c * c * c;
float Tr = 1f - Re;
float P = .25f + .5f * Re;
if (Tr.NearEqual(0f))
{
if (Re.NearEqual(0f))
{
result.Pdf = 0f;
result.Type = BrdfType.Specular;
result.F = new RgbSpectrum(0f);
}
else
{
(wi) = reflDir;
result.Pdf = 1f;
result.Type = reflectionSpecularBounce ? BrdfType.Specular : BrdfType.Glossy;
result.F = Krefl;
}
}
else if (Re.NearEqual(0f))
{
(wi) = transDir;
result.Pdf = 1f;
result.Type = transmitionSpecularBounce ? BrdfType.Specular : BrdfType.Glossy;
result.F = Krefrct;
}
else if (u0 < P)
{
(wi) = reflDir;
result.Pdf = P / Re;
result.Type = reflectionSpecularBounce ? BrdfType.Specular : BrdfType.Glossy;
result.F = Krefl;
}
else
{
if (u0 > u1)
{
//(wi) = SampleTransmissionDirection(u0, u1, ref transDir);
wi = transDir;
result.F = Krefrct;
//SampleTransmission(u1, u2, ref Krefrct);
}
else
{
wi = transDir;
result.F = Krefrct;
//.........这里部分代码省略.........