Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl')
-rw-r--r--source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl35
1 files changed, 35 insertions, 0 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl b/source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl
index 4da30dd74ee..d8adf302e37 100644
--- a/source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl
@@ -26,6 +26,10 @@
# endif
#endif
+#ifndef GPU_FRAGMENT_SHADER
+# define gl_FragCoord vec4(0.0)
+#endif
+
uniform sampler2D horizonBuffer;
/* aoSettings flags */
@@ -424,3 +428,34 @@ OcclusionData occlusion_load(vec3 vP, float custom_occlusion)
return data;
}
+
+#ifndef GPU_FRAGMENT_SHADER
+# undef gl_FragCoord
+#endif
+
+float ambient_occlusion_eval(vec3 normal,
+ float max_distance,
+ const float inverted,
+ const float sample_count)
+{
+ /* Avoid multiline define causing compiler issues. */
+ /* clang-format off */
+#if defined(GPU_FRAGMENT_SHADER) && (defined(MESH_SHADER) || defined(HAIR_SHADER)) && !defined(DEPTH_SHADER) && !defined(VOLUMETRICS)
+ /* clang-format on */
+ vec3 bent_normal;
+ vec4 rand = texelfetch_noise_tex(gl_FragCoord.xy);
+ OcclusionData data = occlusion_search(
+ viewPosition, maxzBuffer, max_distance, inverted, sample_count);
+
+ vec3 V = cameraVec(worldPosition);
+ vec3 N = normalize(normal);
+ vec3 Ng = safe_normalize(cross(dFdx(worldPosition), dFdy(worldPosition)));
+
+ float unused_error, visibility;
+ vec3 unused;
+ occlusion_eval(data, V, N, Ng, inverted, visibility, unused_error, unused);
+ return visibility;
+#else
+ return 1.0;
+#endif
+}