Notifications
Clear all

[Closed] Vertex Paint Opacity

Hi

   I'm trying to write easy script who can help me with the one thing. 
   
   So, I've little question. 
   
   My code of script:

       if selection.count == 1 then
       		(
       			black_color = color 0 0 0 0
       			
       			for s in selection do
       			(
       				nVerts = s.numverts
       				
       				channelInfo.CopyChannel s 3 0
       				channelInfo.PasteChannel s 3 -1
       				channelInfo.NameChannel s 3 -1 "-none-"
       				maxOps.CollapseNode s on
       
       				modPanel.addModToSelection (VertexPaint ()) ui:off
       			   
       				s.showVertexColors = true;
       				s.vertexColorsShaded = false;
       				
       				s.showVertexColors = true -- enable Vertex Colors in Viewport
       				s.vertexColorType = #illum -- set Vertex Color type to Illum
       					
       				MeshOp.setVertColor  s -1 #{1..nVerts} black_color
       
       				update s
       			)
       			modPanel.setCurrentObject $.modifiers[#vertexpaint]
       			$.modifiers[#vertexpaint].mapChannel = -1
       		)
       		else messagebox "Only one object"
       	)
       
  I know it's poor but my question is: How can I use my black_color with 50% opacity to paint my object? I mean how Can I do this via maxscript to paint my object with set 50% opaicty of my color.

and btw. I’ve sometimes problem with this:


     modPanel.setCurrentObject $.modifiers[#vertexpaint]
  $.modifiers[#vertexpaint].mapChannel = -1
   

>> MAXScript Rollout Handler Exception: – Unable to convert: undefined to type: MaxObject <<

3 Replies

you can apply the new vertex colour with an opacityblend.

vert_colour = original_colour + (new_colour – original_colour) * opacity;

I’m was trying to with this but I can’t handle this.

I’m trying to add color via VertexPaintTool now


  v = VertexPaintTool()		
  v.brushOpacity = 50
  v.paintColor = extra_color
  

but how can I apply it to my object with VertexPaint layer?

you can’t paint point4 (which is color with Alpha) values with VertexPaint.
you can paint alpha value in the alpha channel. or use any other map channel as alpha channel.
something like:


fn setVertexColorAlpha node vert c keep:on = if iskindof node editable_poly do
(
	if keep do verts = node.selectedverts as bitarray
	if not iskindof vert BitArray do vert = #{vert} 
	node.selectedverts = vert
	 node.SetVertexColor c #VertexColor
	node.SetVertexColor (color c.a c.a c.a) #Alpha
	if keep do node.selectedverts = verts
	ok
)