本文整理汇总了C#中Light.IntensityAt方法的典型用法代码示例。如果您正苦于以下问题:C# Light.IntensityAt方法的具体用法?C# Light.IntensityAt怎么用?C# Light.IntensityAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Light
的用法示例。
在下文中一共展示了Light.IntensityAt方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Lambertian
/// <summary>
/// Calculate lambertian (diffuse) contribution
/// </summary>
/// <param name="light">light source</param>
/// <param name="lightv">direction of light ray to point of intersection</param>
/// <param name="normal">normal of surface</param>
/// <param name="distance">distance from intersection to the light</param>
/// <returns>Diffuse colour</returns>
public Color Lambertian(Vector3 normal, Light light, Vector3 lightv, float distance)
{
var cosAngle = Math.Abs(Vector3.Dot(lightv, normal));
return Colour * cosAngle * light.IntensityAt(distance) * light.Colour;
}
示例2: Specular
/// <summary>
/// Calculate specular contribution (blinn-phong)
/// </summary>
/// <param name="light">light source</param>
/// <param name="rayDir">incoming direction of tracer ray</param>
/// <param name="lightv">incoming direction of light ray</param>
/// <param name="normal">normal of the surface</param>
/// <param name="distance">distance from intersection to the light</param>
/// <returns></returns>
public Color Specular(Vector3 normal, Vector3 rayDir, Light light, Vector3 lightv, float distance)
{
// get the h component
var added = -rayDir + -lightv; // rayDir and lightDir are the wrong way round
added.Normalize();
var h = added/Vector3.Distance(added, Vector3.Zero);
const int phongExponent = 100;
var dot = Vector3.Dot(h, normal);
var specular =(float) Math.Pow(dot, phongExponent);
return specular*light.IntensityAt(distance) * light.Colour;
}
示例3: Ambient
/// <summary>
/// Calculate Ambient contribution, fraction of light colour and intensity
/// </summary>
/// <param name="light">Light source</param>
/// <param name="distance"></param>
/// <returns>Ambient colour</returns>
public Color Ambient(Light light, float distance)
{
var a = AmbientFraction*light.IntensityAt(distance)*light.Colour;
return a;
}