Commit: 711a50c5ea4de65be1512a1dbfa82b83ef993f56
Author: Brecht Van Lommel
Date:   Wed Jun 13 19:24:17 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB711a50c5ea4de65be1512a1dbfa82b83ef993f56

Merge branch 'master' into blender2.8

This includes making Eevee match Cycles behavior of inserting an emission
node when linking colors to closures.

===================================================================



===================================================================

diff --cc source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl
index a1890433b0f,00000000000..8b232bf14a4
mode 100644,000000..100644
--- a/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl
@@@ -1,841 -1,0 +1,855 @@@
 +
 +#define M_PI        3.14159265358979323846  /* pi */
 +#define M_2PI       6.28318530717958647692  /* 2*pi */
 +#define M_PI_2      1.57079632679489661923  /* pi/2 */
 +#define M_1_PI      0.318309886183790671538  /* 1/pi */
 +#define M_1_2PI     0.159154943091895335768  /* 1/(2*pi) */
 +#define M_1_PI2     0.101321183642337771443  /* 1/(pi^2) */
 +
 +#define LUT_SIZE 64
 +
 +/* Buffers */
 +uniform sampler2D colorBuffer;
 +uniform sampler2D depthBuffer;
 +uniform sampler2D maxzBuffer;
 +uniform sampler2D minzBuffer;
 +uniform sampler2DArray planarDepth;
 +
 +#define cameraForward   normalize(ViewMatrixInverse[2].xyz)
 +#define cameraPos       ViewMatrixInverse[3].xyz
 +#define cameraVec      ((ProjectionMatrix[3][3] == 0.0) ? normalize(cameraPos 
- worldPosition) : cameraForward)
 +#define viewCameraVec  ((ProjectionMatrix[3][3] == 0.0) ? 
normalize(-viewPosition) : vec3(0.0, 0.0, 1.0))
 +
 +/* ------- Structures -------- */
 +
 +/* ------ Lights ----- */
 +struct LightData {
 +      vec4 position_influence;      /* w : InfluenceRadius */
 +      vec4 color_spec;              /* w : Spec Intensity */
 +      vec4 spotdata_radius_shadow;  /* x : spot size, y : spot blend, z : 
radius, w: shadow id */
 +      vec4 rightvec_sizex;          /* xyz: Normalized up vector, w: area 
size X or spot scale X */
 +      vec4 upvec_sizey;             /* xyz: Normalized right vector, w: area 
size Y or spot scale Y */
 +      vec4 forwardvec_type;         /* xyz: Normalized forward vector, w: 
Lamp Type */
 +};
 +
 +/* convenience aliases */
 +#define l_color        color_spec.rgb
 +#define l_spec         color_spec.a
 +#define l_position     position_influence.xyz
 +#define l_influence    position_influence.w
 +#define l_sizex        rightvec_sizex.w
 +#define l_sizey        upvec_sizey.w
 +#define l_right        rightvec_sizex.xyz
 +#define l_up           upvec_sizey.xyz
 +#define l_forward      forwardvec_type.xyz
 +#define l_type         forwardvec_type.w
 +#define l_spot_size    spotdata_radius_shadow.x
 +#define l_spot_blend   spotdata_radius_shadow.y
 +#define l_radius       spotdata_radius_shadow.z
 +#define l_shadowid     spotdata_radius_shadow.w
 +
 +/* ------ Shadows ----- */
 +#ifndef MAX_CASCADE_NUM
 +#define MAX_CASCADE_NUM 4
 +#endif
 +
 +struct ShadowData {
 +      vec4 near_far_bias_exp;
 +      vec4 shadow_data_start_end;
 +      vec4 contact_shadow_data;
 +};
 +
 +struct ShadowCubeData {
 +      vec4 position;
 +};
 +
 +struct ShadowCascadeData {
 +      mat4 shadowmat[MAX_CASCADE_NUM];
 +      vec4 split_start_distances;
 +      vec4 split_end_distances;
 +};
 +
 +/* convenience aliases */
 +#define sh_near   near_far_bias_exp.x
 +#define sh_far    near_far_bias_exp.y
 +#define sh_bias   near_far_bias_exp.z
 +#define sh_exp    near_far_bias_exp.w
 +#define sh_bleed  near_far_bias_exp.w
 +#define sh_tex_start    shadow_data_start_end.x
 +#define sh_data_start   shadow_data_start_end.y
 +#define sh_multi_nbr    shadow_data_start_end.z
 +#define sh_blur         shadow_data_start_end.w
 +#define sh_contact_dist            contact_shadow_data.x
 +#define sh_contact_offset          contact_shadow_data.y
 +#define sh_contact_spread          contact_shadow_data.z
 +#define sh_contact_thickness       contact_shadow_data.w
 +
 +/* ------- Convenience functions --------- */
 +
 +vec3 mul(mat3 m, vec3 v) { return m * v; }
 +mat3 mul(mat3 m1, mat3 m2) { return m1 * m2; }
 +vec3 transform_direction(mat4 m, vec3 v) { return mat3(m) * v; }
 +vec3 transform_point(mat4 m, vec3 v) { return (m * vec4(v, 1.0)).xyz; }
 +vec3 project_point(mat4 m, vec3 v) {
 +      vec4 tmp = m * vec4(v, 1.0);
 +      return tmp.xyz / tmp.w;
 +}
 +
 +#define min3(a, b, c)                   min(a, min(b, c))
 +#define min4(a, b, c, d)                min(a, min3(b, c, d))
 +#define min5(a, b, c, d, e)             min(a, min4(b, c, d, e))
 +#define min6(a, b, c, d, e, f)          min(a, min5(b, c, d, e, f))
 +#define min7(a, b, c, d, e, f, g)       min(a, min6(b, c, d, e, f, g))
 +#define min8(a, b, c, d, e, f, g, h)    min(a, min7(b, c, d, e, f, g, h))
 +#define min9(a, b, c, d, e, f, g, h, i) min(a, min8(b, c, d, e, f, g, h, i))
 +
 +#define max3(a, b, c)                   max(a, max(b, c))
 +#define max4(a, b, c, d)                max(a, max3(b, c, d))
 +#define max5(a, b, c, d, e)             max(a, max4(b, c, d, e))
 +#define max6(a, b, c, d, e, f)          max(a, max5(b, c, d, e, f))
 +#define max7(a, b, c, d, e, f, g)       max(a, max6(b, c, d, e, f, g))
 +#define max8(a, b, c, d, e, f, g, h)    max(a, max7(b, c, d, e, f, g, h))
 +#define max9(a, b, c, d, e, f, g, h, i) max(a, max8(b, c, d, e, f, g, h, i))
 +
 +#define avg3(a, b, c)                   (a + b + c) * (1.0 / 3.0)
 +#define avg4(a, b, c, d)                (a + b + c + d) * (1.0 / 4.0)
 +#define avg5(a, b, c, d, e)             (a + b + c + d + e) * (1.0 / 5.0)
 +#define avg6(a, b, c, d, e, f)          (a + b + c + d + e + f) * (1.0 / 6.0)
 +#define avg7(a, b, c, d, e, f, g)       (a + b + c + d + e + f + g) * (1.0 / 
