1
$\begingroup$

I am using a custom game engine (for which i want to create animated models for in blender) that supports animating the transparency of groups of triangles For example, there could be 6 groups of triangles for a character model

  1. head group that covers all the triangles that form the head
  2. torso group that covers all the triangles that form the torso
  3. same as above but for left hand
  4. same as above but for right hand
  5. same as above but for left leg
  6. same as above but for right leg

of course there could also be more groups, if more control was needed, e.g. just animating the transparency of the toes

My question is, what solutions are there in blender to achieve this? I know there are vertex groups which i suppose could be used in some way, however i think if i have triangles that share vertices (which i do in almost all cases) then this may affect other triangles not part of a specific group that im animating which i do not want, it needs to be per face/triangle rather than per vertex

I also don't mind a solution that involves some scripting/add-on

Edit: I will need a solution which i can export to my engines format, which uses a simple keyframe based system, where at each keyframe there is a list of transforms and a transform simply has a type (Translate, Rotate, Scale, Apply transparency), affected vertices or triangles (if type is Apply transparency) and the transform value itself (e.g. 90 degree rotation about x if the type was Rotate)

I am not using some common format to export this data that blender already supports, instead i want to write a script that exports the data i need in json (for example) and then i can process that json in my own program that does the conversion from blender to my engine, this is what i am already doing for exporting the mesh data, armature and animations and it works well for my use case

Engine animation format that i cannot modify:

Animation
  List of keyframes
    List of transforms

A transform consists of:

TransformType transform_type # [Translate, Rotate, Scale, Apply Alpha]
Bone affected_bone # the bone which the transformation is applied to
Vector3f transform # a 3D vector works because rotations use euler angles
$\endgroup$
2
  • $\begingroup$ The issue you are dealing with here is that, you need a solution that exists in Blender, but also in the game engine and the exchange format. I don't think there is any face-based data commonly supported, even vertex data isn't all equally the same everywhere. That being said, why not export your character model as separated meshes? Or have an image texture where each zone you want to control the alpha is a different flat color, and use that as a mask in your engine's material? $\endgroup$
    – Lauloque
    Commented Oct 26 at 14:21
  • $\begingroup$ The exchange format can be arbitrary, just json storing the data that i need would be enough, I've updated my post with some more information as well Can you explain more in detail how the image texture solution would work? @Lauloque $\endgroup$
    – Suic
    Commented Oct 27 at 3:33

2 Answers 2

1
$\begingroup$

Another approach is to create a Material Slot for each group of faces (head, torso, etc.). A unique Material can be assigned to each Material Slot. This will allow changing the transparency (and other properties) of the materials separately as shown in the screenshot below. Material Slots directly work with faces, and each face can only belong to one Material Slot. These requirements seem perfect for the given problem.

Material Slots

As shown in the following figure, the steps are:

  1. In the Material Slots list, click the add button.
  2. Switch to Edit Mode.
  3. Switch to Face Select.
  4. Select the faces.
  5. Assign the faces to the newly added material slot.
  6. Create a material and tweak its transparency.

Steps

$\endgroup$
2
  • $\begingroup$ yeah this solution is absolutely perfect, thank you $\endgroup$
    – Suic
    Commented Oct 28 at 2:57
  • $\begingroup$ You're welcome! $\endgroup$
    – Mr A
    Commented Oct 28 at 8:39
1
$\begingroup$

You can do this using Face Corner > Color attributes with a Geometry Nodes setup similar to the one shown below. Colors stored on Face Corners can be unique even for face corners sharing a vertex which sets them apart from Vertex Colors (vertex attributes in general).

Geometry Nodes

To paint the colors for the newly added face corner attribute:

  1. Switch to Vertex Paint mode.
  2. Enable Paint Mask.
  3. Select the faces that should be filled.
  4. Run Paint > Set Vertex Colors.

Steps

The result is shown below.

Result

Edit: If you would like to animate the transparency, the Geometry Nodes setup can be replaced with the following Shader Nodes setup. It uses the same attribute that was created above. The second Value slider of the Multiply node allows animating this effect where 0 represents fully opaque and 1 represents fully transparent.

Shader Nodes

$\endgroup$
4
  • $\begingroup$ But is that exportable outside of Blender? $\endgroup$
    – Lauloque
    Commented Oct 26 at 14:17
  • $\begingroup$ That depends on the export format and the capabilities of the engine. As far as I know, attributes can be exported, but custom material setups won't. Even if they are exported, they are unlikely to be imported by engines. The typical workflow involves manually setting up a similar material in the engine. The best way is to test. $\endgroup$
    – Mr A
    Commented Oct 26 at 18:11
  • $\begingroup$ This may work, but im not sure i quite understand it (i am still very new to blender and I've spent most of my time learning about its scripting API) could you please update your post that shows an example (preferably also include the resulting blend file if possible) of the simplest possible animation (2 face groups, can just pick any of the sides and then 1 keyframe that just change the alpha of the first group from 1 to 0.5 and the alpha of the second group from 1 to 0.1 for example, just has to be different) this would give me a better idea of whether this will work for me or not. $\endgroup$
    – Suic
    Commented Oct 27 at 3:50
  • 1
    $\begingroup$ I did figure it out now and this actually seems to be a pretty good solution, altho the shader graph/editor would get quite messy if i had say like 10 different color attributes (one for each hand, one for upper leg, lower leg, toes, head, torso etc) $\endgroup$
    – Suic
    Commented Oct 27 at 6:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .