Page MenuHome

Geometry Nodes: Fields Version of Raycast Node
ClosedPublic

Authored by Hans Goudey (HooglyBoogly) on Sep 25 2021, 10:21 PM.

Details

Summary

This patch includes an updated version of the raycast node that uses fields
instead of attributes.


The source position replaces the input geometry (since this node is
evaluated in the context of a geometry like the other field nodes).

Thanks to @Johnny Matthews (guitargeek) for an initial version of this patch!

Test Files:


Diff Detail

Repository
rB Blender

Event Timeline

Johnny Matthews (guitargeek) requested review of this revision.Sep 25 2021, 10:21 PM
Johnny Matthews (guitargeek) created this revision.

Added "Source Position" to signature

Still crashing:

Stack trace:
ucrtbased.dll!issue_debug_notification(const wchar_t * const message) Line 28
	at minkernel\crts\ucrt\src\appcrt\internal\report_runtime_error.cpp(28)
ucrtbased.dll!__acrt_report_runtime_error(const wchar_t * message) Line 154
	at minkernel\crts\ucrt\src\appcrt\internal\report_runtime_error.cpp(154)
ucrtbased.dll!abort() Line 61
	at minkernel\crts\ucrt\src\appcrt\startup\abort.cpp(61)
blender.exe!_BLI_assert_abort() Line 62
	at C:\blender-git\blender\source\blender\blenlib\intern\BLI_assert.c(62)
blender.exe!blender::Span<blender::fn::GField>::operator[](__int64 index) Line 247
	at C:\blender-git\blender\source\blender\blenlib\BLI_span.hh(247)
blender.exe!blender::fn::build_multi_function_procedure_for_fields(blender::fn::MFProcedure & procedure, blender::ResourceScope & scope, const blender::fn::FieldTreeInfo & field_tree_info, blender::Span<blender::fn::GFieldRef> output_fields) Line 204
	at C:\blender-git\blender\source\blender\functions\intern\field.cc(204)
blender.exe!blender::fn::evaluate_fields(blender::ResourceScope & scope, blender::Span<blender::fn::GFieldRef> fields_to_evaluate, blender::IndexMask mask, const blender::fn::FieldContext & context, blender::Span<blender::fn::GVMutableArray *> dst_varrays) Line 363
	at C:\blender-git\blender\source\blender\functions\intern\field.cc(363)
blender.exe!blender::fn::FieldEvaluator::evaluate() Line 665
	at C:\blender-git\blender\source\blender\functions\intern\field.cc(665)
blender.exe!blender::nodes::set_position_in_component(GeometryComponent & component, const blender::fn::Field<bool> & selection_field, const blender::fn::Field<blender::float3> & position_field) Line 48
	at C:\blender-git\blender\source\blender\nodes\geometry\nodes\node_geo_set_position.cc(48)
blender.exe!blender::nodes::geo_node_set_position_exec(blender::nodes::GeoNodeExecParams params) Line 65
	at C:\blender-git\blender\source\blender\nodes\geometry\nodes\node_geo_set_position.cc(65)
blender.exe!blender::modifiers::geometry_nodes::GeometryNodesEvaluator::execute_geometry_node(const blender::nodes::DNode node, blender::modifiers::geometry_nodes::NodeState & node_state) Line 891
	at C:\blender-git\blender\source\blender\modifiers\intern\MOD_nodes_evaluator.cc(891)
blender.exe!blender::modifiers::geometry_nodes::GeometryNodesEvaluator::execute_node(const blender::nodes::DNode node, blender::modifiers::geometry_nodes::NodeState & node_state) Line 865
	at C:\blender-git\blender\source\blender\modifiers\intern\MOD_nodes_evaluator.cc(865)
blender.exe!blender::modifiers::geometry_nodes::GeometryNodesEvaluator::node_task_run(const blender::nodes::DNode node, blender::modifiers::geometry_nodes::NodeState & node_state) Line 692
	at C:\blender-git\blender\source\blender\modifiers\intern\MOD_nodes_evaluator.cc(692)
blender.exe!blender::modifiers::geometry_nodes::GeometryNodesEvaluator::run_node_from_task_pool(TaskPool * task_pool, void * task_data) Line 674
	at C:\blender-git\blender\source\blender\modifiers\intern\MOD_nodes_evaluator.cc(674)
