View Full Version : Diffuse Map to Vertex color? MAX
cupsster
09-22-2011, 01:27 PM
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.
cupsster
09-22-2011, 01:38 PM
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 (http://forums.cgsociety.org/archive/index.php/t-443253.html)
nezach
09-22-2011, 03:31 PM
There's an 'Assign Vertex Color' tool in the utilities tab that can do that without the need for scripts.
Eric Chadwick
09-22-2011, 04:49 PM
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
09-23-2011, 12:51 AM
@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
09-23-2011, 01:32 AM
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
09-23-2011, 01:39 AM
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..
fonfa
09-23-2011, 05:04 AM
TexTools has a button that does it!
http://www.renderhjs.net/textools/
nezach
09-23-2011, 05:20 AM
@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
09-23-2011, 05:20 AM
thanx for pointing that out.. i'm using it but was unaware of this feature..
cupsster
09-23-2011, 05:21 AM
No, never worked for me except maybe 4 years back when I was experimenting with it..
vBulletin® v3.8.4, Copyright ©2000-2013, Jelsoft Enterprises Ltd.