Created
April 27, 2019 09:18
-
-
Save ShiftedClock/618dee31a85a2ea728e92dc5684dd68d to your computer and use it in GitHub Desktop.
An ambient occlusion routine for a raymarched shader
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| uniform float _AoStepsize, _AoIntensity; | |
| uniform int _AoIterations; | |
| float AmbientOcclusion(float3 ro, float3 p, float3 re, float3 n) { | |
| float step = _AoStepsize; | |
| float ao = 0.0; | |
| float dist; | |
| for (int i = 1; i <= _AoIterations; i++) { | |
| dist = step * i; | |
| ao += max(0.0,(dist - distanceField(ro, p + n * dist, re).w) / dist); | |
| } | |
| return (1.0 - ao * _AoIntensity); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment