问题
I'm trying to make a Lambertian shader for my ray tracer, but am having trouble. The scence still seems to be flat shaded, just a little darker. Such as in this picture
This is my Shader Class:
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;
}
}
If you would like to see any more of my code let me know.
来源:https://stackoverflow.com/questions/29563842/lambertian-shader-not-working