60 likes | 210 Views
Local bounce in surface shader - ILM. Technique for faking self re-emission of light on a surface Automatic: No additional lights No pre-pass needed Respect shadows and occlusions. Local bounce in surface shader - ILM. Psample = position of the bounce
E N D
Local bounce in surface shader - ILM • Technique for faking self re-emission of light on a surface • Automatic: • No additional lights • No pre-pass needed • Respect shadows and occlusions
Local bounce in surface shader - ILM • Psample = position of the bounce pointOnSurface -p -u $uPos -v $vPos $surfaceName • Nsample = normal at Psample pointOnSurface -n -u $uPos -v $vPos $surfaceName • Csample = average color around Psample
Local bounce in surface shader - ILM • Kbounce = intensity of effect • Fbounce = falloff of effect
Local bounce in surface shader - ILM • Do an illuminance loop on Psample • Apply resulting color as a Lambertian diffuse term with a smoothstep distance attenuation • Add value to global diffuse term at P: CKD
Local bounce in surface shader - ILM if (Kbounce > 0.0) { Psample = transform (world, current, Psample); Nsample = ntransform (world, current, Nsample); vector Lsample = Psample - P; /* fake light direction */ float distsample = length(Lsample); color CKDsample = 0; if (distsample < Fbounce) {
Local bounce in surface shader - ILM illuminance(Psample, Nsample, PI/2) { CKDsample += Cl * Nsample.normalize(L); } CKDsample *= Kd * Csample; /* resulting bounce */ if (distsample != 0.0) Lsample /= distsample; float NdotLsample = N.Lsample; if (NdotLsample > 0.0) { CKD += Kbounce * CKDsample * NdotLsample * (1.0 - smoothstep(0.0, Fbounce, distsample)); } }