blender.exe!Task::operator()() Line 179
	at C:\blender-git\blender\source\blender\blenlib\intern\task_pool.cc(179)
blender.exe!tbb::internal::function_task<Task>::execute() Line 1060
	at C:\blender-git\lib\win64_vc15\tbb\include\tbb\task.h(1060)
[External Code]

Connect the circled link in this file

Some warnings: P2433.

source/blender/nodes/geometry/nodes/node_geo_raycast.cc
292

You have to pass the ray direction/length fields as input of the operation as well.

Johnny Matthews (guitargeek) edited the summary of this revision. (Show Details)

Working code for all but "Target Attribute" / "Hit Attribute" functionality

Johnny Matthews (guitargeek) marked an inline comment as done.Sep 26 2021, 8:45 PM
Johnny Matthews (guitargeek) added inline comments.
source/blender/nodes/geometry/nodes/node_geo_raycast.cc
292

You have to pass the ray direction/length fields as input of the operation as well.

Thank you, this comment made me realize that the inputs and outputs mentioned in the call() function are for the operation, not the node. This makes things much clearer to me!

source/blender/nodes/geometry/nodes/node_geo_raycast.cc
231

The mask can't be ignored. This results in a crash in the following setup.

I don't mind fixing this up later on, just wanted to let you know.

Johnny Matthews (guitargeek) marked an inline comment as done.
Johnny Matthews (guitargeek) edited the summary of this revision. (Show Details)

Update to use the mask correctly

  • Transfer attribute from target mesh
  • Cleanups
  • Fixes
Hans Goudey (HooglyBoogly) retitled this revision from Geometry Nodes: New Raycast Node (WIP) to Geometry Nodes: Fields Version of Raycast Node (WIP).Oct 12 2021, 9:37 PM
Jacques Lucke (JacquesLucke) requested changes to this revision.Oct 14 2021, 1:39 PM
Jacques Lucke (JacquesLucke) added inline comments.
source/blender/nodes/geometry/nodes/node_geo_raycast.cc
49

These dependent fields need to specify what inputs they depend on.

266

missing dot

271

Looks like this relies on the method implemented in another patch.

This revision now requires changes to proceed.Oct 14 2021, 1:39 PM
Hans Goudey (HooglyBoogly) marked 4 inline comments as done.
  • Add dependent field indices, fix small issues

I'm running into an issue where the virtual arrays retrieved from the evaluator in the multi-function
are not the same size. It's valid for one to be single and one to be a span, etc. but they should all have the same size.
No idea why yet.

It's valid for one to be single and one to be a span, etc. but they should all have the same size.

Didn't look at it in detail, but it may be valid that they don't have the same size if they are long enough (mask.min_array_size).

  • Fix issues with masks

Yeah, it turns out it was just that issue, but in multiple places.
I might commit some of the changes to masks here separately, since the
same issue might affect the attribute transfer node.

By the way, the result issue is a pretty ugly performance issue that we might have
to think more about in the future. The raycast node is being evaluated twice, once
for the selection, and then again for the attribute transfer. Hopefully the solution
to that can be generalized a bit.

Is this patch still WIP?
The raycast.blend file from the original post crashes when I open it.

Yes, I think we can be a bit smarter about not evaluating the node multiple times in the future.

  • Merge branch 'master' into geometry-nodes-raycast-fields-attribute-transfer
  • Don't fill is hit output if unnecessary
Hans Goudey (HooglyBoogly) retitled this revision from Geometry Nodes: Fields Version of Raycast Node (WIP) to Geometry Nodes: Fields Version of Raycast Node.Oct 19 2021, 1:02 AM
Hans Goudey (HooglyBoogly) edited the summary of this revision. (Show Details)
Hans Goudey (HooglyBoogly) edited the summary of this revision. (Show Details)
  • Properly ignore non-hit indices during attribute transfer (the old node didn't do this)
Jacques Lucke (JacquesLucke) added inline comments.
source/blender/nodes/geometry/nodes/node_geo_raycast.cc
203

typos (evaluate), space before Eventually

This revision is now accepted and ready to land.Oct 19 2021, 12:44 PM