コード例 #1
0
ファイル: Metal.cs プロジェクト: RyouYuan/SlowRenderer
        public override bool Scatter(Vector3 normal, Ray ray)
        {
            Vector3 scatteredDir = Vector3.Reflect(ray.direction, normal);

            scatteredDir += roughness * CoreRandom.SampleUnitSphere();
            if (Vector3.Dot(scatteredDir, normal) > 0)
            {
                ray.origin    = ray.GetHitPiont();
                ray.direction = scatteredDir;
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #2
0
ファイル: Lambertian.cs プロジェクト: RyouYuan/SlowRenderer
 public override bool Scatter(Vector3 normal, Ray ray)
 {
     ray.origin    = ray.GetHitPiont();
     ray.direction = normal + CoreRandom.SampleUnitSphere();
     return(true);
 }