// Based on GPU Gems // Optimised by Alan Zucconi inline fixed3 bump3y(fixed3 x, fixed3 yoffset) { float3 y = 1 - x * x; y = saturate(y-yoffset); return y; }
// --- Diffraction grating effect --- float3 L = gi.light.dir; float3 V = viewDir; float3 N = worldNormal;
// Reminder: // thetaL = angle from L to N // thetaR = angle from reflected L inside material to N // From Snell's Law: // N1 * sin(thetaL) = N2 * sin(thetaR) float cos_thetaL = dot(N, L); float thetaL = acos(cos_thetaL);
fixed3 color = 0; for (int n = 1; n <= _Order; n++) { // Constructive interference float wavelength = u / n; color += spectral_zucconi6(wavelength); } color = saturate(color);