Negative Vertex Map values
-
i use a vertext map to manipulate the motion blur in redshift from an object. positive directions are no problem, but the vertext map only seems to store positive values. manipulating it afterwards via python script didn't help either.
which surprises me in particular because the documentation mentions a float as the data type.
in other tools it is easily possible to use negative float values to create the desired effect.
-
Hey @pyr,
Thank you for reaching out to us. I am a bit perplexed by this topic, as there is no real question here.
The vertex maps of Cinema are usually defined in the closed interval
[0, 1]
(which is reflected as[0%, 100%]
for the end user). We could of course have also chosen the interval to be[-1, 1]
(standard interval), but we decided to go with the so-called half-standard-interval, that is just how it is.Not quite sure what to make out of your
float
comment. There is no such thing as aufloat
(unsigned float) in C because it does not make sense machine code wise. And you are on top of that here working with Python which does not really care about the whole unsigned concept in the first place (there is nouint
in Python).If you want this to be changed, then end-user-support would be the right place to ask this for. They can probably also help you with your Redshift-Motion-Blur-thing (which is not obviously clear to me and also not an SDK topic).
With all that being said, you can write values outside of that interval. It just might be that systems reading in such values might clamp them to the
[0, 1]
interval with is usually used. But there are some systems which also accept negative values. You would have to ask customer support about the details of the Redshift vertex map values.Because of it is ambivalent nature, I have moved this topic into General Talk.
Cheers,
FerdinandResult
Running the script twice: The negative values we wrote persist.
Code
"""Demonstrates writing values outside of the standard half-interval [0, 1] to a vertex map. """ import c4d from mxutils import CheckType doc: c4d.documents.BaseDocument # The currently active document. op: c4d.BaseObject | None # The primary selected object in `doc`. Can be `None`. def main() -> None: """Called by Cinema 4D when the script is being executed. """ # Makre sure the selected object is a polygon object and either get the existing vertex map tag # or create a new one. CheckType(op, c4d.PolygonObject) tag: c4d.VariableTag = CheckType(op.GetTag(c4d.Tvertexmap) or op.MakeVariableTag(c4d.Tvertexmap, op.GetPointCount())) # Get the vertex data from the tag and print the first 5 values. data: list[float] = tag.GetAllHighlevelData() print (data[:5 if len(data) > 5 else len(data)]) # Now set a gradient of values from -1 to 1 based on the x position of each point. for i, p in enumerate(op.GetAllPoints()): data[i] = c4d.utils.RangeMap(p.x, -250., 250., -1., 1., True) # Write the data back. tag.SetAllHighlevelData(data) tag.Message(c4d.MSG_UPDATE) c4d.EventAdd() if __name__ == '__main__': main()
-
-
hey,
found the error. works exactly as i had planned. my code was correct, but i forgot to switch off use fields on the new vertex i mapped.
thanks for the help anyway!