Advertisement
Guest User

Untitled

a guest
Nov 11th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.56 KB | None | 0 0
  1. // by IQ
  2. // just another march, this time to accumulate the difference
  3. // between points across the normal (i.e. little means dark means occluded)
  4. // requires a fair bit of fucking around to make this look good
  5. float calcAO( in vec3 pos, in vec3 nor, in float strength)
  6. {
  7.     float occ = 0.0;
  8.     float sca = 1.0;
  9.     for( int i=0; i<16; i++ )
  10.     {
  11.         float h = 0.001 + strength*float(i)/4.0;
  12.         float d = fScene( pos + h*nor );
  13.         occ += (h-d)*sca;
  14.         sca *= 0.95;
  15.     }
  16.     return clamp( 1.0 - 1.5*occ /* was 1.5 */, 0.0, 1.0 );    
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement