Page MenuHome

Geometry Nodes: Initial attribute interpolation between domains.
ClosedPublic

Authored by Jacques Lucke (JacquesLucke) on Feb 4 2021, 1:15 PM.

Details

Summary

The main immediate benefit of this patch in its current state is that (interpolated) uv coordinates are available on points without having to use the Point Distribute node.

This is also necessary for parts of T84297. E.g. if we want to access "vertex colors" on the point domain.

Diff Detail

Repository
rB Blender

Event Timeline

Jacques Lucke (JacquesLucke) requested review of this revision.Feb 4 2021, 1:15 PM
Jacques Lucke (JacquesLucke) created this revision.
  • better support for mixing some types
  • comments
  • Merge branch 'master' into attribute-domain-interpolation
  • comment
  • cleanup
Jacques Lucke (JacquesLucke) retitled this revision from Geometry Nodes: Initial attribute interpolation between domains (WIP). to Geometry Nodes: Initial attribute interpolation between domains..Feb 4 2021, 4:31 PM

Generally I like this approach. I think the "mixer" idea works. I could tell because I didn't find myself caring about how it was implemented when reading the code in attribute_access.cc.

It's going to be much nicer to work on T84297 now!

source/blender/blenkernel/BKE_attribute_math.hh
162

Seems like this could apply to the SimpleMixer as well? At least they could use the same approach.

218

This ::type idea seems pretty strange, but I'll just accept it as some C++ template goodness : )

I was curious so I tried the following, but got a "lambdas not allowed in this context", which makes sense I guess

using DefaultMixer<int> = SimpleMixerWithAccumulationType<int, double, [](const double &value) {
  return static_cast<int>(value);
}>;
243

At first I thought this was inconsistent with the implicit conversion we use elsewhere (== 0.0f). Now I'm not sure though.

source/blender/blenkernel/intern/attribute_access.cc
327

Another way of framing this is that the read attribute could become capable of owning its array, right? Seems a bit overkill at first to use a different class for this.
Might array_is_temporary_ and array_buffer_ be enough to implement this?
Maybe I'm missing something?

1811

Since there will be many of these functions-- thinking a bit on how to make them a bit shorter:

  • I don't think the component will be accessed here, maybe just use mesh as an argument. Unless you had a reason to do it this way.
  • Do the convert_to_static_type step outside of this function, in the caller.

Then we wouldn't need the separate impl function here. Maybe some of those generalizations won't apply to the other conversions though, not sure.

source/blender/blenkernel/BKE_attribute_math.hh
162

In SimpleMixer store the weights separately, because the buffer is already allocated by the calling code.

218

This ::type thing is fairly normal in C++, see https://en.cppreference.com/w/cpp/types/remove_cv for example.

You're idea isn't too bad, but yeah, it just doesn't work with the current C++ standard.

243

I think mixing 99 false and 1 true should result in false. This is consistent with the mix3 function above.

source/blender/blenkernel/intern/attribute_access.cc
327

Hm, this could be part of ArrayReadAttribute, but I'm not sure if it should. It would just make the memory management more manual.. Will think about it.

1811

Passing in the mesh instead of the component seems fine.

The main motivation I'm doing the convert_to_static_type here was to keep it's scope small (the larger it's scope, the more code is generated for every type). It does not make much of a difference here though. I think this is something we can refactor when we add more domain conversions. Then we'll have a better idea of what abstraction works best.

source/blender/blenkernel/BKE_attribute_math.hh
162

Ah right, of course.

243

Ah, that's what it is, it's different because it's a mix, not just one conversion

source/blender/blenkernel/intern/attribute_access.cc
1811

Okay, thanks for the explanation. Then for now just changing the argument to Mesh is probably best.

source/blender/blenkernel/intern/attribute_access.cc
1811

I agree, will do that tomorrow.

With the small changes discussed above I think this is ready to go. For the OwnedArrayReadAttribute, I don't have more to add besides that sometimes inheritance can be harder to understand than increase complexity in the base class. I trust you'll make the right decision though, since I haven't actually tried to change it.

This revision is now accepted and ready to land.Feb 8 2021, 9:37 PM