Home Technical Talk

Diffuse Map to Vertex color? MAX

polycounter lvl 11
Offline / Send Message
cupsster polycounter lvl 11
Hi all,
please can anyone advice me how to transfer color of diffuse map to vertex colors?
Tryed this: http://www.polycount.com/forum/showthread.php?t=70981&highlight=diffuse+vertex+color not working for me.

Is there any script for this? I must use old tech... :)

Thank you.

Replies

  • cupsster
    Options
    Offline / Send Message
    cupsster polycounter lvl 11
    if rol_ColorBakerProgress!=undefined do destroyDialog rol_ColorBakerProgress
    rollout rol_ColorBakerProgress "Baking Progress" width:190 height:48
    (
    label lbl_Text "Baking Texture into Vertices:" pos:[20,7] width:150 height:13
    progressBar pb1_Progress "ProgressBar" pos:[6,21] width:180 height:20
    
    )
    ----
    ----
    fn IOI_ColorBakerBakeTexture targetObj=
    (
    --	targetObj=$
    converttoPoly targetObj --NOTE
    baseObject=targetObj.baseObject
    theBitmap=targetObj.material.diffusemap.bitmap
    theBitmapW=theBitmap.width-1
    theBitmapH=theBitmap.height-1
    
    
    vertNum=polyOp.getNumVerts baseObject
    fnGetMapvert=polyOp.getMapVert
    fnsetVertColor=polyOp.setVertColor
    fnsetVertData=polyOp.setVDataValue
    
    createDialog rol_ColorBakerProgress
    pbl_Progress=rol_ColorBakerProgress.pb1_Progress
    for iVert=1 to vertNum do
    (
    mapPos=fnGetMapvert baseObject 1 iVert
    
    mapPos[1]=mod (mapPos[1]) 1
    mapPos[2]=mod (mapPos[2]) 1
    bitmapPos=[(mapPos[1]*theBitmapW) as integer, (mapPos[2]*theBitmapH) as integer]	
    if bitmapPos[1]<0 do bitmapPos[1]+=theBitmapW
    if bitmapPos[2]<0 do bitmapPos[2]+=theBitmapH
    multiW= ceil (bitmapPos[1]/theBitmapW) 
    if multiW > 1 do bitmapPos[1]=bitmapPos[1]-theBitmapW*(multiW-1)
    
    multiH= ceil (bitmapPos[2]/theBitmapH) 
    if multiH > 1 do bitmapPos[2]=bitmapPos[2]-theBitmapH*(multiH-1)	
    bitMapPos[2]=theBitmapH-bitMapPos[2] --theBitmapW-bitMapPos[1], 
    
    mapColor= (getPixels theBitmap bitmapPos 1)[1]
    fnsetVertColor baseObject 0 #{iVert} mapColor --PERFORMANCE This is VERY slow. 10sec on 4000 object.
    
    Progress=(iVert/(vertNum as float))*100
    if pbl_Progress.value!=Progress do pbl_Progress.value=Progress
    )
    addModifier targetObj (VertexPaint())
    max modify mode
    destroyDialog rol_ColorBakerProgress
    
    targetObj.showVertexColors =true
    )
    IOI_ColorBakerBakeTexture $
    

    CREDIT
  • nezach
    Options
    Offline / Send Message
    There's an 'Assign Vertex Color' tool in the utilities tab that can do that without the need for scripts.
  • Eric Chadwick
    Options
    Offline / Send Message
    Max will not display vertex colors in the viewport by default. You have to force it, in Object Properties, via Vertex Channel Display. Or you can use a DirectX shader that supports vertex color.
  • cupsster
    Options
    Offline / Send Message
    cupsster polycounter lvl 11
    @EricChadwick: yep, I know that :) standard material > diffuse slot > vertex color map
    or
    object properties > display vertex colors

    @nezach: anyway this script works... max assign vertex colors don't.. so who wins? :P
  • Noors
    Options
    Offline / Send Message
    Noors greentooth
    yeah most of the time i'm not able to assign the vertex color from the diffuse either. Sometimes it weirdly works after checking/unchecking some options but as i'm not considering myself as a max noob, my bet is : it's pretty buggy.
  • cupsster
    Options
    Offline / Send Message
    cupsster polycounter lvl 11
    so good news for you Noors :) this works 100% sure, just second before I decided to script it myself google revealed this to me.. I'm pretty happy cause for time it will be crucial part of my workflow..
  • Bruno Afonseca
  • nezach
    Options
    Offline / Send Message
    cupsster wrote: »
    @nezach: anyway this script works... max assign vertex colors don't.. so who wins? :P


    You get no diffuse colors to the vertices from using it at all? It works for me so I guess I 'win' at that. /shrug
  • cupsster
    Options
    Offline / Send Message
    cupsster polycounter lvl 11
    thanx for pointing that out.. i'm using it but was unaware of this feature..
  • cupsster
    Options
    Offline / Send Message
    cupsster polycounter lvl 11
    No, never worked for me except maybe 4 years back when I was experimenting with it..
Sign In or Register to comment.