Merge branch 'blender-v3.3-release'

# Conflicts:
#	release/scripts/addons
This commit is contained in:
2022-09-02 18:28:46 +02:00
11 changed files with 83 additions and 8 deletions

View File

@@ -98,10 +98,11 @@ GlobalData init_globals(void)
# if defined(WORLD_BACKGROUND) || defined(PROBE_CAPTURE)
surf.P = transform_direction(ViewMatrixInverse, -viewCameraVec(viewPosition));
surf.N = surf.Ng = -surf.P;
surf.N = surf.Ng = surf.Ni = -surf.P;
surf.ray_length = 0.0;
# else
surf.P = worldPosition;
surf.Ni = worldNormal;
surf.N = safe_normalize(worldNormal);
surf.Ng = safe_normalize(cross(dFdx(surf.P), dFdy(surf.P)));
surf.ray_length = distance(surf.P, cameraPos);
@@ -123,7 +124,7 @@ GlobalData init_globals(void)
cos_theta = hairThickTime / hairThickness;
}
float sin_theta = sqrt(max(0.0, 1.0 - cos_theta * cos_theta));
surf.N = safe_normalize(worldNormal * sin_theta + B * cos_theta);
surf.N = surf.Ni = safe_normalize(worldNormal * sin_theta + B * cos_theta);
surf.curve_T = -hairTangent;
/* Costly, but follows cycles per pixel tangent space (not following curve shape). */
surf.curve_B = cross(V, surf.curve_T);

View File