7.0)
 +#define avg8(a, b, c, d, e, f, g, h)    (a + b + c + d + e + f + g + h) * 
(1.0 / 8.0)
 +#define avg9(a, b, c, d, e, f, g, h, i) (a + b + c + d + e + f + g + h + i) * 
(1.0 / 9.0)
 +
 +float min_v2(vec2 v) { return min(v.x, v.y); }
 +float min_v3(vec3 v) { return min(v.x, min(v.y, v.z)); }
 +float max_v2(vec2 v) { return max(v.x, v.y); }
 +float max_v3(vec3 v) { return max(v.x, max(v.y, v.z)); }
 +
 +float sum(vec2 v) { return dot(vec2(1.0), v); }
 +float sum(vec3 v) { return dot(vec3(1.0), v); }
 +float sum(vec4 v) { return dot(vec4(1.0), v); }
 +
 +float saturate(float a) { return clamp(a, 0.0, 1.0); }
 +vec2 saturate(vec2 a) { return clamp(a, 0.0, 1.0); }
 +vec3 saturate(vec3 a) { return clamp(a, 0.0, 1.0); }
 +vec4 saturate(vec4 a) { return clamp(a, 0.0, 1.0); }
 +
 +float distance_squared(vec2 a, vec2 b) { a -= b; return dot(a, a); }
 +float distance_squared(vec3 a, vec3 b) { a -= b; return dot(a, a); }
 +float len_squared(vec3 a) { return dot(a, a); }
 +
 +float inverse_distance(vec3 V) { return max( 1 / length(V), 1e-8); }
 +
 +vec2 mip_ratio_interp(float mip) {
 +      float low_mip = floor(mip);
 +      return mix(mipRatio[int(low_mip)], mipRatio[int(low_mip + 1.0)], mip - 
low_mip);
 +}
 +
 +/* ------- RNG ------- */
 +
 +float wang_hash_noise(uint s)
 +{
 +      s = (s ^ 61u) ^ (s >> 16u);
 +      s *= 9u;
 +      s = s ^ (s >> 4u);
 +      s *= 0x27d4eb2du;
 +      s = s ^ (s >> 15u);
 +
 +      return fract(float(s) / 4294967296.0);
 +}
 +
 +/* ------- Fast Math ------- */
 +
 +/* [Drobot2014a] Low Level Optimizations for GCN */
 +float fast_sqrt(float v)
 +{
 +      return intBitsToFloat(0x1fbd1df5 + (floatBitsToInt(v) >> 1));
 +}
 +
 +vec2 fast_sqrt(vec2 v)
 +{
 +      return intBitsToFloat(0x1fbd1df5 + (floatBitsToInt(v) >> 1));
 +}
 +
 +/* [Eberly2014] GPGPU Programming for Games and Science */
 +float fast_acos(float v)
 +{
 +      float res = -0.156583 * abs(v) + M_PI_2;
 +      res *= fast_sqrt(1.0 - abs(v));
 +      return (v >= 0) ? res : M_PI - res;
 +}
 +
 +vec2 fast_acos(vec2 v)
 +{
 +      vec2 res = -0.156583 * abs(v) + M_PI_2;
 +      res *= fast_sqrt(1.0 - abs(v));
 +      v.x = (v.x >= 0) ? res.x : M_PI - res.x;
 +      v.y = (v.y >= 0) ? res.y : M_PI - res.y;
 +      return v;
 +}
 +
 +float point_plane_projection_dist(vec3 lineorigin, vec3 planeorigin, vec3 
planenormal)
 +{
 +      return dot(planenormal, planeorigin - lineorigin);
 +}
 +
 +float line_plane_intersect_dist(vec3 lineorigin, vec3 linedirection, vec3 
planeorigin, vec3 planenormal)
 +{
 +      return dot(planenormal, planeorigin - lineorigin) / dot(planenormal, 
linedirection);
 +}
 +
 +float line_plane_intersect_dist(vec3 lineorigin, vec3 linedirection, vec4 
plane)
 +{
 +      vec3 plane_co = plane.xyz * (-plane.w / len_squared(plane.xyz));
 +      vec3 h = lineorigin - plane_co;
 +      return -dot(plane.xyz, h) / dot(plane.xyz, linedirection);
 +}
 +
 +vec3 line_plane_intersect(vec3 lineorigin, vec3 linedirection, vec3 
planeorigin, vec3 planenormal)
 +{
 +      float dist = line_plane_intersect_dist(lineorigin, linedirection, 
planeorigin, planenormal);
 +      return lineorigin + linedirection * dist;
 +}
 +
 +vec3 line_plane_intersect(vec3 lineorigin, vec3 linedirection, vec4 plane)
 +{
 +      float dist = line_plane_intersect_dist(lineorigin, linedirection, 
plane);
 +      return lineorigin + linedirection * dist;
 +}
 +
 +float line_aligned_plane_intersect_dist(vec3 lineorigin, vec3 linedirection, 
vec3 planeorigin)
 +{
 +      /* aligned plane normal */
 +      vec3 L = planeorigin - lineorigin;
 +      float diskdist = length(L);
 +      vec3 planenormal = -normalize(L);
 +      return -diskdist / dot(planenormal, linedirection);
 +}
 +
 +vec3 line_aligned_plane_intersect(vec3 lineorigin, vec3 linedirection, vec3 
planeorigin)
 +{
 +      float dist = line_aligned_plane_intersect_dist(lineorigin, 
linedirection, planeorigin);
 +      if (dist < 0) {
 +              /* if intersection is behind we fake the intersection to be
 +               * really far and (hopefully) not inside the radius of interest 
*/
 +              dist = 1e16;
 +      }
 +      return lineorigin + linedirection * dist;
 +}
 +
 +float line_unit_sphere_intersect_dist(vec3 lineorigin, vec3 linedirection)
 +{
 +      float a = dot(linedirection, linedirection);
 +      float b = dot(linedirection, lineorigin);
 +      float c = dot(lineorigin, lineorigin) - 1;
 +
 +      float dist = 1e15;
 +      float determinant = b * b - a * c;
 +      if (determinant >= 0)
 +              dist = (sqrt(determinant) - b) / a;
 +
 +      return dist;
 +}
 +
 +float line_unit_box_intersect_dist(vec3 lineorigin, vec3 linedirection)
 +{
 +      /* 
https://seblagarde.wordpress.com/2012/09/29/image-based-lighting-approaches-and-parallax-corrected-cubemap/
 */
 +      vec3 firstplane  = (vec3( 1.0) - lineorigin) / linedirection;
 +      vec3 secondplane = (vec3(-1.0) - lineorigin) / linedirection;
 +      vec3 furthestplane = max(firstplane, secondplane);
 +
 +      return min_v3(furthestplane);
 +}
 +
 +
 +/* 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);
 +
 +      /*

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to