Store Attribute data Over Time

   965   6   1
User Avatar
Member
21 posts
Joined: Oct. 2019
Offline
Hello everyone! Is it possible to keep an attribute with the last written value even when it is not being rewritten?

I have observed that when the attribute wrangle does not save that function for example due to a conditional, the attribute disappears.
I have a scene in which I need to save the position information over time to resume it later incrementally.

My intention is to increment an attribute intermittently, so that it grows without going back to zero when it is not being written.

I attach the scene with the example given in the detail attribute.

Attachments:
StoreDataOverTime.hipnc (173.7 KB)

User Avatar
Member
4677 posts
Joined: Feb. 2012
Offline
Hi,

For these situations, you have to use the Solver SOP to preserve history over time.
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
User Avatar
Member
21 posts
Joined: Oct. 2019
Offline
animatrix_
preserve history over time

I am honored by your response Yunus. I cannot get the attribute "pos" to grow procedurally at the pace of a caterpillar. Always forward but with pauses. I am trying to do it with Solver SOP. I sense that this is a key point to understand Houdini's logic. In any other environment you simply store the information in a variable. Here it seems to start from scratch every frame.
User Avatar
Member
4677 posts
Joined: Feb. 2012
Offline
You tried it like this?



If it's still not doing what you want, you might want to change the logic inside to have intermittent pauses.
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
User Avatar
Member
21 posts
Joined: Oct. 2019
Offline
Thank you very much Yunus for insisting on something so simple for you. The idea is to take the values ​​of a sin() function but only when it is growing between 0 and 1, with the objective of obtaining a variable "pos" that grows indefinitely in an intermittent manner, guided by the determined rhythm of the sin function. I would like to do it without depending on keyframes to understand this particular Houdini logic.
User Avatar
Member
117 posts
Joined: Dec. 2019
Offline
Hello,

Using the Solver SOP is of course the way to do what you are looking for, but the Attribute Wrangle inside is missing something to make it work as intended.

If you want to keep the previously written value, then you have to store it in a variable and return it when the "if" statement condition is not satisfied.


// get current pos attrib value
float pos = detail(0, "pos");

// initialize offset value to add to pos attrib
// when "if" statement is not satisfied then offset is 0 and will not affect pos attrib value
float offset = 0;

// sin function values are always between -1 and 1
// enter "if" statement only when sin value is between 0 and 1
float signal = sin(@Time * chf('speed'));
if (signal >= 0) {
    offset = chf('units') * signal;
}

setdetailattrib(0, "pos", pos + offset, "set");

Not sure why you need velocity from another geometry, you can find an example with velocity as well in the hip file.
Edited by ObeidaZakzak - Sept. 1, 2024 06:51:16

Attachments:
StoreDataOverTime.[suggestion].hipnc (213.1 KB)

Houdini Pipeline Supervisor @ TAT Studio
User Avatar
Member
21 posts
Joined: Oct. 2019
Offline
ObeidaZakzak
Hello,

Using the Solver SOP is of course the way to do what you are looking for, but the Attribute Wrangle inside is missing something to make it work as intended.

If you want to keep the previously written value, then you have to store it in a variable and return it when the "if" statement condition is not satisfied.


// get current pos attrib value
float pos = detail(0, "pos");

// initialize offset value to add to pos attrib
// when "if" statement is not satisfied then offset is 0 and will not affect pos attrib value
float offset = 0;

// sin function values are always between -1 and 1
// enter "if" statement only when sin value is between 0 and 1
float signal = sin(@Time * chf('speed'));
if (signal >= 0) {
    offset = chf('units') * signal;
}

setdetailattrib(0, "pos", pos + offset, "set");

Not sure why you need velocity from another geometry, you can find an example with velocity as well in the hip file.


This is exactly what I needed to understand Houdini's logic regarding the memory of variables!
Believe it or not, this opens up a world of possibilities for implementing ideas.
I believe you are a social benefactor operating within the jurisdiction of the galaxy.
Thank you very much for your help Obeida.
  • Quick Links