Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float3 position = Position.Sample(deferredSampler, input.uv).rgb;
- float3 normal = Normal.Sample(deferredSampler, input.uv).rgb;
- float depth = distance(position, CameraPosition);
- float noise = 0;// rand_1_05(input.uv);
- float r = AORadius / SampleRadius;
- float occlusion = 0;
- float dAngle = (2 * pi) / SampleDir;
- float angle = (2 * pi) * noise;
- float rayLen = r / depth;
- for (int i = 0; i < SampleDir; i++)
- {
- angle += dAngle;
- float2 ray = float2(cos(angle), sin(angle))*rayLen;
- for (int j = 0; j < SampleRadius; j++)
- {
- float3 sampleOffset = Position.Sample(deferredSampler, input.uv + ray * j).rgb - position; // vector towards sample
- float len = dot(sampleOffset, sampleOffset);
- // dot of the sample vector with the surface normal: how big is the angle.
- // div by len: how far is it? is it still relevant to our sample?
- float sampleAngle = dot(sampleOffset, normal) / len;
- occlusion += saturate(sampleAngle) / SampleDir / SampleRadius;
- }
- }
- float final = pow(1 - occlusion, 4);
Advertisement
Add Comment
Please, Sign In to add comment