neverhood311 / Stop-motion-OBJ

A Blender add-on for importing a sequence of OBJ meshes as frames
GNU General Public License v3.0
687 stars 52 forks source link

Automatically assigning vertex colour data specific to each step in the sequence #107

Open kryspyb opened 4 years ago

kryspyb commented 4 years ago

When importing .PLY data from Paraview using the plugin, it would be really useful to assign the vertex colour to render to using Nodes to all files automatically (this could be my lack of knowledge of blender though!).

neverhood311 commented 4 years ago

I don't think I fully understand your use-case.

It sounds like you have a sequence of .PLY files and they each have vertex color data. Are you trying to render each object with the vertex color data visible?

If so, are you able to do it importing a single mesh into Blender?

kryspyb commented 4 years ago

Hello, thanks for replying. I think you have understood correctly, I would like to render each file with the vertex color visible by default. The PLY files are exports from a time stepped CFD simulation, so each file would need its own unique vertex colour associated. I don't think it will work as a single mesh, as I'm trying to output it using blend4web/aframe.

neverhood311 commented 4 years ago

Right, I don't mean to treat it as a single mesh. One of the first approaches to debugging issues with mesh sequences is to make sure you can do what you want in Blender with a single mesh from your sequence. For example, if textures aren't importing for a sequence, try importing a single mesh. If the texture still doesn't import, it's either an issue with the mesh or with Blender's import (or user error, honestly). Once that's sorted out, the mesh sequence will likely import properly.

In your case, it sounds like you want to import PLYs with vertex color data, then use those vertex colors for rendering/texturing. First you would need to check blend4web/aframe to see if they support vertex colors. I'm not familiar with either of those, but it's possible they don't. If they don't, then another option is to somehow convert your vertex color data into an image texture and map that back onto your mesh. I haven't tried that before, but it looks like it's possible: see Bake vertex colors to texture from mesh, and Converting Vertex Color to a Texture With Blender, and How do I bake vertex color into a texture?. Note that these tutorials teach you how to do this with a single mesh, not multiple.

If you want to render the sequence within Blender, then you may just be able to use the Vertex Color Node in a material and pass that into the Color input of a Diffuse shader.

I hope this helps.

kryspyb commented 4 years ago

Hello, thank you for the detailed reply (and delay in my response).

Implementing the vertex colours to the model can be done using the nodes functionality in blender, this then is usable in blend4web and a-frame. I have tried this previously. It just takes a bit of time to setup the nodes initially, but I've got around this by importing the meshes into some templates that I have setup. Unfortunately it's looking like the traditional animation approach in blender doesn't work with these kinds of output, it's fine for video export though. The only work around I have found is again using nodes to switch on and off the PLY meshes for each one in the sequence, not really how blender should operate.

I appreciate the time you have take to help.