Notifications
Clear all

[Closed] Baking bitmap texture into Vertex Colors?

Does there exist a tool for baking the texture information into the vertex color?

Or any hints on how to program this?

/Andreas

6 Replies

dunno a tool for doing this but i remember a tool that would take the image , go trough it ,get a “middle” Color and set it for ambient or diffuse color.
Again i’m not sure if its a good starting point but it look like it.

the way i see it, goes on 4 step

-look trough all vertex
-check pixel color of texture map ( depending of an radius would be helpful)
-make approximation of middle color ( maybe using some kind of threshold/filter because if you use poor quality texture you can have ugly artefact)

  • set the middle color on Vertex Color

pretty obvious i know. sorry for the lack of more code

-D-

[edit] Find the script i was looking for . its Called Diffuse Mapper by andre Hotz
http://www.scriptspot.com/andrehotz/

Thanks for the pointers.

I have managed to create a tool for baking. However it only works on planar mapping as it is now. I use the function

polyOp.getMapVert

It’s fine as long as I have U, V information only (as in planes), but it gets tricky when there are U, V and W. How do I translate that to the the x, y positions on the map really?

/Andreas

Utilities / Assign Vertex Color

Best, Rob

1 Reply
(@f97ao)
Joined: 11 months ago

Posts: 0

Thanks Rob. I almost thought there should exist a tool like that. He, well guess it didn’t hurt to program vertex colors and uvw mapping for a day anyway.
I was almost finished with my tool.

/Andreas

If you’re using Max 8 you could use my Wahooney MXS, I’ve written an extension that allows you to query a texture at a given coordinate. I think it might help.

It would still be useful to figure out how to do this.

I had problems with projecting the 2d bitmap on the 3 dimensional uvw coordinats. Does anyone have any tips on this?

Create an object and assign a material with a bitmap texture in the diffuse slot then run the script.



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.
		fnsetVertData baseObject 1 #{iVert} (mapColor.red)
		
		
		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 $