|
@@ -8,9 +8,14 @@ class SAO extends ScreenShader {
|
|
|
|
|
|
static var SRC = {
|
|
|
|
|
|
- @range(4,30) @const var numSamples : Int;
|
|
|
+ @global var camera : {
|
|
|
+ var position : Vec3;
|
|
|
+ };
|
|
|
+
|
|
|
+ @range(4,30) @const(127) var numSamples : Int;
|
|
|
@range(1,10) @const(16) var numSpiralTurns : Int;
|
|
|
@const var useWorldUV : Bool;
|
|
|
+ @const var USE_FADE : Bool = false;
|
|
|
|
|
|
@ignore @param var depthTexture : Channel;
|
|
|
@ignore @param var normalTexture : Channel3;
|
|
@@ -29,6 +34,9 @@ class SAO extends ScreenShader {
|
|
|
@ignore @param var microOcclusion : Channel;
|
|
|
@param var microOcclusionIntensity : Float;
|
|
|
|
|
|
+ @param var fadeStart : Float;
|
|
|
+ @param var fadeEnd : Float;
|
|
|
+
|
|
|
function sampleAO(uv : Vec2, position : Vec3, normal : Vec3, radiusSS : Float, tapIndex : Int, rotationAngle : Float) : Float {
|
|
|
// returns a unit vector and a screen-space radius for the tap on a unit disk
|
|
|
// (the caller should scale by the actual disk radius)
|
|
@@ -83,6 +91,10 @@ class SAO extends ScreenShader {
|
|
|
occlusion = 1.0 - occlusion / float(numSamples);
|
|
|
occlusion = pow(occlusion, 1.0 + intensity).saturate();
|
|
|
|
|
|
+ if ( USE_FADE ) {
|
|
|
+ var dist = distance(origin, camera.position);
|
|
|
+ occlusion = mix(occlusion, 1.0, saturate((dist - fadeStart) / (fadeEnd - fadeStart)));
|
|
|
+ }
|
|
|
occlusion *= mix(1, microOcclusion.get(vUV).r, microOcclusionIntensity);
|
|
|
|
|
|
output.color = vec4(occlusion.xxx, 1.);
|