本文整理汇总了C#中Normal.ToVec方法的典型用法代码示例。如果您正苦于以下问题:C# Normal.ToVec方法的具体用法?C# Normal.ToVec怎么用?C# Normal.ToVec使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Normal
的用法示例。
在下文中一共展示了Normal.ToVec方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Sample
public override void Sample(ref Vector wi, ref Normal n, float u0, float u1, float lambda, out Vector dir, out float f)
{
var nl = n.ToVec();
dir = Geometry.Reflect(ref wi, ref n);
//new Vector(wi - nl * 2f * nl&wi);
f = 1f;
}
示例2: Sample_f
public override void Sample_f(ref Vector wo, ref Normal N, ref Normal shadeN, ref RgbSpectrum in_f, float u0, float u1, float u2, ref SurfaceTextureData surfaceData, out BsdfSampleData result) {
EvalParams(ref surfaceData);
bool into = (Normal.Dot(ref N, ref shadeN) > 0f);
result = new BsdfSampleData();
result.Type = this.Type;
if (!into) {
// No internal reflections
result.Wi = (-wo);
result.Pdf = 1f;
result.Type = reflectionSpecularBounce ? BrdfType.Specular : BrdfType.Glossy;
result.F = Krefl;
}
else {
// RR to choose if reflect the ray or go trough the glass
float comp = u0 * totFilter;
if (comp > transFilter) {
Vector mwo = -wo;
result.Wi = mwo - (2f * Vector.Dot(ref N, ref mwo)) * N.ToVec();
result.Pdf = reflPdf;
result.Type = reflectionSpecularBounce ? BrdfType.Specular : BrdfType.Glossy;
result.F = Krefrct;
}
else {
result.Wi = -wo;
result.Pdf = transPdf;
result.F = Krefrct;
result.Type = transmitionSpecularBounce ? BrdfType.Specular : BrdfType.Glossy;
}
}
}
示例3: Sample_f
public override void Sample_f(ref Vector wo, ref Normal N, ref Normal shadeN, ref RgbSpectrum in_f, float u0, float u1, float u2, ref SurfaceTextureData surfaceData, out BsdfSampleData result) {
Vector dir = -wo;
float dp = Normal.Dot(ref shadeN, ref dir);
result.Lambda = 0f;
result.Wi = dir - (2f * dp) * shadeN.ToVec();
result.Type = reflectionSpecularBounce ? BrdfType.Specular : BrdfType.Glossy;
result.Pdf = 1f;
result.F = Kr;
}
示例4: Sample
public RgbSpectrum Sample(ref Point point, ref Normal n, float u0, float u1, float u2, out RayInfo ray, out float pdf)
{
var wi = MC.CosineSampleHemisphere(u1, u2);
pdf = wi.z * MathLab.INVPI;
Vector v1, v2;
Vector.CoordinateSystem(n.ToVec(), out v1, out v2);
wi = new Vector(
v1.x * wi.x + v2.x * wi.y + n.x * wi.z,
v1.y * wi.x + v2.y * wi.y + n.y * wi.z,
v1.z * wi.x + v2.z * wi.y + n.z * wi.z);
ray = new RayInfo(point, wi, 1e-4f, float.MaxValue);
return Le(wi);
}
示例5: CreateFrame
public void CreateFrame(ref Normal n)
{
nn = n.ToVec().Normalize();
Vector.CoordinateSystem(nn, out sn, out tn);
}
示例6: TransformAccordingNormal
public static void TransformAccordingNormal(Normal nn, Vector woL, ref Vector woW) {
Vector sn = new Vector(), tn;
float zz = (float)Math.Sqrt(1f - nn.z * nn.z);
sn.z = 0f;
if (Math.Abs(zz) < 1e-6f) {
sn.x = 1f;
sn.y = 0f;
}
else {
sn.x = nn.y / zz;
sn.y = -nn.x / zz;
}
tn = (nn.ToVec() ^ sn);
woW = woL.x * sn + woL.y * tn + woL.z * (new Vector(nn.x, nn.y, nn.z));
}
示例7: Bsdf
public Bsdf(ref Normal geoN, ref Normal shadeN)
{
nn = shadeN.ToVec();
nn.Normalize();
ng = geoN.ToVec();
ng.Normalize();
Vector.CoordinateSystem(ref nn, out sn, out tn);
bxdfs = new List<BxDF>();
}
示例8: IntersectSphere
protected static bool IntersectSphere(ref Normal N, float D, ref RayData ray, ref RayHit rayHit)
{
var vd = N.ToVec() & ray.Dir;
if (vd > -MathLab.Epsilon && vd < MathLab.Epsilon)
{
rayHit.Index = RayBuffer.NotHit;
return false;
}
var t = -((N.ToVec() & ray.Org.ToVec()) + D) / vd;
var result = t > MathLab.Epsilon;
if (result)
{
rayHit.Index = 0;
rayHit.Distance = t;
}
rayHit.Index = RayBuffer.NotHit;
return false;
}
示例9: Reflect
public static Vector Reflect(ref Vector dir, ref Normal N)
{
float dp = Normal.Dot(ref N, ref dir);
return dir - (2f*dp)*N.ToVec();
}