/** * Get the radiance seen through a particular pixel * * @param istate intersection state for ray tracing * @param rx pixel x coordinate * @param ry pixel y coordinate * @param lensU DOF sampling variable * @param lensV DOF sampling variable * @param time motion blur sampling variable * @param instance QMC instance seed * @return a shading state for the intersected primitive, or * <code>null</code> if nothing is seen through the specifieFd * point */ public ShadingState getRadiance(IntersectionState istate, float rx, float ry, double lensU, double lensV, double time, int instance) { if (bakingPrimitives == null) { Ray r = camera.getRay(rx, ry, imageWidth, imageHeight, lensU, lensV, time); return(r != null?lightServer.getRadiance(rx, ry, instance, r, istate) : null); } else { Ray r = new Ray(rx / imageWidth, ry / imageHeight, -1, 0, 0, 1); traceBake(r, istate); if (!istate.hit()) { return(null); } ShadingState state = ShadingState.createState(istate, rx, ry, r, instance, lightServer); bakingPrimitives.prepareShadingState(state); if (bakingViewDependent) { state.setRay(camera.getRay(state.getPoint())); } else { Point3 p = state.getPoint(); Vector3 n = state.getNormal(); // create a ray coming from directly above the point being // shaded Ray incoming = new Ray(p.x + n.x, p.y + n.y, p.z + n.z, -n.x, -n.y, -n.z); incoming.setMax(1); state.setRay(incoming); } lightServer.shadeBakeResult(state); return(state); } }
public ShadingState getRadiance(float rx, float ry, int i, Ray r, IntersectionState istate) { lock (lockObj) { scene.trace(r, istate); if (istate.hit()) { ShadingState state = ShadingState.createState(istate, rx, ry, r, i, this); state.getInstance().prepareShadingState(state); IShader shader = getShader(state); if (shader == null) { state.setResult(Color.BLACK); return(state); } if (_shadingCache != null) { Color c = lookupShadingCache(state, shader); if (c != null) { state.setResult(c); return(state); } } state.setResult(shader.getRadiance(state)); if (_shadingCache != null) { addShadingCache(state, shader, state.getResult()); } return(state); } else { return(null); } } }
public ShadingState getRadiance(float rx, float ry, float time, int i, int d, Ray r, IntersectionState istate, ShadingCache cache) { istate.time = time; scene.trace(r, istate); if (istate.hit()) { ShadingState state = ShadingState.createState(istate, rx, ry, time, r, i, d, this); state.getInstance().prepareShadingState(state); IShader shader = getShader(state); if (shader == null) { state.setResult(Color.BLACK); return(state); } if (cache != null) { Color c = cache.lookup(state, shader); if (c != null) { state.setResult(c); return(state); } } state.setResult(shader.GetRadiance(state)); if (cache != null) { cache.add(state, shader, state.getResult()); } checkNanInf(state.getResult()); return(state); } else { return(null); } }