VertexColorModify.zip
0.00MB

 

Edit Mode에서 버텍스나 엣지 선택 후 간편하게 버텍스 컬러 세팅하는 에드온입니다.

기존 버텍스 페인트 모드에서 불가능했던 알파 값 세팅까지 가능합니다.

참고 : https://blender.stackexchange.com/questions/159342/is-there-a-way-to-set-vertex-color-of-selected-vertices-with-single-click

 

에드온 설치 방법

첨부한 압축파일을 다운받고, 블랜더 설정>Add-ons에서 Install로 해당 압축파일을 설치합니다.

에드온 검색창에 Vertex Color Modify를 검색하고 체크하면 설치 끝입니다.

 

사용 방법

Edit Mode에서 버텍스나 엣지를 선택합니다.

SideBar에서 Vertex Color Modify 판넬을 열고 컬러 세팅해서 Apply Color하면 됩니다.

(N키 누르면 SideBar 오픈)

 

버텍스 컬러 상태를 확인할려면, Shading창에서 아래와 같이 노드를 세팅하면 됩니다.

(블랜더 최신 버전은 Vertex Color 대신 Attribute Color로 변경됨)

 

유니티 엔진 결과 확인

 

파이썬 스크립트

bl_info = {
    "name": "Vertex Color Modify",
    "author": "CatDarkGame",
    "version": (0, 1, 0),
    "blender": (2, 93, 2),
    "location": "3D View > Side Bar(N) > VertexColor Modify",
    "description": "",
}


import bpy

from bpy.props import EnumProperty
from bpy.types import Operator, Panel
from bpy.utils import register_class, unregister_class
 

class VertexColorModify_PT_panel(Panel):
    bl_idname = 'VertexColorMotify_PT_panel'
    bl_label = 'VertexColor Modify'
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'UI'
    bl_category = 'VertexColor'
 
    def draw(self, context):
        layout = self.layout
        layout.prop(context.scene, "mytool_color")
        layout.operator('vertexcolormodify.ot_op', text='Apply Color').action = 'APPLY'
        
 
class VertexColorModify_OT_op(Operator):
    bl_idname = 'vertexcolormodify.ot_op'
    bl_label = 'VertexColor Modify'
    bl_description = 'VertexColor Modify'
    bl_options = {'REGISTER', 'UNDO'}
 
    action: EnumProperty(
        items=[
            ('APPLY', 'Apply Color', 'Apply Color')
        ]
    )
 
    def execute(self, context):
        if self.action == 'APPLY':
            color_to_vertices(color=context.scene.mytool_color)
        return {'FINISHED'}
 
 
def register():
    register_class(VertexColorModify_OT_op)
    register_class(VertexColorModify_PT_panel)
    bpy.types.Scene.mytool_color = bpy.props.FloatVectorProperty(
                 name = "Vertex Color",
                 subtype = "COLOR",
                 size = 4,
                 min = 0.0,
                 max = 1.0,
                 default = (1.0,1.0,1.0,1.0))
 
 
def unregister():
    unregister_class(VertexColorModify_OT_op)
    unregister_class(VertexColorModify_PT_panel)
    del bpy.types.Scene.mytool_color
 
if __name__ == '__main__':
    register()


def color_to_vertices(color):
    mesh = bpy.context.active_object.data
    bpy.ops.object.mode_set(mode = 'VERTEX_PAINT')

    selected_verts = []
    for vert in mesh.vertices:
        if vert.select == True:
            selected_verts.append(vert)


    for polygon in mesh.polygons:
        for selected_vert in selected_verts:
            for i, index in enumerate(polygon.vertices):
                if selected_vert.index == index:
                    loop_index = polygon.loop_indices[i]
                    mesh.vertex_colors.active.data[loop_index].color = color

    bpy.ops.object.mode_set(mode = 'EDIT')

#Ref https://blender.stackexchange.com/questions/909/how-can-i-set-and-get-the-vertex-color-property
#Ref https://blender.stackexchange.com/questions/214343/could-i-see-a-simple-example-of-using-a-color-picker-in-a-script
#Ref https://github.com/todashuta/blender-addon-set-vertex-color-alpha/blob/main/set_vertex_color_alpha.py

 

 

 

 


WRITTEN BY
CatDarkGame
Technical Artist dhwlgn12@gmail.com

,