diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2017-05-15 17:13:39 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2017-05-15 17:14:18 +0300 |
commit | c28a4eb8cb8c5abc3307c6a27b24ef274c72083c (patch) | |
tree | 0f8cccea522a2bb40a922222941a949d6f3b7c8e /source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl | |
parent | e053fade993204bbfaa98ced1b056e02226a3e61 (diff) |
Eevee: fix some glsl for low quality lamps.
Diffstat (limited to 'source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl')
-rw-r--r-- | source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl b/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl index ef8af646ec1..1954a2ad85d 100644 --- a/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl +++ b/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl @@ -5,6 +5,8 @@ #define M_1_2PI 0.159154943091895335768 /* 1/(2*pi) */ #define M_1_PI2 0.101321183642337771443 /* 1/(pi^2) */ +#define LUT_SIZE 64 + /* ------- Structures -------- */ struct LightData { @@ -127,6 +129,16 @@ vec3 line_aligned_plane_intersect(vec3 lineorigin, vec3 linedirection, vec3 plan return lineorigin + linedirection * dist; } +/* Return texture coordinates to sample Surface LUT */ +vec2 lut_coords(float cosTheta, float roughness) +{ + float theta = acos(cosTheta); + vec2 coords = vec2(roughness, theta / M_PI_2); + + /* scale and bias coordinates, for correct filtered lookup */ + return coords * (LUT_SIZE - 1.0) / LUT_SIZE + 0.5 / LUT_SIZE; +} + /* -- Tangent Space conversion -- */ vec3 tangent_to_world(vec3 vector, vec3 N, vec3 T, vec3 B) { |