Refactor: combine insert_keyframe() and insert_key_rna() into a single function #122053

Merged
Nathan Vegdahl merged 49 commits from nathanvegdahl/blender:combine_keying_functions into main 2024-06-11 16:43:08 +02:00
144 changed files with 3453 additions and 1277 deletions
Showing only changes of commit a404f0d93e - Show all commits

View File

@ -222,7 +222,7 @@ draco::DataType getDataType(size_t componentType)
}
API(uint32_t)
encoderSetAttribute(Encoder *encoder, char *attributeName, size_t componentType, char *dataType, void *data)
encoderSetAttribute(Encoder *encoder, char *attributeName, size_t componentType, char *dataType, void *data, bool normalized)
{
auto buffer = std::make_unique<draco::DataBuffer>();
uint32_t count = encoder->mesh.num_points();
@ -232,7 +232,7 @@ encoderSetAttribute(Encoder *encoder, char *attributeName, size_t componentType,
draco::GeometryAttribute::Type semantics = getAttributeSemantics(attributeName);
draco::GeometryAttribute attribute;
attribute.Init(semantics, &*buffer, componentCount, getDataType(componentType), false, stride, 0);
attribute.Init(semantics, &*buffer, componentCount, getDataType(componentType), normalized, stride, 0);
auto id = static_cast<uint32_t>(encoder->mesh.AddAttribute(attribute, true, count));
auto dataBytes = reinterpret_cast<uint8_t *>(data);

View File

@ -53,7 +53,7 @@ API(void)
encoderSetIndices(Encoder *encoder, size_t indexComponentType, uint32_t indexCount, void *indices);
API(uint32_t)
encoderSetAttribute(Encoder *encoder, char *attributeName, size_t componentType, char *dataType, void *data);
encoderSetAttribute(Encoder *encoder, char *attributeName, size_t componentType, char *dataType, void *data, bool normalized);
API(uint32_t)
encoderGetEncodedVertexCount(Encoder *encoder);

View File

@ -142,11 +142,13 @@ ccl_device_inline float longitudinal_scattering(
if (v <= 0.1f) {
float i0 = log_bessel_I0(cos_arg);
float val = expf(i0 - sin_arg - inv_v + 0.6931f + logf(0.5f * inv_v));
kernel_assert(isfinite_safe(val));
return val;
}
else {
float i0 = bessel_I0(cos_arg);
float val = (expf(-sin_arg) * i0) / (sinhf(inv_v) * 2.0f * v);
kernel_assert(isfinite_safe(val));
return val;
}
}
@ -185,7 +187,7 @@ ccl_device int bsdf_hair_chiang_setup(ccl_private ShaderData *sd, ccl_private Ch
kernel_assert(isfinite_safe(bsdf->h));
bsdf->N = Y;
bsdf->alpha = -bsdf->alpha;
return SD_BSDF | SD_BSDF_HAS_EVAL | SD_BSDF_HAS_TRANSMISSION;
}
@ -224,9 +226,9 @@ ccl_device_inline void hair_attenuation(
Ap_energy[3] *= fac;
}
/* Given the tilt angle, generate the rotated theta_i for the different bounces. */
ccl_device_inline void hair_alpha_angles(float sin_theta_i,
float cos_theta_i,
/* Update sin_theta_o and cos_theta_o to account for scale tilt for each bounce. */
ccl_device_inline void hair_alpha_angles(float sin_theta_o,
float cos_theta_o,
float alpha,
ccl_private float *angles)
{
@ -237,12 +239,12 @@ ccl_device_inline void hair_alpha_angles(float sin_theta_i,
float sin_4alpha = 2.0f * sin_2alpha * cos_2alpha;
float cos_4alpha = sqr(cos_2alpha) - sqr(sin_2alpha);
angles[0] = sin_theta_i * cos_2alpha + cos_theta_i * sin_2alpha;
angles[1] = fabsf(cos_theta_i * cos_2alpha - sin_theta_i * sin_2alpha);
angles[2] = sin_theta_i * cos_1alpha - cos_theta_i * sin_1alpha;
angles[3] = fabsf(cos_theta_i * cos_1alpha + sin_theta_i * sin_1alpha);
angles[4] = sin_theta_i * cos_4alpha - cos_theta_i * sin_4alpha;
angles[5] = fabsf(cos_theta_i * cos_4alpha + sin_theta_i * sin_4alpha);
angles[0] = sin_theta_o * cos_2alpha - cos_theta_o * sin_2alpha;
angles[1] = fabsf(cos_theta_o * cos_2alpha + sin_theta_o * sin_2alpha);
angles[2] = sin_theta_o * cos_1alpha + cos_theta_o * sin_1alpha;
angles[3] = fabsf(cos_theta_o * cos_1alpha - sin_theta_o * sin_1alpha);
angles[4] = sin_theta_o * cos_4alpha + cos_theta_o * sin_4alpha;
angles[5] = fabsf(cos_theta_o * cos_4alpha - sin_theta_o * sin_4alpha);
}
/* Evaluation function for our shader. */
@ -293,17 +295,17 @@ ccl_device Spectrum bsdf_hair_chiang_eval(KernelGlobals kg,
const float phi = phi_i - phi_o;
float angles[6];
hair_alpha_angles(sin_theta_i, cos_theta_i, bsdf->alpha, angles);
hair_alpha_angles(sin_theta_o, cos_theta_o, bsdf->alpha, angles);
Spectrum F = zero_spectrum();
float F_energy = 0.0f;
/* Primary specular (R), Transmission (TT) and Secondary Specular (TRT). */
for (int i = 0; i < 3; i++) {
const float Mp = longitudinal_scattering(angles[2 * i],
const float Mp = longitudinal_scattering(sin_theta_i,
cos_theta_i,
angles[2 * i],
angles[2 * i + 1],
sin_theta_o,
cos_theta_o,
(i == 0) ? bsdf->m0_roughness :
(i == 1) ? 0.25f * bsdf->v :
4.0f * bsdf->v);
@ -347,6 +349,7 @@ ccl_device int bsdf_hair_chiang_sample(KernelGlobals kg,
kernel_assert(fabsf(dot(X, Y)) < 1e-3f);
const float3 Z = safe_normalize(cross(X, Y));
/* wo in pbrt. */
const float3 local_O = make_float3(dot(sd->wi, X), dot(sd->wi, Y), dot(sd->wi, Z));
const float sin_theta_o = local_O.x;
@ -387,19 +390,20 @@ ccl_device int bsdf_hair_chiang_sample(KernelGlobals kg,
v *= 4.0f;
}
float angles[6];
hair_alpha_angles(sin_theta_o, cos_theta_o, bsdf->alpha, angles);
float sin_theta_o_tilted = sin_theta_o;
float cos_theta_o_tilted = cos_theta_o;
if (p < 3) {
sin_theta_o_tilted = angles[2 * p];
cos_theta_o_tilted = angles[2 * p + 1];
}
rand.z = max(rand.z, 1e-5f);
const float fac = 1.0f + v * logf(rand.z + (1.0f - rand.z) * expf(-2.0f / v));
float sin_theta_i = -fac * sin_theta_o +
cos_from_sin(fac) * cosf(M_2PI_F * rand.y) * cos_theta_o;
float sin_theta_i = -fac * sin_theta_o_tilted +
sin_from_cos(fac) * cosf(M_2PI_F * rand.y) * cos_theta_o_tilted;
float cos_theta_i = cos_from_sin(sin_theta_i);
float angles[6];
if (p < 3) {
hair_alpha_angles(sin_theta_i, cos_theta_i, -bsdf->alpha, angles);
sin_theta_i = angles[2 * p];
cos_theta_i = angles[2 * p + 1];
}
float phi;
if (p < 3) {
phi = delta_phi(p, gamma_o, gamma_t) + sample_trimmed_logistic(rand.x, bsdf->s);
@ -409,17 +413,15 @@ ccl_device int bsdf_hair_chiang_sample(KernelGlobals kg,
}
const float phi_i = phi_o + phi;
hair_alpha_angles(sin_theta_i, cos_theta_i, bsdf->alpha, angles);
Spectrum F = zero_spectrum();
float F_energy = 0.0f;
/* Primary specular (R), Transmission (TT) and Secondary Specular (TRT). */
for (int i = 0; i < 3; i++) {
const float Mp = longitudinal_scattering(angles[2 * i],
const float Mp = longitudinal_scattering(sin_theta_i,
cos_theta_i,
angles[2 * i],
angles[2 * i + 1],
sin_theta_o,
cos_theta_o,
(i == 0) ? bsdf->m0_roughness :
(i == 1) ? 0.25f * bsdf->v :
4.0f * bsdf->v);

View File

@ -274,8 +274,8 @@ ccl_device void osl_closure_dielectric_bsdf_setup(KernelGlobals kg,
fresnel->reflection_tint = rgb_to_spectrum(closure->reflection_tint);
fresnel->transmission_tint = rgb_to_spectrum(closure->transmission_tint);
fresnel->thin_film.thickness = 0.0f;
fresnel->thin_film.ior = 0.0f;
fresnel->thin_film.thickness = closure->thinfilm_thickness;
fresnel->thin_film.ior = closure->thinfilm_ior;
bsdf_microfacet_setup_fresnel_dielectric_tint(kg, bsdf, sd, fresnel, preserve_energy);
if (layer_albedo != NULL) {
@ -425,8 +425,8 @@ ccl_device void osl_closure_generalized_schlick_bsdf_setup(
fresnel->f0 = rgb_to_spectrum(closure->f0);
fresnel->f90 = rgb_to_spectrum(closure->f90);
fresnel->exponent = closure->exponent;
fresnel->thin_film.thickness = 0.0f;
fresnel->thin_film.ior = 0.0f;
fresnel->thin_film.thickness = closure->thinfilm_thickness;
fresnel->thin_film.ior = closure->thinfilm_ior;
bsdf_microfacet_setup_fresnel_generalized_schlick(kg, bsdf, sd, fresnel, preserve_energy);
if (layer_albedo != NULL) {

View File

@ -54,6 +54,8 @@ OSL_CLOSURE_STRUCT_BEGIN(DielectricBSDF, dielectric_bsdf)
OSL_CLOSURE_STRUCT_MEMBER(DielectricBSDF, FLOAT, float, alpha_y, NULL)
OSL_CLOSURE_STRUCT_MEMBER(DielectricBSDF, FLOAT, float, ior, NULL)
OSL_CLOSURE_STRUCT_MEMBER(DielectricBSDF, STRING, DeviceString, distribution, NULL)
OSL_CLOSURE_STRUCT_MEMBER(DielectricBSDF, FLOAT, float, thinfilm_thickness, "thinfilm_thickness")
OSL_CLOSURE_STRUCT_MEMBER(DielectricBSDF, FLOAT, float, thinfilm_ior, "thinfilm_ior")
OSL_CLOSURE_STRUCT_END(DielectricBSDF, dielectric_bsdf)
OSL_CLOSURE_STRUCT_BEGIN(ConductorBSDF, conductor_bsdf)
@ -77,6 +79,9 @@ OSL_CLOSURE_STRUCT_BEGIN(GeneralizedSchlickBSDF, generalized_schlick_bsdf)
OSL_CLOSURE_STRUCT_MEMBER(GeneralizedSchlickBSDF, VECTOR, packed_float3, f90, NULL)
OSL_CLOSURE_STRUCT_MEMBER(GeneralizedSchlickBSDF, FLOAT, float, exponent, NULL)
OSL_CLOSURE_STRUCT_MEMBER(GeneralizedSchlickBSDF, STRING, DeviceString, distribution, NULL)
OSL_CLOSURE_STRUCT_MEMBER(
GeneralizedSchlickBSDF, FLOAT, float, thinfilm_thickness, "thinfilm_thickness")
OSL_CLOSURE_STRUCT_MEMBER(GeneralizedSchlickBSDF, FLOAT, float, thinfilm_ior, "thinfilm_ior")
OSL_CLOSURE_STRUCT_END(GeneralizedSchlickBSDF, generalized_schlick_bsdf)
OSL_CLOSURE_STRUCT_BEGIN(Microfacet, microfacet)

View File

@ -31,6 +31,8 @@ shader node_principled_bsdf(string distribution = "multi_ggx",
color EmissionColor = 1.0,
float EmissionStrength = 0.0,
float Alpha = 1.0,
float ThinFilmThickness = 0.0,
float ThinFilmIOR = 1.33,
normal Normal = N,
normal CoatNormal = N,
normal Tangent = normalize(dPdu),
@ -92,21 +94,33 @@ shader node_principled_bsdf(string distribution = "multi_ggx",
BSDF = mix(BSDF, clamped_base_color * SubsurfBSDF, subsurface_weight);
}
if (eta != 1.0) {
if (eta != 1.0 || ThinFilmThickness > 0.1) {
/* Apply specular tint */
color F0 = f0 * specular_tint;
color F90 = color(1.0);
BSDF = layer(
generalized_schlick_bsdf(
Normal, T, color(1.0), color(0.0), alpha_x, alpha_y, F0, F90, -eta, distribution),
BSDF);
BSDF = layer(generalized_schlick_bsdf(Normal,
T,
color(1.0),
color(0.0),
alpha_x,
alpha_y,
F0,
F90,
-eta,
distribution,
"thinfilm_thickness",
ThinFilmThickness,
"thinfilm_ior",
ThinFilmIOR),
BSDF);
}
}
closure color TransmissionBSDF = 0;
if (metallic < 1.0 && TransmissionWeight > CLOSURE_WEIGHT_CUTOFF) {
float eta = max(IOR, 1e-5);
float thinfilm_ior = backfacing() ? ThinFilmIOR / eta : ThinFilmIOR;
eta = backfacing() ? 1.0 / eta : eta;
color F0 = F0_from_ior(eta) * specular_tint;
@ -121,7 +135,11 @@ shader node_principled_bsdf(string distribution = "multi_ggx",
F0,
F90,
-eta,
distribution),
distribution,
"thinfilm_thickness",
ThinFilmThickness,
"thinfilm_ior",
thinfilm_ior),
BSDF = mix(BSDF, TransmissionBSDF, transmission);
}

@ -1 +1 @@
Subproject commit a5521c85e03bfd1556ff1e63bf7163235c401497
Subproject commit 62613b29fd2eb0d8ca84d86e6e57c0aa11548460

View File

@ -5,7 +5,7 @@
bl_info = {
'name': 'glTF 2.0 format',
'author': 'Julien Duroure, Scurest, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors',
"version": (4, 2, 39),
"version": (4, 2, 40),
'blender': (4, 2, 0),
'location': 'File > Import-Export',
'description': 'Import-Export as glTF 2.0',

View File

@ -34,7 +34,7 @@ def encode_scene_primitives(scenes, export_settings):
dll.encoderSetIndices.argtypes = [c_void_p, c_size_t, c_uint32, c_void_p]
dll.encoderSetAttribute.restype = c_uint32
dll.encoderSetAttribute.argtypes = [c_void_p, c_char_p, c_size_t, c_char_p, c_void_p]
dll.encoderSetAttribute.argtypes = [c_void_p, c_char_p, c_size_t, c_char_p, c_void_p, c_bool]
dll.encoderEncode.restype = c_bool
dll.encoderEncode.argtypes = [c_void_p, c_uint8]
@ -130,7 +130,8 @@ def __encode_primitive(primitive, dll, export_settings, encoded_primitives_cache
attr_name.encode(),
attr.component_type,
attr.type.encode(),
attr.buffer_view.data)
attr.buffer_view.data,
attr.normalized)
draco_ids[attr_name] = draco_id
dll.encoderSetIndices(encoder, indices.component_type, indices.count, indices.buffer_view.data)

View File

@ -8786,7 +8786,7 @@ def km_3d_view_tool_sculpt_gpencil_select_lasso(params):
def km_sequencer_editor_tool_generic_select_timeline_rcs(params, fallback):
return [
*_template_items_change_frame(params),
# Frame change can be cancelled if click happens on strip handle. In such case move the handle.
# Frame change can be canceled if click happens on strip handle. In such case move the handle.
("transform.seq_slide", {"type": 'LEFTMOUSE', "value": 'PRESS'},
{"properties": [("view2d_edge_pan", True)]}),
]

View File

@ -20,6 +20,7 @@ _modules = [
"file",
"geometry_nodes",
"image",
"image_as_planes",
"mesh",
"node",
"object",

File diff suppressed because it is too large Load Diff

View File

@ -160,8 +160,6 @@ class DATA_PT_EEVEE_light_shadow(DataButtonsPanel, Panel):
sub.active = light.use_shadow_jitter
sub.prop(light, "shadow_jitter_overblur", text="Overblur")
col.separator()
col = layout.column()
col.prop(light, "shadow_filter_radius", text="Filter")
@ -170,7 +168,6 @@ class DATA_PT_EEVEE_light_shadow(DataButtonsPanel, Panel):
row.prop(light, "shadow_maximum_resolution", text="Resolution Limit")
if light.type != 'SUN':
row.prop(light, "use_absolute_resolution", text="", icon='DRIVER_DISTANCE')
sub.prop(light, "shadow_resolution_scale", text="Scale")
class DATA_PT_EEVEE_light_influence(DataButtonsPanel, Panel):

View File

@ -574,8 +574,6 @@ class RENDER_PT_eevee_next_raytracing(RenderButtonsPanel, Panel):
col.prop(options, "resolution_scale")
col.prop(options, "trace_max_roughness", text="Max Roughness")
# TODO Move it to raytracing options
col.prop(props, "horizon_bias", text="Bias")
class RENDER_PT_eevee_next_screen_trace(RenderButtonsPanel, Panel):
@ -605,8 +603,8 @@ class RENDER_PT_eevee_next_screen_trace(RenderButtonsPanel, Panel):
col.prop(props, "screen_trace_thickness", text="Thickness")
class RENDER_PT_eevee_next_horizon_scan(RenderButtonsPanel, Panel):
bl_label = "Horizon Scan"
class RENDER_PT_eevee_next_gi_approximation(RenderButtonsPanel, Panel):
bl_label = "Fast GI Approximation"
bl_options = {'DEFAULT_CLOSED'}
bl_parent_id = "RENDER_PT_eevee_next_raytracing"
COMPAT_ENGINES = {'BLENDER_EEVEE_NEXT'}
@ -624,10 +622,15 @@ class RENDER_PT_eevee_next_horizon_scan(RenderButtonsPanel, Panel):
layout.use_property_split = True
layout.use_property_decorate = False
col = layout.column(align=True)
col.prop(props, "fast_gi_ray_count", text="Rays")
col.prop(props, "fast_gi_step_count", text="Steps")
col = layout.column()
col.prop(props, "horizon_quality", text="Precision")
col.prop(props, "horizon_thickness", text="Thickness")
col.prop(props, "horizon_resolution", text="Resolution")
col.prop(props, "horizon_bias", text="Bias")
class RENDER_PT_eevee_next_denoise(RenderButtonsPanel, Panel):
@ -775,9 +778,6 @@ class RENDER_PT_eevee_next_sampling_shadows(RenderButtonsPanel, Panel):
col.prop(props, "shadow_ray_count", text="Rays")
col.prop(props, "shadow_step_count", text="Steps")
col = layout.column()
col.prop(props, "shadow_resolution_scale", text="Resolution")
col = layout.column(align=False, heading="Volume Shadows")
row = col.row(align=True)
sub = row.row(align=True)
@ -786,6 +786,9 @@ class RENDER_PT_eevee_next_sampling_shadows(RenderButtonsPanel, Panel):
sub.active = props.use_volumetric_shadows
sub.prop(props, "volumetric_shadow_samples", text="Steps")
col = layout.column()
col.prop(props, "shadow_resolution_scale", text="Resolution")
class RENDER_PT_eevee_sampling(RenderButtonsPanel, Panel):
bl_label = "Sampling"
@ -1350,12 +1353,8 @@ classes = (
RENDER_PT_eevee_next_raytracing_presets,
RENDER_PT_eevee_next_raytracing,
RENDER_PT_eevee_next_screen_trace,
RENDER_PT_eevee_next_horizon_scan,
RENDER_PT_eevee_next_gi_approximation,
RENDER_PT_eevee_next_denoise,
RENDER_PT_simplify,
RENDER_PT_simplify_viewport,
RENDER_PT_simplify_render,
RENDER_PT_simplify_greasepencil,
RENDER_PT_eevee_motion_blur,
RENDER_PT_eevee_volumetric,
RENDER_PT_eevee_volumetric_lighting,
@ -1366,6 +1365,10 @@ classes = (
RENDER_PT_eevee_shadows,
RENDER_PT_eevee_indirect_lighting,
RENDER_PT_eevee_indirect_lighting_display,
RENDER_PT_simplify,
RENDER_PT_simplify_viewport,
RENDER_PT_simplify_render,
RENDER_PT_simplify_greasepencil,
RENDER_PT_eevee_depth_of_field,
RENDER_PT_eevee_next_depth_of_field,
RENDER_PT_eevee_next_motion_blur,

View File

@ -207,11 +207,23 @@ class EEVEE_WORLD_PT_sun_shadow(WorldButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
layout.use_property_split = True
world = context.world
layout.use_property_split = True
layout.prop(world, "sun_shadow_maximum_resolution", text="Resolution Limit")
col = layout.column(align=False, heading="Jitter")
row = col.row(align=True)
sub = row.row(align=True)
sub.prop(world, "use_sun_shadow_jitter", text="")
sub = sub.row(align=True)
sub.active = world.use_sun_shadow_jitter
sub.prop(world, "sun_shadow_jitter_overblur", text="Overblur")
col.separator()
col = layout.column()
col.prop(world, "sun_shadow_filter_radius", text="Filter")
col.prop(world, "sun_shadow_maximum_resolution", text="Resolution Limit")
class WORLD_PT_viewport_display(WorldButtonsPanel, Panel):

View File

@ -2852,6 +2852,7 @@ class VIEW3D_MT_image_add(Menu):
# auto detect which mode to use otherwise.
layout.operator("object.empty_image_add", text="Reference", icon='IMAGE_REFERENCE').background = False
layout.operator("object.empty_image_add", text="Background", icon='IMAGE_BACKGROUND').background = True
layout.operator("image.import_as_mesh_planes", text="Mesh Plane", icon='MESH_PLANE')
class VIEW3D_MT_object_relations(Menu):

View File

@ -29,7 +29,7 @@ extern "C" {
/* Blender file format version. */
#define BLENDER_FILE_VERSION BLENDER_VERSION
#define BLENDER_FILE_SUBVERSION 42
#define BLENDER_FILE_SUBVERSION 44
/* Minimum Blender version that supports reading file written with the current
* version. Older Blender versions will test this and cancel loading the file, showing a warning to

View File

@ -48,6 +48,20 @@ enum {
* data-blocks.
*/
IDTYPE_FLAGS_NO_MEMFILE_UNDO = 1 << 5,
/**
* Indicates that the given IDType is considered as unused.
*
* This is used for some 'root' ID types which typically do not have any actual user (WM.
* Scene...). It prevents e.g. their deletion through the 'Purge' operation.
*
* \note This applies to local IDs. Linked data should essentially ignore this flag. In practice,
* currently, only the Scene ID can be linked among the `never unused` types.
*
* \note The implementation of the expected behaviors related to this characteristic is somewhat
* fragile and inconsistent currently. In most case though, code is expected to ensure that such
* IDs have at least an 'extra user' (#LIB_TAG_EXTRAUSER).
*/
IDTYPE_FLAGS_NEVER_UNUSED = 1 << 6,
};
struct IDCacheKey {

View File

@ -302,17 +302,13 @@ bool BKE_image_is_stereo(const struct Image *ima);
/**
* Acquire render result associated with the give image.
*
* If the result is non a null pointer then the image is locking its render result part of
* operations, preventing other threads from modifying the result. It is then required to call
* #BKE_image_release_renderresult with the render result returned by this function.
* The returned render result is user-counted It is then required to call *
* #BKE_image_release_renderresult with the non-null render result returned by this function.
*
* It is allowed to call #BKE_image_release_renderresult with render_result of nullptr.
* It is possible to use ibuf acquire/release API while a render result is held.
*
* NOTE: It is not possible to use functions like #BKE_image_acquire_ibuf and
* #BKE_image_acquire_multilayer_view_ibuf as the same internal mutex as the image cache is used
* to protect the render result. When RenderResult is acquired, access image buffers directly from
* its passes, with user-increment when a more permanent reference is needed instead of the image
* buffer acquire/release functions.
* It is allowed to call #BKE_image_release_renderresult with render_result of nullptr, but it is
* not required.
*/
RenderResult *BKE_image_acquire_renderresult(Scene *scene, Image *ima);
void BKE_image_release_renderresult(Scene *scene, Image *ima, RenderResult *render_result);

View File

@ -123,6 +123,7 @@ void BKE_crazyspace_set_quats_editmesh(BMEditMesh *em,
float (*quats)[4],
const bool use_select)
{
using namespace blender;
BMFace *f;
BMIter iter;
int index;
@ -151,21 +152,20 @@ void BKE_crazyspace_set_quats_editmesh(BMEditMesh *em,
if (!BM_elem_flag_test(l_iter->v, BM_ELEM_TAG)) {
const float *co_prev, *co_curr, *co_next; /* orig */
const float *vd_prev, *vd_curr, *vd_next; /* deform */
const int i_prev = BM_elem_index_get(l_iter->prev->v);
const int i_curr = BM_elem_index_get(l_iter->v);
const int i_next = BM_elem_index_get(l_iter->next->v);
const int vert_prev = BM_elem_index_get(l_iter->prev->v);
const int vert = BM_elem_index_get(l_iter->v);
const int vert_next = BM_elem_index_get(l_iter->next->v);
/* Retrieve mapped coordinates. */
vd_prev = mappedcos[i_prev];
vd_curr = mappedcos[i_curr];
vd_next = mappedcos[i_next];
const float3 &vd_prev = mappedcos[vert_prev];
const float3 &vd_curr = mappedcos[vert];
const float3 &vd_next = mappedcos[vert_next];
if (has_origcos) {
co_prev = origcos[i_prev];
co_curr = origcos[i_curr];
co_next = origcos[i_next];
co_prev = origcos[vert_prev];
co_curr = origcos[vert];
co_next = origcos[vert_next];
}
else {
co_prev = l_iter->prev->v->co;
@ -173,7 +173,7 @@ void BKE_crazyspace_set_quats_editmesh(BMEditMesh *em,
co_next = l_iter->next->v->co;
}
set_crazy_vertex_quat(quats[i_curr], co_curr, co_next, co_prev, vd_curr, vd_next, vd_prev);
set_crazy_vertex_quat(quats[vert], co_curr, co_next, co_prev, vd_curr, vd_next, vd_prev);
BM_elem_flag_enable(l_iter->v, BM_ELEM_TAG);
}
@ -191,44 +191,32 @@ void BKE_crazyspace_set_quats_mesh(Mesh *mesh,
BitVector<> vert_tag(mesh->verts_num);
/* first store two sets of tangent vectors in vertices, we derive it just from the face-edges */
const Span<float3> positions = mesh->vert_positions();
const Span<float3> positions = origcos.is_empty() ? mesh->vert_positions() : origcos;
const OffsetIndices<int> faces = mesh->faces();
const Span<int> corner_verts = mesh->corner_verts();
const bool has_origcos = !origcos.is_empty();
for (const int i : faces.index_range()) {
const IndexRange face = faces[i];
for (const int corner : face) {
const int i_curr = corner_verts[corner];
if (vert_tag[i_curr]) {
const int vert = corner_verts[corner];
if (vert_tag[vert]) {
continue;
}
const int i_prev = corner_verts[mesh::face_corner_prev(face, corner)];
const int i_next = corner_verts[mesh::face_corner_next(face, corner)];
const int vert_prev = corner_verts[mesh::face_corner_prev(face, corner)];
const int vert_next = corner_verts[mesh::face_corner_next(face, corner)];
const float *co_prev, *co_curr, *co_next; /* orig */
const float *vd_prev, *vd_curr, *vd_next; /* deform */
const float3 &vd_prev = mappedcos[vert_prev];
const float3 &vd_curr = mappedcos[vert];
const float3 &vd_next = mappedcos[vert_next];
/* Retrieve mapped coordinates. */
vd_prev = mappedcos[i_prev];
vd_curr = mappedcos[i_curr];
vd_next = mappedcos[i_next];
const float3 &co_prev = positions[vert_prev];
const float3 &co_curr = positions[vert];
const float3 &co_next = positions[vert_next];
if (has_origcos) {
co_prev = origcos[i_prev];
co_curr = origcos[i_curr];
co_next = origcos[i_next];
}
else {
co_prev = positions[i_prev];
co_curr = positions[i_curr];
co_next = positions[i_next];
}
set_crazy_vertex_quat(quats[vert], co_curr, co_next, co_prev, vd_curr, vd_next, vd_prev);
set_crazy_vertex_quat(quats[i_curr], co_curr, co_next, co_prev, vd_curr, vd_next, vd_prev);
vert_tag[i_curr].set();
vert_tag[vert].set();
}
}
}

View File

@ -3842,15 +3842,23 @@ RenderResult *BKE_image_acquire_renderresult(Scene *scene, Image *ima)
image_init_multilayer_multiview(ima, rr);
}
if (!rr) {
BLI_mutex_unlock(static_cast<ThreadMutex *>(ima->runtime.cache_mutex));
if (rr) {
RE_ReferenceRenderResult(rr);
}
BLI_mutex_unlock(static_cast<ThreadMutex *>(ima->runtime.cache_mutex));
return rr;
}
void BKE_image_release_renderresult(Scene *scene, Image *ima, RenderResult *render_result)
{
if (render_result) {
/* Decrement user counter, and free if nobody else holds a reference to the result. */
BLI_mutex_lock(static_cast<ThreadMutex *>(ima->runtime.cache_mutex));
RE_FreeRenderResult(render_result);
BLI_mutex_unlock(static_cast<ThreadMutex *>(ima->runtime.cache_mutex));
}
if (ima->rr) {
/* pass */
}
@ -3859,10 +3867,6 @@ void BKE_image_release_renderresult(Scene *scene, Image *ima, RenderResult *rend
RE_ReleaseResult(RE_GetSceneRender(scene));
}
}
if (render_result) {
BLI_mutex_unlock(static_cast<ThreadMutex *>(ima->runtime.cache_mutex));
}
}
bool BKE_image_is_openexr(Image *ima)

View File

@ -753,7 +753,8 @@ static bool lib_query_unused_ids_tag_recurse(ID *id, UnusedIDsData &data)
return false;
}
if (ELEM(GS(id->name), ID_WM, ID_WS, ID_SCE, ID_SCR, ID_LI)) {
const IDTypeInfo *id_type = BKE_idtype_get_info_from_id(id);
if (id_type->flags & IDTYPE_FLAGS_NEVER_UNUSED) {
/* Some 'root' ID types are never unused (even though they may not have actual users), unless
* their actual user-count is set to 0. */
id_relations->tags |= MAINIDRELATIONS_ENTRY_TAGS_PROCESSED;

View File

@ -86,7 +86,8 @@ IDTypeInfo IDType_ID_LI = {
/*name*/ "Library",
/*name_plural*/ N_("libraries"),
/*translation_context*/ BLT_I18NCONTEXT_ID_LIBRARY,
/*flags*/ IDTYPE_FLAGS_NO_COPY | IDTYPE_FLAGS_NO_LIBLINKING | IDTYPE_FLAGS_NO_ANIMDATA,
/*flags*/ IDTYPE_FLAGS_NO_COPY | IDTYPE_FLAGS_NO_LIBLINKING | IDTYPE_FLAGS_NO_ANIMDATA |
IDTYPE_FLAGS_NEVER_UNUSED,
/*asset_type_info*/ nullptr,
/*init_data*/ nullptr,

View File

@ -1124,7 +1124,7 @@ static void object_get_datamask(const Depsgraph &depsgraph,
r_mask.fmask |= CD_MASK_MTFACE;
}
/* Check if we need mcols due to vertex paint or weight-paint. */
/* Check if we need loop-color due to vertex paint or weight-paint. */
if (ob.mode & OB_MODE_VERTEX_PAINT) {
r_mask.lmask |= CD_MASK_PROP_BYTE_COLOR;
}
@ -1194,9 +1194,8 @@ Mesh *mesh_get_eval_deform(Depsgraph *depsgraph,
* they aren't cleaned up properly on mode switch, causing crashes, e.g #58150. */
BLI_assert(ob->id.tag & LIB_TAG_COPIED_ON_EVAL);
/* if there's no derived mesh or the last data mask used doesn't include
* the data we need, rebuild the derived mesh
*/
/* If there's no evaluated mesh or the last data mask used doesn't include
* the data we need, rebuild the evaluated mesh. */
bool need_mapping;
CustomData_MeshMasks cddata_masks = *dataMask;
@ -1255,9 +1254,8 @@ Mesh *editbmesh_get_eval_cage(Depsgraph *depsgraph,
{
CustomData_MeshMasks cddata_masks = *dataMask;
/* if there's no derived mesh or the last data mask used doesn't include
* the data we need, rebuild the derived mesh
*/
/* If there's no evaluated mesh or the last data mask used doesn't include
* the data we need, rebuild the evaluated mesh. */
object_get_datamask(*depsgraph, *obedit, cddata_masks, nullptr);
if (!obedit->runtime->editmesh_eval_cage ||

View File

@ -1594,7 +1594,7 @@ constexpr IDTypeInfo get_type_info()
info.name = "Scene";
info.name_plural = "scenes";
info.translation_context = BLT_I18NCONTEXT_ID_SCENE;
info.flags = 0;
info.flags = IDTYPE_FLAGS_NEVER_UNUSED;
info.asset_type_info = nullptr;
info.init_data = scene_init_data;

View File

@ -168,7 +168,7 @@ IDTypeInfo IDType_ID_SCR = {
/*name_plural*/ N_("screens"),
/*translation_context*/ BLT_I18NCONTEXT_ID_SCREEN,
/*flags*/ IDTYPE_FLAGS_NO_COPY | IDTYPE_FLAGS_ONLY_APPEND | IDTYPE_FLAGS_NO_ANIMDATA |
IDTYPE_FLAGS_NO_MEMFILE_UNDO,
IDTYPE_FLAGS_NO_MEMFILE_UNDO | IDTYPE_FLAGS_NEVER_UNUSED,
/*asset_type_info*/ nullptr,
/*init_data*/ nullptr,

View File

@ -180,7 +180,7 @@ IDTypeInfo IDType_ID_WS = {
/*name_plural*/ N_("workspaces"),
/*translation_context*/ BLT_I18NCONTEXT_ID_WORKSPACE,
/*flags*/ IDTYPE_FLAGS_NO_COPY | IDTYPE_FLAGS_ONLY_APPEND | IDTYPE_FLAGS_NO_ANIMDATA |
IDTYPE_FLAGS_NO_MEMFILE_UNDO,
IDTYPE_FLAGS_NO_MEMFILE_UNDO | IDTYPE_FLAGS_NEVER_UNUSED,
/*asset_type_info*/ nullptr,
/*init_data*/ workspace_init_data,

View File

@ -3282,12 +3282,6 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain)
}
}
if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 11)) {
LISTBASE_FOREACH (Light *, light, &bmain->lights) {
light->shadow_resolution_scale = 1.0f;
}
}
if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 12)) {
FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
versioning_node_hue_correct_set_wrappng(ntree);
@ -3640,6 +3634,22 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain)
}
}
if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 43)) {
const World *default_world = DNA_struct_default_get(World);
LISTBASE_FOREACH (World *, world, &bmain->worlds) {
world->sun_shadow_maximum_resolution = default_world->sun_shadow_maximum_resolution;
world->sun_shadow_filter_radius = default_world->sun_shadow_filter_radius;
}
}
if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 44)) {
const Scene *default_scene = DNA_struct_default_get(Scene);
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
scene->eevee.fast_gi_step_count = default_scene->eevee.fast_gi_step_count;
scene->eevee.fast_gi_ray_count = default_scene->eevee.fast_gi_ray_count;
}
}
/**
* Always bump subversion in BKE_blender_version.h when adding versioning
* code here, and wrap it inside a MAIN_VERSION_FILE_ATLEAST check.

View File

@ -921,6 +921,7 @@ void BLO_update_defaults_startup_blend(Main *bmain, const char *app_template)
{
LISTBASE_FOREACH (Light *, light, &bmain->lights) {
light->shadow_maximum_resolution = 0.001f;
light->transmission_fac = 1.0f;
SET_FLAG_FROM_TEST(light->mode, false, LA_SHAD_RES_ABSOLUTE);
}
}

View File

@ -1311,10 +1311,11 @@ static bool write_file_handle(Main *mainvar,
/* We only write unused IDs in undo case. */
if (!wd->use_memfile) {
/* NOTE: All Scenes, WindowManagers and WorkSpaces should always be written to disk, so
* their user-count should never be zero currently. */
/* NOTE: All 'never unused' local IDs (Scenes, WindowManagers, ...) should always be
* written to disk, so their user-count should never be zero currently. Note that
* libraries have already been skipped above, as they need a specific handling. */
if (id->us == 0) {
BLI_assert(!ELEM(GS(id->name), ID_SCE, ID_WM, ID_WS));
BLI_assert((id_type->flags & IDTYPE_FLAGS_NEVER_UNUSED) == 0);
continue;
}

View File

@ -36,6 +36,9 @@ class MetaData {
const blender::StringRef value);
public:
/* The pixels in the result represents data, which is not to be color-managed. */
bool is_data = false;
void add(const blender::StringRef key, const blender::StringRef value);
/**
* Replace the hash neutral cryptomatte keys with hashed versions.
@ -45,8 +48,10 @@ class MetaData {
*/
void replace_hash_neutral_cryptomatte_keys(const blender::StringRef layer_name);
void add_to_render_result(RenderResult *render_result) const;
/* Invokes the given callback on each entry of the meta data. */
void for_each_entry(FunctionRef<void(const std::string &, const std::string &)> callback) const;
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("COM:MetaData")
#endif

View File

@ -13,7 +13,6 @@
#include "COM_MultilayerImageOperation.h"
#include "COM_RenderLayersProg.h"
#include "COM_SetAlphaMultiplyOperation.h"
#include "COM_SetAlphaReplaceOperation.h"
#include "COM_SetColorOperation.h"
namespace blender::compositor {
@ -52,7 +51,7 @@ void CryptomatteBaseNode::convert_to_operations(NodeConverter &converter,
converter.map_output_socket(output_image_socket, apply_mask_operation->get_output_socket(0));
NodeOutput *output_pick_socket = this->get_output_socket(2);
SetAlphaReplaceOperation *extract_pick_operation = new SetAlphaReplaceOperation();
CryptomattePickOperation *extract_pick_operation = new CryptomattePickOperation();
converter.add_operation(extract_pick_operation);
converter.add_input_value(extract_pick_operation->get_input_socket(1), 1.0f);
converter.add_link(cryptomatte_operation->get_output_socket(0),

View File

@ -60,4 +60,29 @@ void CryptomatteOperation::update_memory_buffer_partial(MemoryBuffer *output,
}
}
CryptomattePickOperation::CryptomattePickOperation()
{
this->add_input_socket(DataType::Color);
this->add_input_socket(DataType::Value);
this->add_output_socket(DataType::Color);
}
void CryptomattePickOperation::update_memory_buffer_partial(MemoryBuffer *output,
const rcti &area,
Span<MemoryBuffer *> inputs)
{
for (BuffersIterator<float> it = output->iterate_with(inputs, area); !it.is_end(); ++it) {
const float *color = it.in(0);
copy_v3_v3(it.out, color);
it.out[3] = 1.0f;
}
}
std::unique_ptr<MetaData> CryptomattePickOperation::get_meta_data()
{
std::unique_ptr<MetaData> meta_data = std::make_unique<MetaData>();
meta_data->is_data = true;
return meta_data;
}
} // namespace blender::compositor

View File

@ -26,4 +26,15 @@ class CryptomatteOperation : public MultiThreadedOperation {
Span<MemoryBuffer *> inputs) override;
};
class CryptomattePickOperation : public MultiThreadedOperation {
public:
CryptomattePickOperation();
void update_memory_buffer_partial(MemoryBuffer *output,
const rcti &area,
Span<MemoryBuffer *> inputs) override;
std::unique_ptr<MetaData> get_meta_data() override;
};
} // namespace blender::compositor

View File

@ -161,6 +161,25 @@ void ViewerOperation::update_memory_buffer_partial(MemoryBuffer * /*output*/,
update_image(&area);
}
void ViewerOperation::update_memory_buffer_finished(MemoryBuffer * /*output*/,
const rcti & /*area*/,
Span<MemoryBuffer *> /*inputs*/)
{
const std::unique_ptr<MetaData> meta_data =
this->get_input_socket(0)->get_reader()->get_meta_data();
if (meta_data && meta_data->is_data) {
image_->flag &= ~IMA_VIEW_AS_RENDER;
/* TODO: Assign image buffer's color space to either non-color or linear, to be fully correct
* about the content of the pixels. This needs to happen consistently with the GPU compositor,
* and also consistently with the ibuf_ acquired as a state of this operation (which is not
* always guaranteed to happen here. */
}
else {
image_->flag |= IMA_VIEW_AS_RENDER;
}
}
void ViewerOperation::clear_display_buffer()
{
BLI_assert(is_active_viewer_output());

View File

@ -82,6 +82,10 @@ class ViewerOperation : public MultiThreadedOperation {
const rcti &area,
Span<MemoryBuffer *> inputs) override;
void update_memory_buffer_finished(MemoryBuffer *output,
const rcti &area,
Span<MemoryBuffer *> inputs) override;
void clear_display_buffer();
private:

View File

@ -80,7 +80,7 @@ class Context {
/* Get the texture where the result of the compositor viewer should be written, given the domain
* of the result to be viewed. This should be called by viewer output nodes to get their target
* texture. */
virtual GPUTexture *get_viewer_output_texture(Domain domain) = 0;
virtual GPUTexture *get_viewer_output_texture(Domain domain, bool is_data) = 0;
/* Get the texture where the given render pass is stored. This should be called by the Render
* Layer node to populate its outputs. */

View File

@ -129,6 +129,9 @@ class Result {
bool is_external_ = false;
public:
/* The pixels in the result represents data, which is not to be color-managed. */
bool is_data = false;
/* Construct a result of the given type and precision with the given texture pool that will be
* used to allocate and release the result's texture. */
Result(ResultType type, TexturePool &texture_pool, ResultPrecision precision);

View File

@ -455,6 +455,8 @@ set(GLSL_SRC
engines/eevee_next/shaders/eevee_ambient_occlusion_pass_comp.glsl
engines/eevee_next/shaders/eevee_attributes_lib.glsl