Commit: 33b6f944c673bf76de9d5ed955f0e6ab1fe10aac
Author: Brecht Van Lommel
Date:   Wed Feb 28 21:33:40 2018 +0100
Branches: blender2.8
https://developer.blender.org/rB33b6f944c673bf76de9d5ed955f0e6ab1fe10aac

Merge branch 'master' into blender2.8

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



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

diff --cc source/blender/gpu/shaders/gpu_shader_material.glsl
index 1269f81180c,1f5ffbdcc7e..602ca16b08d
--- a/source/blender/gpu/shaders/gpu_shader_material.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_material.glsl
@@@ -3028,130 -2795,16 +3028,131 @@@ void node_emission(vec4 color, float st
  
  void background_transform_to_world(vec3 viewvec, out vec3 worldvec)
  {
 -      vec4 v = (gl_ProjectionMatrix[3][3] == 0.0) ? vec4(viewvec, 1.0) : 
vec4(0.0, 0.0, 1.0, 1.0);
 -      vec4 co_homogenous = (gl_ProjectionMatrixInverse * v);
 +      vec4 v = (ProjectionMatrix[3][3] == 0.0) ? vec4(viewvec, 1.0) : 
vec4(0.0, 0.0, 1.0, 1.0);
 +      vec4 co_homogenous = (ProjectionMatrixInverse * v);
  
        vec4 co = vec4(co_homogenous.xyz / co_homogenous.w, 0.0);
 -      worldvec = (gl_ModelViewMatrixInverse * co).xyz;
 +#if defined(WORLD_BACKGROUND) || defined(PROBE_CAPTURE)
 +      worldvec = (ViewMatrixInverse * co).xyz;
 +#else
 +      worldvec = (ModelViewMatrixInverse * co).xyz;
 +#endif
 +}
 +
 +void node_background(vec4 color, float strength, out Closure result)
 +{
 +#ifndef VOLUMETRICS
 +      color *= strength;
 +#ifdef EEVEE_ENGINE
 +      result = CLOSURE_DEFAULT;
 +      result.radiance = color.rgb;
 +      result.opacity = color.a;
 +#else
 +      result = Closure(color.rgb, color.a);
 +#endif
 +#else
 +      result = CLOSURE_DEFAULT;
 +#endif
 +}
 +
 +/* volumes */
 +
 +void node_volume_scatter(vec4 color, float density, float anisotropy, out 
Closure result)
 +{
 +#ifdef VOLUMETRICS
 +      result = Closure(vec3(0.0), color.rgb * density, vec3(0.0), anisotropy);
 +#else
 +      result = CLOSURE_DEFAULT;
 +#endif
  }
  
 -void node_background(vec4 color, float strength, vec3 N, out vec4 result)
 +void node_volume_absorption(vec4 color, float density, out Closure result)
  {
 -      result = color * strength;
 +#ifdef VOLUMETRICS
 +      result = Closure((1.0 - color.rgb) * density, vec3(0.0), vec3(0.0), 
0.0);
 +#else
 +      result = CLOSURE_DEFAULT;
 +#endif
 +}
 +
 +void node_blackbody(float temperature, sampler2D spectrummap, out vec4 color)
 +{
 +    if(temperature >= 12000.0) {
 +        color = vec4(0.826270103, 0.994478524, 1.56626022, 1.0);
 +    }
 +    else if(temperature < 965.0) {
 +        color = vec4(4.70366907, 0.0, 0.0, 1.0);
 +    }
 +      else {
 +              float t = (temperature - 965.0) / (12000.0 - 965.0);
 +              color = vec4(texture(spectrummap, vec2(t, 0.0)).rgb, 1.0);
 +      }
 +}
 +
 +void node_volume_principled(
 +      vec4 color,
 +      float density,
 +      float anisotropy,
 +      vec4 absorption_color,
 +      float emission_strength,
 +      vec4 emission_color,
 +      float blackbody_intensity,
 +      vec4 blackbody_tint,
 +      float temperature,
 +      float density_attribute,
 +      vec4 color_attribute,
 +      float temperature_attribute,
 +      sampler2D spectrummap,
 +      out Closure result)
 +{
 +#ifdef VOLUMETRICS
 +      vec3 absorption_coeff = vec3(0.0);
 +      vec3 scatter_coeff = vec3(0.0);
 +      vec3 emission_coeff = vec3(0.0);
 +
 +      /* Compute density. */
 +      density = max(density, 0.0);
 +
 +      if(density > 1e-5) {
 +              density = max(density * density_attribute, 0.0);
 +      }
 +
 +      if(density > 1e-5) {
 +              /* Compute scattering and absorption coefficients. */
 +              vec3 scatter_color = color.rgb * color_attribute.rgb;
 +
 +              scatter_coeff = scatter_color * density;
++              absorption_color.rgb = sqrt(max(absorption_color.rgb, 0.0));
 +              absorption_coeff = max(1.0 - scatter_color, 0.0) * max(1.0 - 
absorption_color.rgb, 0.0) * density;
 +      }
 +
 +      /* Compute emission. */
 +      emission_strength = max(emission_strength, 0.0);
 +
 +      if(emission_strength > 1e-5) {
 +              emission_coeff += emission_strength * emission_color.rgb;
 +      }
 +
 +      if(blackbody_intensity > 1e-3) {
 +              /* Add temperature from attribute. */
 +              float T = max(temperature * max(temperature_attribute, 0.0), 
0.0);
 +
 +              /* Stefan-Boltzman law. */
 +              float T4 = (T * T) * (T * T);
 +              float sigma = 5.670373e-8 * 1e-6 / M_PI;
 +              float intensity = sigma * mix(1.0, T4, blackbody_intensity);
 +
 +              if(intensity > 1e-5) {
 +                      vec4 bb;
 +                      node_blackbody(T, spectrummap, bb);
 +                      emission_coeff += bb.rgb * blackbody_tint.rgb * 
intensity;
 +              }
 +      }
 +
 +      result = Closure(absorption_coeff, scatter_coeff, emission_coeff, 
anisotropy);
 +#else
 +      result = CLOSURE_DEFAULT;
 +#endif
  }
  
  /* closures */

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

Reply via email to