public Vector3?Sample(Vector3 outDir, bool isOnLightSubpath, Vector2 primarySample) { if (outDir.Z == 0) { return(null); } Vector3 wh = distribution.Sample(outDir, primarySample); if (Vector3.Dot(outDir, wh) < 0) { return(null); } float eta = ShadingSpace.CosTheta(outDir) > 0 ? (outsideIOR / insideIOR) : (insideIOR / outsideIOR); var inDir = ShadingSpace.Refract(outDir, wh, eta); return(inDir); }