use of org.sunflow.core.LightSample in project joons-renderer by joonhyublee.
the class PointLight method getSamples.
public void getSamples(ShadingState state) {
Vector3 d = Point3.sub(lightPoint, state.getPoint(), new Vector3());
if (Vector3.dot(d, state.getNormal()) > 0 && Vector3.dot(d, state.getGeoNormal()) > 0) {
LightSample dest = new LightSample();
// prepare shadow ray
dest.setShadowRay(new Ray(state.getPoint(), lightPoint));
float scale = 1.0f / (float) (4 * Math.PI * lightPoint.distanceToSquared(state.getPoint()));
dest.setRadiance(power, power);
dest.getDiffuseRadiance().mul(scale);
dest.getSpecularRadiance().mul(scale);
dest.traceShadow(state);
state.addSample(dest);
}
}
Aggregations