Rendering deformed Spline with Hair material



  • Hi,

    I've always rendered my splines with Hair materials. After adding some custom modifiers, I simply cannot render anything anymore. Again, let's dive into old forum topics and start making tests to try and learn how things work.

    At first I learned that the relationship between GetContour() and GetVirtualObjects() has always been a hot topic, not mentioned anywhere in the docs. I discovered that by sending nullptr to GetVirtualObjects(), it will eventually try GetContour(). Because I have OBJECT_GENERATOR and OBJECT_ISSPLINE defined, to generate either a poly or a spline, based on parameters chosen by the user.

    About spline and deformers, here's what I discovered...

    • SplineObject returned by GetContour(): OK (rendered by Hair material)
    • SplineObject returned by GetVirtualObjects(): NOK (cannot be rendered by Hair material)
    • SplineObject returned by GetContour() + C4D Deformer (Twist): NOK
    • SplineObject returned by GetVirtualObjects() + C4D Deformer (Twist): NOK
    • SplineObject returned by GetContour() + custom Deformer: NOK
    • SplineObject returned by GetVirtualObjects() + custom Deformer: NOK
    • Native spline object (Circle) + C4D Deformer (Twist): NOK
    • Native spline object (Circle) + custom Deformer: NOK
    • C4D Hair + C4D Deformer (Twist): Can render, but not deformed
    • C4D Hair with the Deformers flag enabled + C4D Deformer (Twist): OK!!

    So... looks like the Hair material does not render modified splines. Why? Is that a limitation or a bug?

    But the C4D native hair has a Deformers flag that enables rendering of the deformed splines. How can it do it? I need that too!

    EDIT: Some curious findings about C4D Hair object...

    • When it has a deformer inside, instead of not rendering at all, it renders undeformed splines.
    • There's an option in the Hair object (Generate, Type) that when set to Spline, will not render hair (deformed or not).
    • There's actually nothing in the Hair Object cache looking at c4dsdk's Active Object Properties, unless we set it to Generate Splines. If it's not caching splines, then what?

  • Global Moderator

    Hi Roger,

    sorry come coming with a little bit of delay here, but actually the question was not that easy to address.

    The "Deformers" flag enabled in the Advanced tab of Cinema Hair actually execute something like:

    • create a dummy spline for each hair based on the hair definition
    • deform the dummy spline by applying the modifier stack found under the hair object
    • use the deformed spline data to overwrite the hair primitive

    What is important to note is that in the end what is actually rendered is still an hair primitive and not the deformed spline.
    As additional note the hairs are not represented in the scene as real geometry that's why you can't find any evidence in the Active Object Dialog since the hair renderer is not handling with 3D data but delivers a representation of hair in 2.5D space where geometry is not needed.
    Finally the primitives which can be currently rendered are those satisfying the following expression (obj is the object being evaluated by the hair renderer)

    obj->GetType() == HAIR_STYLE_OBJECT_ID || 
    obj->IsInstanceOf(Opolygon) || 
    obj->IsInstanceOf(Ospline) || 
    obj->IsInstanceOf(Oline)) || 
    obj->IsInstanceOf(Oparticle) || 
    obj->GetType() == ID_TP_PARTICLEGEOMETRY
    

    That said since I see no reason to deny deformed splines to be rendered by the hair renderer, I'm going to file a bug report on this regard.

    Best, Riccardo



  • Hi Riccardo,

    Thanks for the explanation.

    While a deformed spline primitive like the Circle will not render, if I make it editable, turning it into an Ospline, it will finally render. Both have a line object in the deform cache, so I don't understand what object is being checked.

    I really need to render custom deformed splines, if that's a bug I hope we can have it fixed soon. I tested back to R16 and the same happens. The hair solution you mentioned sounds like too much work just to render line objects that C4D is expected to render.


  • Global Moderator

    @rsodre said in Rendering deformed Spline with Hair material:

    While a deformed spline primitive like the Circle will not render, if I make it editable, turning it into an Ospline, it will finally render. Both have a line object in the deform cache, so I don't understand what object is being checked.

    Hi Roger, you've totally tackled the issue, both their caches contain LineObject but not their generator: the first (the circle primitive) returns fail when checking IsInstanceOf(Oline) and on IsInstanceOf(Ospline) the other instead return true on IsInstanceOf(Ospline).

    I'll let you know about the bug being fixed, but actually it's priority might be assessed as low.

    Best, Riccardo



  • But should a spline primitive like Circle return true on IsInstanceOf(Ospline)? Or is it returning false the expected behaviour?

    Is there a way to make my custom generator return true to IsInstanceOf(Ospline)?