Use the screenspace partial derivatives of the viewspace position to compute the normal.
| 14 | |
| 15 | // Use the screenspace partial derivatives of the viewspace position to compute the normal. |
| 16 | vec3 computeViewNormal(vec3 pos) |
| 17 | { |
| 18 | vec3 dx = dFdx(pos); |
| 19 | vec3 dy = dFdy(pos); |
| 20 | return normalize(cross(dx, dy)); |
| 21 | } |
| 22 | |
| 23 | float computeViewFalloff(vec3 viewPos, vec3 viewUp) |
| 24 | { |