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/bsdf_sampling_lib.glsl')
-rw-r--r--source/blender/draw/engines/eevee/shaders/bsdf_sampling_lib.glsl80
1 files changed, 40 insertions, 40 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/bsdf_sampling_lib.glsl b/source/blender/draw/engines/eevee/shaders/bsdf_sampling_lib.glsl
index cce9d59dc12..5f2b719095e 100644
--- a/source/blender/draw/engines/eevee/shaders/bsdf_sampling_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/bsdf_sampling_lib.glsl
@@ -7,34 +7,34 @@ uniform float invSampleCount;
vec2 jitternoise = vec2(0.0);
#ifndef UTIL_TEX
-#define UTIL_TEX
+# define UTIL_TEX
uniform sampler2DArray utilTex;
-#define texelfetch_noise_tex(coord) texelFetch(utilTex, ivec3(ivec2(coord) % LUT_SIZE, 2.0), 0)
+# define texelfetch_noise_tex(coord) texelFetch(utilTex, ivec3(ivec2(coord) % LUT_SIZE, 2.0), 0)
#endif /* UTIL_TEX */
void setup_noise(void)
{
- jitternoise = texelfetch_noise_tex(gl_FragCoord.xy).rg; /* Global variable */
+ jitternoise = texelfetch_noise_tex(gl_FragCoord.xy).rg; /* Global variable */
}
#ifdef HAMMERSLEY_SIZE
vec3 hammersley_3d(float i, float invsamplenbr)
{
- vec3 Xi; /* Theta, cos(Phi), sin(Phi) */
+ vec3 Xi; /* Theta, cos(Phi), sin(Phi) */
- Xi.x = i * invsamplenbr; /* i/samples */
- Xi.x = fract(Xi.x + jitternoise.x);
+ Xi.x = i * invsamplenbr; /* i/samples */
+ Xi.x = fract(Xi.x + jitternoise.x);
- int u = int(mod(i + jitternoise.y * HAMMERSLEY_SIZE, HAMMERSLEY_SIZE));
+ int u = int(mod(i + jitternoise.y * HAMMERSLEY_SIZE, HAMMERSLEY_SIZE));
- Xi.yz = texelFetch(texHammersley, u, 0).rg;
+ Xi.yz = texelFetch(texHammersley, u, 0).rg;
- return Xi;
+ return Xi;
}
vec3 hammersley_3d(float i)
{
- return hammersley_3d(i, invSampleCount);
+ return hammersley_3d(i, invSampleCount);
}
#endif
@@ -42,66 +42,66 @@ vec3 hammersley_3d(float i)
float pdf_ggx_reflect(float NH, float a2)
{
- return NH * a2 / D_ggx_opti(NH, a2);
+ return NH * a2 / D_ggx_opti(NH, a2);
}
float pdf_hemisphere()
{
- return 0.5 * M_1_PI;
+ return 0.5 * M_1_PI;
}
vec3 sample_ggx(vec3 rand, float a2)
{
- /* Theta is the aperture angle of the cone */
- float z = sqrt( (1.0 - rand.x) / ( 1.0 + a2 * rand.x - rand.x ) ); /* cos theta */
- float r = sqrt(max(0.0, 1.0f - z*z)); /* sin theta */
- float x = r * rand.y;
- float y = r * rand.z;
-
- /* Microfacet Normal */
- return vec3(x, y, z);
+ /* Theta is the aperture angle of the cone */
+ float z = sqrt((1.0 - rand.x) / (1.0 + a2 * rand.x - rand.x)); /* cos theta */
+ float r = sqrt(max(0.0, 1.0f - z * z)); /* sin theta */
+ float x = r * rand.y;
+ float y = r * rand.z;
+
+ /* Microfacet Normal */
+ return vec3(x, y, z);
}
vec3 sample_ggx(vec3 rand, float a2, vec3 N, vec3 T, vec3 B, out float NH)
{
- vec3 Ht = sample_ggx(rand, a2);
- NH = Ht.z;
- return tangent_to_world(Ht, N, T, B);
+ vec3 Ht = sample_ggx(rand, a2);
+ NH = Ht.z;
+ return tangent_to_world(Ht, N, T, B);
}
#ifdef HAMMERSLEY_SIZE
vec3 sample_ggx(float nsample, float a2, vec3 N, vec3 T, vec3 B)
{
- vec3 Xi = hammersley_3d(nsample);
- vec3 Ht = sample_ggx(Xi, a2);
- return tangent_to_world(Ht, N, T, B);
+ vec3 Xi = hammersley_3d(nsample);
+ vec3 Ht = sample_ggx(Xi, a2);
+ return tangent_to_world(Ht, N, T, B);
}
vec3 sample_hemisphere(float nsample, vec3 N, vec3 T, vec3 B)
{
- vec3 Xi = hammersley_3d(nsample);
+ vec3 Xi = hammersley_3d(nsample);
- float z = Xi.x; /* cos theta */
- float r = sqrt(max(0.0, 1.0f - z*z)); /* sin theta */
- float x = r * Xi.y;
- float y = r * Xi.z;
+ float z = Xi.x; /* cos theta */
+ float r = sqrt(max(0.0, 1.0f - z * z)); /* sin theta */
+ float x = r * Xi.y;
+ float y = r * Xi.z;
- vec3 Ht = vec3(x, y, z);
+ vec3 Ht = vec3(x, y, z);
- return tangent_to_world(Ht, N, T, B);
+ return tangent_to_world(Ht, N, T, B);
}
vec3 sample_cone(float nsample, float angle, vec3 N, vec3 T, vec3 B)
{
- vec3 Xi = hammersley_3d(nsample);
+ vec3 Xi = hammersley_3d(nsample);
- float z = cos(angle * Xi.x); /* cos theta */
- float r = sqrt(max(0.0, 1.0f - z*z)); /* sin theta */
- float x = r * Xi.y;
- float y = r * Xi.z;
+ float z = cos(angle * Xi.x); /* cos theta */
+ float r = sqrt(max(0.0, 1.0f - z * z)); /* sin theta */
+ float x = r * Xi.y;
+ float y = r * Xi.z;
- vec3 Ht = vec3(x, y, z);
+ vec3 Ht = vec3(x, y, z);
- return tangent_to_world(Ht, N, T, B);
+ return tangent_to_world(Ht, N, T, B);
}
#endif