Search in sources :

Example 11 with LightSample

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);
    }
}
Also used : LightSample(org.sunflow.core.LightSample) Vector3(org.sunflow.math.Vector3) Ray(org.sunflow.core.Ray)

Aggregations

LightSample (org.sunflow.core.LightSample)11 Ray (org.sunflow.core.Ray)9 Color (org.sunflow.image.Color)8 Vector3 (org.sunflow.math.Vector3)8 Point3 (org.sunflow.math.Point3)4 OrthoNormalBasis (org.sunflow.math.OrthoNormalBasis)2 XYZColor (org.sunflow.image.XYZColor)1