forked from blender/blender
main sync #3
@ -149,7 +149,7 @@ ccl_device_inline void integrate_distant_lights(KernelGlobals kg,
|
||||
((ls.shader & SHADER_EXCLUDE_TRANSMIT) && (path_flag & PATH_RAY_TRANSMIT)) ||
|
||||
((ls.shader & SHADER_EXCLUDE_CAMERA) && (path_flag & PATH_RAY_CAMERA)) ||
|
||||
((ls.shader & SHADER_EXCLUDE_SCATTER) && (path_flag & PATH_RAY_VOLUME_SCATTER)))
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -159,7 +159,7 @@ ccl_device_inline void integrate_distant_lights(KernelGlobals kg,
|
||||
* generate a firefly for small lights since it is improbable. */
|
||||
const ccl_global KernelLight *klight = &kernel_data_fetch(lights, lamp);
|
||||
if (klight->use_caustics)
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
#endif /* __MNEE__ */
|
||||
|
||||
@ -169,7 +169,7 @@ ccl_device_inline void integrate_distant_lights(KernelGlobals kg,
|
||||
ccl_private ShaderData *emission_sd = AS_SHADER_DATA(&emission_sd_storage);
|
||||
Spectrum light_eval = light_sample_shader_eval(kg, state, emission_sd, &ls, ray_time);
|
||||
if (is_zero(light_eval)) {
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* MIS weighting. */
|
||||
|
@ -101,6 +101,7 @@ SSR_INTERFACE
|
||||
# if defined(USE_BARYCENTRICS) && !defined(HAIR_SHADER)
|
||||
vec3 barycentric_distances_get()
|
||||
{
|
||||
# if defined(GPU_OPENGL)
|
||||
/* NOTE: No need to undo perspective divide since it is not applied yet. */
|
||||
vec3 pos0 = (ProjectionMatrixInverse * gpu_position_at_vertex(0)).xyz;
|
||||
vec3 pos1 = (ProjectionMatrixInverse * gpu_position_at_vertex(1)).xyz;
|
||||
@ -119,6 +120,17 @@ vec3 barycentric_distances_get()
|
||||
d = dot(d10, edge21);
|
||||
dists.z = sqrt(dot(edge21, edge21) - d * d);
|
||||
return dists.xyz;
|
||||
# elif defined(GPU_METAL)
|
||||
/* Calculate Barycentric distances from available parameters in Metal. */
|
||||
float3 wp_delta = (length(dfdx(worldPosition.xyz)) + length(dfdy(worldPosition.xyz)));
|
||||
float3 bc_delta = (length(dfdx(gpu_BaryCoord)) + length(dfdy(gpu_BaryCoord)));
|
||||
float3 rate_of_change = wp_delta / bc_delta;
|
||||
vec3 dists;
|
||||
dists.x = length(rate_of_change * (1.0 - gpu_BaryCoord.x));
|
||||
dists.y = length(rate_of_change * (1.0 - gpu_BaryCoord.y));
|
||||
dists.z = length(rate_of_change * (1.0 - gpu_BaryCoord.z));
|
||||
return dists.xyz;
|
||||
# endif
|
||||
}
|
||||
# endif
|
||||
|
||||
|
@ -2039,24 +2039,16 @@ static bool gpencil_generic_stroke_select(bContext *C,
|
||||
/* init space conversion stuff */
|
||||
gpencil_point_conversion_init(C, &gsc);
|
||||
|
||||
/* Use only object transform matrix because all layer transformations are already included
|
||||
* in the evaluated stroke. */
|
||||
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
|
||||
Object *ob_eval = depsgraph != NULL ? DEG_get_evaluated_object(depsgraph, ob) : ob;
|
||||
float select_mat[4][4];
|
||||
copy_m4_m4(select_mat, ob_eval->object_to_world);
|
||||
|
||||
/* deselect all strokes first? */
|
||||
if (SEL_OP_USE_PRE_DESELECT(sel_op) || GPENCIL_PAINT_MODE(gpd)) {
|
||||
/* Set selection index to 0. */
|
||||
gpd->select_last_index = 0;
|
||||
|
||||
CTX_DATA_BEGIN (C, bGPDstroke *, gps, editable_gpencil_strokes) {
|
||||
bGPDspoint *pt;
|
||||
int i;
|
||||
|
||||
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
|
||||
pt->flag &= ~GP_SPOINT_SELECT;
|
||||
}
|
||||
|
||||
gps->flag &= ~GP_STROKE_SELECT;
|
||||
BKE_gpencil_stroke_select_index_reset(gps);
|
||||
}
|
||||
CTX_DATA_END;
|
||||
|
||||
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
|
||||
deselect_all_selected(C);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
@ -2071,9 +2063,9 @@ static bool gpencil_generic_stroke_select(bContext *C,
|
||||
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
|
||||
bGPDspoint *pt_active = (pt->runtime.pt_orig) ? pt->runtime.pt_orig : pt;
|
||||
|
||||
/* Convert point coords to screen-space. */
|
||||
const bool is_inside = is_inside_fn(
|
||||
gsc.region, gpstroke_iter.diff_mat, &pt_active->x, user_data);
|
||||
/* Convert point coords to screen-space. Needs to use the evaluated point
|
||||
* to consider modifiers. */
|
||||
const bool is_inside = is_inside_fn(gsc.region, select_mat, &pt->x, user_data);
|
||||
if (strokemode == false) {
|
||||
const bool is_select = (pt_active->flag & GP_SPOINT_SELECT) != 0;
|
||||
const int sel_op_result = ED_select_op_action_deselected(sel_op, is_select, is_inside);
|
||||
|
@ -1268,6 +1268,11 @@ bool MTLShader::generate_msl_from_glsl(const shader::ShaderCreateInfo *info)
|
||||
ss_fragment << "uint gl_PrimitiveID;" << std::endl;
|
||||
}
|
||||
|
||||
/* Global barycentrics. */
|
||||
if (msl_iface.uses_barycentrics) {
|
||||
ss_fragment << "vec3 gpu_BaryCoord;\n";
|
||||
}
|
||||
|
||||
/* Add Texture members. */
|
||||
for (const MSLTextureSampler &tex : msl_iface.texture_samplers) {
|
||||
if (bool(tex.stage & ShaderStage::FRAGMENT)) {
|
||||
@ -2036,33 +2041,7 @@ std::string MSLGeneratorInterface::generate_msl_fragment_entry_stub()
|
||||
|
||||
/* Barycentrics. */
|
||||
if (this->uses_barycentrics) {
|
||||
|
||||
/* Main barycentrics. */
|
||||
out << shader_stage_inst_name << ".gpu_BaryCoord = mtl_barycentric_coord.xyz;" << std::endl;
|
||||
|
||||
/* barycentricDist represents the world-space distance from the current world-space position
|
||||
* to the opposite edge of the vertex. */
|
||||
out << "float3 worldPos = " << shader_stage_inst_name << ".worldPosition.xyz;" << std::endl;
|
||||
out << "float3 wpChange = (length(dfdx(worldPos))+length(dfdy(worldPos)));" << std::endl;
|
||||
out << "float3 bcChange = "
|
||||
"(length(dfdx(mtl_barycentric_coord))+length(dfdy(mtl_barycentric_coord)));"
|
||||
<< std::endl;
|
||||
out << "float3 rateOfChange = wpChange/bcChange;" << std::endl;
|
||||
|
||||
/* Distance to edge using inverse barycentric value, as rather than the length of 0.7
|
||||
* contribution, we'd want the distance to the opposite side. */
|
||||
out << shader_stage_inst_name
|
||||
<< ".gpu_BarycentricDist.x = length(rateOfChange * "
|
||||
"(1.0-mtl_barycentric_coord.x));"
|
||||
<< std::endl;
|
||||
out << shader_stage_inst_name
|
||||
<< ".gpu_BarycentricDist.y = length(rateOfChange * "
|
||||
"(1.0-mtl_barycentric_coord.y));"
|
||||
<< std::endl;
|
||||
out << shader_stage_inst_name
|
||||
<< ".gpu_BarycentricDist.z = length(rateOfChange * "
|
||||
"(1.0-mtl_barycentric_coord.z));"
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
/* Populate Uniforms and uniform blocks. */
|
||||
|
Loading…
Reference in New Issue
Block a user