zenustech / zenoblend

Zeno Blender Addon (WIP)
Mozilla Public License 2.0
37 stars 5 forks source link

Support vertex color transfer #8

Closed hooyuser closed 3 years ago

hooyuser commented 3 years ago

Here is a test file create_vertex_color

zeno_vdb_slice.blend.txt

hooyuser commented 3 years ago

Thanks! I adjust the internal logic a little bit: vertex colors are considered to be loop attribute, and multiple vertex colors are supported.

Nice work! I wonder if we could have a zeno version of "Attribute Convert Node", which is a useful node in Blender Geometry Nodes, designed for converting the domain and type of an attribute. For example, a vertex attribute of type vec3 can be converted into a loop attribute (or alternatively face corner attribute in the context of Blender) of type color. Since some zeno nodes will produce clr attribute as a vertex attribute, this kind of node can enable users to bring the clr vertex attribute to blender mesh vertex color.

Btw, this doesn't seem to an urgent demand for zenoblend since Blender Geometry Nodes can already complete this kind of conversion.

hooyuser commented 3 years ago

If we are going to convert a vertex attribute clr into a loop attribute Col, it will look like this.

attribute convert

archibate commented 3 years ago

clr attribute as a vertex attribute, this kind of node can enable users to bring the clr vertex attribute to blender mesh vertex color.

FYI we currently automatically do this vertex-to-loop transfer in PrimitiveToBMesh when has_vert_color is on.

archibate commented 3 years ago

Oh I see, so the reason to have separate loop attributes is for face that sharing same vertex does not have to share the same, e.g., vertex normal, allowing flat/smooth shading easily.

hooyuser commented 3 years ago

@archibate I find when has_vert_color is on, all the zeno point attribute will be converted into bmesh vertex color. So we don't have any point attribute for bmesh in that case. In blender, vertex colors are actually special face corner attributes. I think we could only cast the point attribute named clr into bmesh vertex color.

Also I find gamma correction is still necessary? I will give a screenshot to deal with this then.

hooyuser commented 3 years ago

As the following screenshot shows, @clr = 0.5 will be transformed into clr = 0.212. When an 8-bit color of the char format is converted into color of the float format, Blender will make gamma correction. It appears Blender always regards color of the char format as non-linear encoded color.

gamma