예제 #1
0
파일: Bsdf.cs 프로젝트: HungryBear/rayden
        float mReflectCoeff;     //!< Fresnel reflection coefficient (for glass) 

        Bsdf(
        Ray aRay,
        ref Normal normal,
        Material Material,
        SceneGeometryInfo aScene)
        {
            Setup(aRay, ref normal, Material, aScene);
        }
예제 #2
0
파일: Bsdf.cs 프로젝트: HungryBear/rayden
        void Setup(
            Ray aRay,
            ref Normal normal,
            Material Material,
            SceneGeometryInfo aScene)
        {
            mMaterialID = -1;
            mFrame.SetFromZ(ref normal);
            var invdir = -aRay.Direction;
            mLocalDirFix = mFrame.ToLocal(ref invdir);

            // reject rays that are too parallel with tangent plane
            if (Math.Abs(mLocalDirFix.z) < Consts.EPS_COSINE)
            {
                return;
            }

            GetComponentProbabilities(Material, mProbabilities);

            mIsDelta = (Math.Abs(mProbabilities.diffProb) < MathLab.Epsilon) && (Math.Abs(mProbabilities.phongProb) < MathLab.Epsilon);

            // now it becomes valid
            mMaterialID = 1;//Material.mIOR;
        }
예제 #3
0
파일: Bsdf.cs 프로젝트: HungryBear/rayden
 float AlbedoRefract(Material aMaterial)
 {
     return 1f;
 }
예제 #4
0
파일: Bsdf.cs 프로젝트: HungryBear/rayden
 float AlbedoReflect(Material aMaterial)
 {
     return Luminance(aMaterial.mMirrorReflectance);
 }
예제 #5
0
파일: Bsdf.cs 프로젝트: HungryBear/rayden
 float AlbedoPhong(Material aMaterial)
 {
     return Luminance(aMaterial.mPhongReflectance);
 }
예제 #6
0
파일: Bsdf.cs 프로젝트: HungryBear/rayden
 float AlbedoDiffuse(Material aMaterial)
 {
     return Luminance(aMaterial.mDiffuseReflectance);
 }
예제 #7
0
파일: Bsdf.cs 프로젝트: HungryBear/rayden
        void GetComponentProbabilities(
             Material aMaterial,
            ComponentProbabilities oProbabilities)
        {
            mReflectCoeff = Utils.FresnelDielectric(mLocalDirFix.z, aMaterial.mIOR);

            float albedoDiffuse = AlbedoDiffuse(aMaterial);
            float albedoPhong = AlbedoPhong(aMaterial);
            float albedoReflect = mReflectCoeff * AlbedoReflect(aMaterial);
            float albedoRefract = (1f - mReflectCoeff) * AlbedoRefract(aMaterial);

            float totalAlbedo = albedoDiffuse + albedoPhong + albedoReflect + albedoRefract;

            if (totalAlbedo < 1e-9f)
            {
                oProbabilities.diffProb = 0f;
                oProbabilities.phongProb = 0f;
                oProbabilities.reflProb = 0f;
                oProbabilities.refrProb = 0f;
                mContinuationProb = 0f;
            }
            else
            {
                oProbabilities.diffProb = albedoDiffuse / totalAlbedo;
                oProbabilities.phongProb = albedoPhong / totalAlbedo;
                oProbabilities.reflProb = albedoReflect / totalAlbedo;
                oProbabilities.refrProb = albedoRefract / totalAlbedo;
                // The continuation probability is max component from reflectance.
                // That way the weight of sample will never rise.
                // Luminance is another very valid option.
                mContinuationProb =
                    (aMaterial.mDiffuseReflectance +
                    aMaterial.mPhongReflectance +
                    mReflectCoeff * aMaterial.mMirrorReflectance).Max() +
                    (1f - mReflectCoeff);

                mContinuationProb = Math.Min(1f, Math.Max(0f, mContinuationProb));
            }
        }