Page MenuHome

Fix T62422: Baking ray distance do not work.
ClosedPublic

Authored by Sebastian Parborg (zeddb) on May 14 2020, 4:05 PM.

Details

Summary

The previous naming scheme for the "selected to active" baking options lead to confusion and they were not describing what they actually did.

To remedy this, I've added a new settings that does what the older setting implied it did.

I do think I will have to provide a better description for the older settings and update the documentation.
At least for me, I feel that it is very hard to grasp what they are actually doing right now.

Dalai and Brecht, what do you think about this explanation for the cage_extrusion setting?

Old: Distance to use for the inward ray cast when using selected to active

New: The distance the ray starting position will be extruded/offset along the face normal

Now this might not be a better description either, but at least we have a starting point :)

Diff Detail

Repository
rB Blender

Event Timeline

Sebastian Parborg (zeddb) edited the summary of this revision. (Show Details)

The coding itself seems fine, can you just check with the bakers at the Blender Animation Studio (@Julien Kaspar (JulienKaspar) and @Andy Goralczyk (eyecandy) ) if they have anything to say in that regard? Also @Andy Davies (metalliandy) is my go-to baking expert, I would like to hear from him.

Also, elsewhere this is replaced by "blockers" in conjunction with cages. May be better to have the name reflect that: e.g., "Block Limit".

As for "Ray Distance / Ray Start Offset", what about just calling it "Extrusion" like we do for the cage?

source/blender/makesrna/intern/rna_scene.c
4894

I suggest the following tooltip: "Maximum ray length before excluding it from the baking result, unlimited if 0."

To me this seems reasonable functionality. I'm not sure how often it is needed, but I can imagine cases where you want to limit this distance.

Suggestions for names and descriptions.

Extrusion
Inflate the active object by the specified distance for baking. This helps matching to points nearer to the outside of the selected object meshes.

Max Distance
Limit distance for matching points between the active and select objects. If zero, there is no limit.

Brecht Van Lommel (brecht) requested changes to this revision.May 15 2020, 1:02 AM
This revision now requires changes to proceed.May 15 2020, 1:02 AM

I would not go with the "extrusion" - something "distance" is more commonly used.
Here are a few example from other applications: "Max Ray Distance" (3dsmax), "Max Frontal Distance" and "Max Back Distance" (Substance, two values actually), "Min Offset" and "Max Offset" (Marmoset, also two values) and "Search envelope" (Maya) and "Offset Distance" (Modo)

It depends on the context, but generally "distance" is the correct terminology for baking when using a uniform ray distance, as you are setting the distance the rays will travel before being cast back inward. Renaming it Max/Maximum Ray Distance is fine ofc., but I would say that "Extrusion" is correct when referring specifically to a cage, as you are inflating or extruding the mesh (either visible or in the BG) used for projection beyond its initial size. Distance has somewhat of a different meaning in cage baking as you are setting the cage size in order to control the ray distance (and sometimes direction), rather than setting the ray distance explicitly.

It's also very important to use separate terms for uniform ray distance baking vs cage baking as they are contrasting methods that produce very different results. Substance, for example, refers to distance only when not using a cage as the alternative method is a distance based ray cast (uniform ray distance) and the distance sliders are disabled when cage baking is enabled. For the vast majority of cases people shouldn't really be using ray distance based baking as it causes too many errors.

Generally this is how both features should work:

  • When using a uniform ray distance based ray casting method (no cage), rays are cast outwards along each vertex normal and then at the set distance they are cast back inwards. Where they intersect with the highpoly mesh, the normals are sampled and written.
  • When using a cage, rays are projected inward from the cage along the vertex normals and where they intersect with the highpoly mesh, the normals are sampled and written. Face normals shouldnt be used in this context, or ever for baking, as it would cause errors such as seams (similar to using no cage) due to gaps in the projection.

When setting a maximum distance, it should indeed set the maximum distance a ray can travel. It's common to use a ray-hit-furthest approach. If rays fail, then ray-hit-closest-double sided would be the next option.

I haven't seen the blockers patch/request, but if we are talking about separate meshes that kill rays when hit, they are usually very inefficient and increase render times (at least this was the case in xNormal), so it's generally not something I would reccomend that people use. It's easier and faster to make a custom cage much of the time.

A few points of note:

  1. I would be careful when using "extrude" in any other context other than when specifically referring to cages. "Inflate" is fine in this context too as you are referring to a cage, but rays are cast or shot, rather than extruded, right?
  2. We probably shouldn't be referring to rays as "baking rays" in the tooltips. A ray is just a ray. There isn't anything special about rays that requires them to be renamed in this context.
  3. When using a cage object, the "Extrusion" setting should really be disabled as you are already setting the ray distance limit by picking the object. Redundancy isn't really required in this situation. :)

I'm not sure the new tooltips actually clear anything up unfortunately. My suggestions would be the following, though @Brecht Van Lommel (brecht)'s are fine too.

  • Max Ray Distance: The Maximum distance rays will travel before being cast inwards to sample the high poly mesh. Zero is unlimited.
  • Extrude: The amount the projection cage will be inflated before casting rays inwards to sample the high poly mesh.

Cheers!

Sebastian Parborg (zeddb) updated this revision to Diff 24796.EditedMay 15 2020, 3:08 PM
When using a cage, the "Extrusion" setting should really be disabled as you are already setting the ray distance limit by picking the object. Redundancy isn't really required in this situation. :)

Right you are! The current code actually didn't use that value at all when a cage object was defined. So we should reflect this in the UI too. (Added this change to this patch).

However just one thing: From my tests and looking at the code, the cages doesn't seem to limit the rays in any way.
They only seem to modify the ray direction and start position.

I'm a bit confused as the method/algorithm you are describing doesn't seem to fully match what is happening under the hood in blender. But I might be missing something of course.

I've updated the descriptions based on the feedback given.

@Sebastian Parborg (zeddb) "[cages] only seem to modify the ray direction and start position" - that's correct, and that is what Andy said as well as far as I can tell.

From what I understand is that in common cases, you need all points on the active object to match some point on the selected object. In such cases having a hole in the texture map is not useful.

The reason you might use max distance for those cases would be as a kind of sanity check, to verify if matching points are found within a reasonable distance and then fix those problems.

There are other cases where holes in the texture map are fine, if you want to e.g. bake a wire fence onto a plane. And then some distance limit make sense.

intern/cycles/blender/addon/ui.py
1908

I would put this property at the bottom of the panel, since I think it's the least important one in practice.

Sebastian Parborg (zeddb) marked 2 inline comments as done.
This revision is now accepted and ready to land.May 15 2020, 7:33 PM

@Pablo Vazquez (pablovazquez)
I watched stream record. You thought it is bugfix.
Actually it is not fixing bug, but fixing/improving baking ray.
This fix will add new feature (max-ray-length) and make possible to bake perforated meshes to solid without artifacts.
So you can count it is a feature :)