public Color GetRadiance(ShadingState state) { // don't use these - gather lights for sphere of directions // gather lights state.initLightSamples(); state.initCausticSamples(); Vector3 v = state.getRay().getDirection(); v.negate(); Vector3 h = new Vector3(); Vector3 t = state.getBasis().transform(new Vector3(0, 1, 0)); Color diff = Color.black(); Color spec = Color.black(); foreach (LightSample ls in state) { Vector3 l = ls.getShadowRay().getDirection(); float dotTL = Vector3.dot(t, l); float sinTL = (float)Math.Sqrt(1 - dotTL * dotTL); // float dotVL = Vector3.dot(v, l); diff.madd(sinTL, ls.getDiffuseRadiance()); Vector3.add(v, l, h); h.normalize(); float dotTH = Vector3.dot(t, h); float sinTH = (float)Math.Sqrt(1 - dotTH * dotTH); float s = (float)Math.Pow(sinTH, 10.0f); spec.madd(s, ls.getSpecularRadiance()); } Color c = Color.add(diff, spec, new Color()); // transparency return(Color.blend(c, state.traceTransparency(), state.getV(), new Color())); }
public Color getRadiance(ShadingState state) { // don't use these - gather lights for sphere of directions // gather lights state.initLightSamples(); state.initCausticSamples(); Vector3 v = state.getRay().getDirection(); v.negate(); Vector3 h = new Vector3(); Vector3 t = state.getBasis().transform(new Vector3(0, 1, 0)); Color diff = Color.black(); Color spec = Color.black(); foreach (LightSample ls in state) { Vector3 l = ls.getShadowRay().getDirection(); float dotTL = Vector3.dot(t, l); float sinTL = (float)Math.Sqrt(1 - dotTL * dotTL); // float dotVL = Vector3.dot(v, l); diff.madd(sinTL, ls.getDiffuseRadiance()); Vector3.add(v, l, h); h.normalize(); float dotTH = Vector3.dot(t, h); float sinTH = (float)Math.Sqrt(1 - dotTH * dotTH); float s = (float)Math.Pow(sinTH, 10.0f); spec.madd(s, ls.getSpecularRadiance()); } Color c = Color.add(diff, spec, new Color()); // transparency return Color.blend(c, state.traceTransparency(), state.getV(), new Color()); }