Page MenuHome

Force Field Visualization and Debugging Tool
Needs ReviewPublic

Authored by Lukas Toenne (lukastoenne) on Jul 13 2015, 4:30 PM.

Details

Summary

Using force fields in Blender is a tedious and time-consuming process,
in large part because there is currently no way to display force fields
in the viewport. Artists and simulation specialists don't have any means
of estimating the effect of forces in the scene and adjust them
accordingly. Every use of a force field comes down to countless
iterations and experience.

The Force Visualization Modifier introduced in this patch provides a
platform for various kinds of display and visualization for force fields
and their effects. Using a modifier for this makes it integrate with
existing feature seamlessly and in a non-destructive way.

Currently two methods for display are implemented:

  • Field Lines are a typical tool used by physicists to represent fields. Each line is oriented in the direction of the field, while their density gives a relative measure of field strength.
  • Vertex Attributes can be used to store explicit numerical values at discrete points (vertices). These values can be field strength itself or any derived value (flux density, scalar strength, divergence, curl, etc.).

Other ways of displaying fields are imaginable, the modifier should make
it straightforward to integrate future methods.

Examples

Dipole Field (Lines display)

(FILE )

Vortex Field (Ribbons display)

(FILE )

Wind and Turbulence

(Tubes display)

(FILE )

Force Vector as a Vertex Attribute

(FILE )

Diff Detail

Repository
rB Blender
Branch
forceviz

Event Timeline

Lukas Toenne (lukastoenne) retitled this revision from to == Force Field Visualization and Debugging Tool ==.
Lukas Toenne (lukastoenne) updated this object.
Lukas Toenne (lukastoenne) retitled this revision from == Force Field Visualization and Debugging Tool == to Force Field Visualization and Debugging Tool.Jul 13 2015, 4:32 PM
Lukas Toenne (lukastoenne) updated this object.

Added missing force vector attribute output.

Gottfried Hofmann (gottfried) edited edge metadata.

This looks really useful. Need to find some time to compile again...

This revision is now accepted and ready to land.Jul 15 2015, 10:29 PM
Sergey Sharybin (sergey) requested changes to this revision.Jul 19 2015, 12:32 PM
Sergey Sharybin (sergey) edited edge metadata.

Quick review of Cycles side only for now.

@Lukas Toenne (lukastoenne), is it possible to maybe split the patch into smaller ones? Also, are you willing to address code review feedback or rather want someone else to do it?

Setting as a requested changes for now, because acceptance from @Gottfried Hofmann (gottfried) made the patch marked as ready for land, which is it obviously not yet.

intern/cycles/blender/blender_mesh.cpp
443

data++ ?

462

Use get_float3()

484

If nothing has changed in C++ RNA d->value(some_value) is a setter, not getter. If it's still the case i'm not sure what the code tries to do here.

release/scripts/startup/bl_operators/presets.py
89 ↗(On Diff #4640)

Usually silencing of all possible exceptions is rather really bad. Why do you need to have try-except block here and can the exception be more specialized?

This revision now requires changes to proceed.Jul 19 2015, 12:32 PM
Lukas Toenne (lukastoenne) edited edge metadata.

Fixed errors pointed out by Sergey.

intern/cycles/blender/blender_mesh.cpp
443

yes, no strong feelings here, changed it.

462

Right, changed these assignments.

484

Thanks for spotting this, i must have rushed through the copy/paste here ...
It copies from the CD layer iterator d to the data attribute, so my code is wrong.

release/scripts/startup/bl_operators/presets.py
89 ↗(On Diff #4640)

Oops, this commit shouldn't even be here, it's not used for the feature (will revert).

This is in fact the same code as in master, just moved to a separate function to make extension of preset writers possible. The intention is that the AddPresetBase class becomes easier to customize. Subclasses can reimplement the write_preset_py function if the simple key:value map is not sufficient.

@Sergey Sharybin (sergey) i suppose the CD layer extension could be made into a separate patch. But i'm afraid we would then want a "proper" scheme for handling arbitrary user CD layers, and how to expose these in the RNA without dozens of macros and thousands of lines of generated code for all possible variants. This is not so easy and could take a long time.

Also, the mesh sampling code could be its own patch, although i put an earlier version up for review a while ago and nothing happened. The mesh sampling code is something i keep using and improving in a number of branches, would be nice to have it official at some point.

Sorry for this, I just did not want to be in the way. Btw: Built it now - it works fine :)

Btw: Could you add vertex colors or weights to the ribbons? Since the direction is already denoted by the ribbon, you could just use abs(strength) of the force at each point. The max could either be set by the user in the UI (similar to how particle speed display can be customized) or you just use the max from all the points that are visualized...