0

我正在尝试为我的光线追踪器制作朗伯着色器,但遇到了麻烦。场景似乎仍然是平坦的阴影,只是稍微暗了一点。比如这张图片 在此处输入图像描述

这是我的着色器类:

public class LambertianShader {

    public Colour diffuseColour;

    public LambertianShader(Colour diffuseColour){
        this.diffuseColour = diffuseColour;
    }

    public Colour shade(Intersection intersection, Light light){
        Vector3D lightDirection =  light.location.subtract(intersection.point);
        lightDirection.normalise();


        Colour finalColour = new Colour();
        float lambCoef = (float) intersection.normal.dot(lightDirection);

        if(lambCoef>0){
            finalColour.r = Math.max(0.0f, diffuseColour.r * lambCoef * light.intensity.r);
            finalColour.g = Math.max(0.0f, diffuseColour.g * lambCoef * light.intensity.g);
            finalColour.b = Math.max(0.0f, diffuseColour.b * lambCoef * light.intensity.b);


        }
        return finalColour;

    }

}

如果您想查看更多我的代码,请告诉我。

4

0 回答 0