@@ -40,7 +40,7 @@ void init_globals_curves()
/* Shade as a cylinder. */
float cos_theta = interp.curves_time_width / interp.curves_thickness;
float sin_theta = sqrt(max(0.0, 1.0 - cos_theta * cos_theta));
g_data.N = normalize(interp.N * sin_theta + interp.curves_binormal * cos_theta);
g_data.N = g_data.Ni = normalize(interp.N * sin_theta + interp.curves_binormal * cos_theta);
/* Costly, but follows cycles per pixel tangent space (not following curve shape). */
vec3 V = cameraVec(g_data.P);
@@ -67,6 +67,7 @@ void init_globals()
{
/* Default values. */
g_data.P = interp.P;
g_data.Ni = interp.N;
g_data.N = safe_normalize(interp.N);
g_data.Ng = g_data.N;
g_data.is_strand = false;

View File

@@ -77,12 +77,20 @@ typedef enum eGPUMaterialFlag {
GPU_MATFLAG_HOLDOUT = (1 << 6),
GPU_MATFLAG_SHADER_TO_RGBA = (1 << 7),
GPU_MATFLAG_AO = (1 << 8),
GPU_MATFLAG_CLEARCOAT = (1 << 9),
GPU_MATFLAG_OBJECT_INFO = (1 << 10),
GPU_MATFLAG_AOV = (1 << 11),
GPU_MATFLAG_BARYCENTRIC = (1 << 20),
/* Optimization to only add the branches of the principled shader that are necessary. */
GPU_MATFLAG_PRINCIPLED_CLEARCOAT = (1 << 21),
GPU_MATFLAG_PRINCIPLED_METALLIC = (1 << 22),
GPU_MATFLAG_PRINCIPLED_DIELECTRIC = (1 << 23),
GPU_MATFLAG_PRINCIPLED_GLASS = (1 << 24),
GPU_MATFLAG_PRINCIPLED_ANY = (1 << 25),
/* Tells the render engine the material was just compiled or updated. */
GPU_MATFLAG_UPDATED = (1 << 29),

View File

@@ -353,6 +353,24 @@ void GPUCodegen::generate_resources()
{
GPUCodegenCreateInfo &info = *create_info;
/* Ref. T98190: Defines are optimizations for old compilers.
* Might become unecessary with EEVEE-Next. */
if (GPU_material_flag_get(&mat, GPU_MATFLAG_PRINCIPLED_CLEARCOAT)) {
info.define("PRINCIPLED_CLEARCOAT");
}
if (GPU_material_flag_get(&mat, GPU_MATFLAG_PRINCIPLED_METALLIC)) {
info.define("PRINCIPLED_METALLIC");
}
if (GPU_material_flag_get(&mat, GPU_MATFLAG_PRINCIPLED_DIELECTRIC)) {
info.define("PRINCIPLED_DIELECTRIC");
}
if (GPU_material_flag_get(&mat, GPU_MATFLAG_PRINCIPLED_GLASS)) {
info.define("PRINCIPLED_GLASS");
}
if (GPU_material_flag_get(&mat, GPU_MATFLAG_PRINCIPLED_ANY)) {
info.define("PRINCIPLED_ANY");
}
std::stringstream ss;
/* Textures. */

View File

@@ -187,8 +187,10 @@ struct ClosureTransparency {
struct GlobalData {
/** World position. */
vec3 P;
/** Surface Normal. */
/** Surface Normal. Normalized, overriden by bump displacement. */
vec3 N;
/** Raw interpolated normal (non-normalized) data. */
vec3 Ni;
/** Geometric Normal. */
vec3 Ng;
/** Curve Tangent Space. */

View File

@@ -12,6 +12,16 @@ void node_attribute_temperature(vec4 attr, out vec4 out_attr)
out_attr.w = 1.0;
}
void node_attribute_density(vec4 attr, out float out_attr)
{
out_attr = attr.x;
}
void node_attribute_flame(vec4 attr, out float out_attr)
{
out_attr = attr.x;
}
void node_attribute(
vec4 attr, out vec4 outcol, out vec3 outvec, out float outf, out float outalpha)
{

View File

@@ -1,6 +1,6 @@
void node_displacement_object(float height, float midlevel, float scale, vec3 N, out vec3 result)
{
N = transform_direction(ModelMatrix, N);
N = transform_direction(ModelMatrixInverse, N);
result = (height - midlevel) * scale * normalize(N);
/* Apply object scale and orientation. */
result = transform_direction(ModelMatrix, result);

View File

@@ -3,13 +3,13 @@
void node_normal_map(vec4 tangent, vec3 texnormal, out vec3 outnormal)
{
if (all(equal(tangent, vec4(0.0, 0.0, 0.0, 1.0)))) {
outnormal = g_data.N;
outnormal = g_data.Ni;
return;
}
tangent *= (FrontFacing ? 1.0 : -1.0);
vec3 B = tangent.w * cross(g_data.N, tangent.xyz) * sign(ObjectInfo.w);
vec3 B = tangent.w * cross(g_data.Ni, tangent.xyz) * sign(ObjectInfo.w);
outnormal = texnormal.x * tangent.xyz + texnormal.y * B + texnormal.z * g_data.N;
outnormal = texnormal.x * tangent.xyz + texnormal.y * B + texnormal.z * g_data.Ni;
outnormal = normalize(outnormal);
}
#endif

View File

@@ -149,25 +149,37 @@ void node_bsdf_principled(vec4 base_color,
max(roughness, transmission_roughness);
refraction_data.ior = ior;
/* Ref. T98190: Defines are optimizations for old compilers.
* Might become unecessary with EEVEE-Next. */
if (do_diffuse == 0.0 && do_refraction == 0.0 && do_clearcoat != 0.0) {
#ifdef PRINCIPLED_CLEARCOAT
/* Metallic & Clearcoat case. */
result = closure_eval(reflection_data, clearcoat_data);
#endif
}
else if (do_diffuse == 0.0 && do_refraction == 0.0 && do_clearcoat == 0.0) {
#ifdef PRINCIPLED_METALLIC
/* Metallic case. */
result = closure_eval(reflection_data);
#endif
}
else if (do_diffuse != 0.0 && do_refraction == 0.0 && do_clearcoat == 0.0) {
#ifdef PRINCIPLED_DIELECTRIC
/* Dielectric case. */
result = closure_eval(diffuse_data, reflection_data);
#endif
}
else if (do_diffuse == 0.0 && do_refraction != 0.0 && do_clearcoat == 0.0) {
#ifdef PRINCIPLED_GLASS
/* Glass case. */
result = closure_eval(reflection_data, refraction_data);
#endif
}
else {
#ifdef PRINCIPLED_ANY
/* Un-optimized case. */
result = closure_eval(diffuse_data, reflection_data, clearcoat_data, refraction_data);
#endif
}
Closure emission_cl = closure_eval(emission_data);
Closure transparency_cl = closure_eval(transparency_data);

View File

@@ -167,6 +167,27 @@ static int node_shader_gpu_bsdf_principled(GPUMaterial *mat,
if (use_transparency) {
flag |= GPU_MATFLAG_TRANSPARENT;
}
if (use_clear) {
flag |= GPU_MATFLAG_CLEARCOAT;
}
/* Ref. T98190: Defines are optimizations for old compilers.
* Might become unecessary with EEVEE-Next. */
if (use_diffuse == false && use_refract == false && use_clear == true) {
flag |= GPU_MATFLAG_PRINCIPLED_CLEARCOAT;
}
else if (use_diffuse == false && use_refract == false && use_clear == false) {
flag |= GPU_MATFLAG_PRINCIPLED_METALLIC;
}
else if (use_diffuse == true && use_refract == false && use_clear == false) {
flag |= GPU_MATFLAG_PRINCIPLED_DIELECTRIC;
}
else if (use_diffuse == false && use_refract == true && use_clear == false) {
flag |= GPU_MATFLAG_PRINCIPLED_GLASS;
}
else {
flag |= GPU_MATFLAG_PRINCIPLED_ANY;
}
if (use_subsurf) {
bNodeSocket *socket = (bNodeSocket *)BLI_findlink(&node->original->inputs, 2);

View File

@@ -25,9 +25,11 @@ static int node_shader_gpu_volume_info(GPUMaterial *mat,
}
if (out[1].hasoutput) {
out[1].link = GPU_attribute(mat, CD_AUTO_FROM_NAME, "density");
GPU_link(mat, "node_attribute_density", out[1].link, &out[1].link);
}
if (out[2].hasoutput) {
out[2].link = GPU_attribute(mat, CD_AUTO_FROM_NAME, "flame");
GPU_link(mat, "node_attribute_flame", out[2].link, &out[2].link);
}
if (out[3].hasoutput) {
out[3].link = GPU_attribute(mat, CD_AUTO_FROM_NAME, "temperature");