| 19 | namespace |
| 20 | { |
| 21 | Vector3 gaussian( float variance, float r ) |
| 22 | { |
| 23 | /** |
| 24 | * We use a falloff to modulate the shape of the profile. Big falloffs |
| 25 | * spreads the shape making it wider, while small falloffs make it |
| 26 | * narrower. |
| 27 | */ |
| 28 | Vector3 falloff = Vector3( 1.0f, 0.37f, 0.3f ); |
| 29 | |
| 30 | Vector3 g; |
| 31 | for( int i = 0; i < 3; i++ ) |
| 32 | { |
| 33 | float rr = r / ( 0.001f + falloff[i] ); |
| 34 | g[i] = exp( ( -( rr * rr ) ) / ( 2.0f * variance ) ) / ( 2.0f * 3.14f * variance ); |
| 35 | } |
| 36 | return g; |
| 37 | } |
| 38 | |
| 39 | Vector3 profile( float r ) |
| 40 | { |