Talk:HowTo:Radiosity baking in Blender

From VsWiki
Revision as of 16:43, 25 September 2005 by tiny paintings (talk | contribs) (Geometry changes)
Jump to: navigation, search

Image formatting

I'm putting out a request for help from the more experienced wiki users on a few matters:

  • Image formatting: Is there a way of inserting some (vertical) space between the images and the text? Image captions? --tiny paintings 12:22, 22 Sep 2005 (PDT)
    • Space is possible via several ways (CSS padding/spacing, tables, etc...) where do you want to add spaces? --Pontiac 13:10, 22 Sep 2005 (PDT)
    • images captions, thumbnails etc... are only (possible (at least easy) with the wiki-uploaded pictures. Depends on what you want to do. --Pontiac 13:10, 22 Sep 2005 (PDT)

Geometry changes

I've followed the tutorial exactly and it does what i expected (not to the end though). But there are a few points that do not work as expected:

  • The Mesh created by the radiosity progress has a different vertex-count than the source mesh (without the sphere and with MaxEl set to 1)--Pontiac 12:29, 23 Sep 2005 (PDT)
    • If i "Remove Doubles" (in the vertex-edit menu that is. The button in the radiosity menu doesn't really work) on the vertices then the vertex count is right again, but the order seems to be messed up. --Pontiac 13:03, 23 Sep 2005 (PDT)
      • I suspected that would happend (different vertex counts)... I'll rewrite that part to reflect how I actually did it. --tiny paintings 15:55, 23 Sep 2005 (PDT)
      • With regards to "messed up order": Can you be more specific? I designed the script explictily so that vertex order DOES NOT matter (well, you probably shouldn't move the meshes, though...). --tiny paintings 16:03, 23 Sep 2005 (PDT)
        • What i meant has to do with the vertex-creation of the radiosity process. AFAIK the mess is created when vertices are duplicated and then merged again (via "Remove Doubles" in this case). It depends by what criteria you sort the vertices (x,y,z coords or other?) In theorie you wouldnt need a sorting if you compare the x,y,z coords and only copy the data when they are the same (i know that's not realistical) --Pontiac 16:21, 23 Sep 2005 (PDT)
          • Does or does the script not work for you? I'm confused. --tiny paintings 16:54, 23 Sep 2005 (PDT)
          • The order-mess is always created somehow afaik, or that's what my tests showed. Even if your original mesh has duplicate vertices the order gets screwed up after you bake the radiosity. Yes they are sorted on coordinate. True, sorting isn't needed but I figured python sort function should be blazing fast and complexity of my script isn't bad - in theory it could be O(|V|log|V|), where as a naive implementation of "compare and copy on match" is O(|V|^2). Anyhow, I don't think running times are a problem. --tiny paintings 16:54, 23 Sep 2005 (PDT)
            • Ok, here is what i currently do: 1. I follow your script until the "seperate the mesh from the sphere". This is not possible, because the mesh is somehow splitted into smaller sections (and it would give me dozens of objects when splitting) and thus have more vertices. 2. to get the same amount of vertices i remove the sphere (duh) and then say "Edit"->"Vertices"->"Remove Doubles". But then i get some really messed up results when baking the texture on the original mesh. it 'looks' like the vertices are mixed up somehow. I'll put my test file up somewhere asap. i'm too tired right now :-/ --Pontiac 17:12, 23 Sep 2005 (PDT)
            • Ok, here's the test file i mentioned above: radiosity_baking_04_rad.blend
              On the 1. layer is the original mesh (OB:"Cube") with the vertex colors already applied (and messed up). On the 3. layer ist the geometry that was created by the rad-process (OB:"Mesh.002"). (you can ignor the 2. layer since it's just a copy of the 1. with the same material) --Pontiac 01:30, 25 Sep 2005 (PDT)
              • Can't open it. Send it to seaghost at hellokitty.com, and include an .obj of the original mesh. --tiny paintings 05:12, 25 Sep 2005 (PDT)
              • I'm assuming you clicked Free Radio Data even though I forgot to include an instruction for that? --tiny paintings 07:43, 25 Sep 2005 (PDT)

Script Talk

  • There is a third point, but it was only a script error, which i fixed already. (a missing ":")
    • I'm making some changes to the tooltip description of the new script, since it's a bit off, really. --tiny paintings 15:55, 23 Sep 2005 (PDT)
      • I confess that i didn't check the tooltips before posting it here ;) Thanks --Pontiac 16:21, 23 Sep 2005 (PDT)
      • Ah, now i know what you mean, the whole "radiosity data" things i wrote. I inserted that as a dummy (data generated by the radiosity process) ;) --Pontiac 16:47, 23 Sep 2005 (PDT)
    • Also, the tutorial is becoming rather cluttered with two scripts in it. Maybe you can put my original script in a file, say vccopy.py, and link to it? The GUI-capable script should be downloadable too to avoid the unnecessary copy-open_emacs-paste-save procedure. --tiny paintings 15:55, 23 Sep 2005 (PDT)
      • If you have no problem with it i would vote to keep only the new (GUI) script (your script is 'nearly 1:1 in there), but keep the original script on the talk page for reference. (less clutter on the main page) ... concentrating on one single script is the way to go IMHO --Pontiac 16:21, 23 Sep 2005 (PDT)
      • I moved the (GUI) script to an extra page so it is possible to download it here AND edit it with the wiki interface. See HowTo:Radiosity baking in Blender#Script and HowTo:Radiosity baking in Blender/vccopy.py--Pontiac 16:47, 23 Sep 2005 (PDT)

old Script

This is the original Script by tiny paintings. See the main page for the most recent version

You have to pardon my python n00bness, this is all I could come up with. Feel free to improve it!

import Blender

# WHAT DOES IT DO?
# This script copies the vertex color information from one mesh
# to another, and does so correctly assuming the meshes have the
# same geometry, vertex-wise.

# IMPORTANT: Assumes meshes with exactly equal geometry, vertex-wise.

fromObj = "Mesh"  # Set this to the resulting mesh from radio calcuation
toObj = "Fuselage_default" # Set this to the name of your original, UV-mapped mesh.

me_from = Blender.Object.Get(fromObj).getData()
me_to = Blender.Object.Get(toObj).getData()

if not me_to and not me_from:
	print "ERROR: Source/destination object does not exist"

elif len(me_to.verts) != len(me_from.verts):
	print "ERROR: Source and destination objects must have the same number of vertices"
	
else:
	# make two lists sorted on coordinates,
	# containing a face and vertex index i and j respectively
	
	l_to = []
	l_from = []
	
	# format: [ (x,y,z, face index, vertex index), ... ]
	
	for i in range(len(me_to.faces)):
		for j in range(len(me_to.faces[i].v)):
			vert = me_to.faces[i].v[j].co
			l_to.append((vert[0], vert[1], vert[2], i, j))
			
		for j in range(len(me_from.faces[i].v)):
			vert = me_from.faces[i].v[j].co
			l_from.append((vert[0], vert[1], vert[2], i, j))
		
	# Sort the lists after vertex coordinates
	l_to.sort()	
	l_from.sort()
	
	for i in range(len(l_to)):
		to_f = l_to[i][3]
		from_f = l_from[i][3]
		to_v = l_to[i][4]
		from_v = l_from[i][4]
		
		me_to.faces[to_f].col[to_v] = me_from.faces[from_f].col[from_v]
			

	me_to.update()
	print "Copied vertex color information from object "+fromObj+" to object "+toObj+"."