Difference between revisions of "Talk:HowTo:Radiosity baking in Blender"

From VsWiki
Jump to: navigation, search
m (Geometry changes: absolute coordinates)
(Geometry changes)
Line 22: Line 22:
 
******* Go try it out so we can wipe this little talk-abomination clean! :) --[[User:tiny paintings|tiny paintings]] 06:15, 26 Sep 2005 (PDT)
 
******* Go try it out so we can wipe this little talk-abomination clean! :) --[[User:tiny paintings|tiny paintings]] 06:15, 26 Sep 2005 (PDT)
 
******* Ok, i'll try, but this should really be done by the script (if possible, of course). See my comment above. --[[User:pontiac|Pontiac]] 06:34, 26 Sep 2005 (PDT)
 
******* Ok, i'll try, but this should really be done by the script (if possible, of course). See my comment above. --[[User:pontiac|Pontiac]] 06:34, 26 Sep 2005 (PDT)
 +
******** It does what you suggested, and then some. Translation, scaling, rotation etc. is all in the object to world space matrix. --[[User:tiny paintings|tiny paintings]] 06:37, 26 Sep 2005 (PDT)
  
 
== Script Talk ==
 
== Script Talk ==

Revision as of 15:37, 26 September 2005

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)
    • YADDAYADDA
      • 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)
          • Uploaded it (+OBJ files) again:
            radiosity_baking_04_rad.blend
            radiosity_baking_04.obj
            radiosity_baking_04.mtl
            --09:15, 25 Sep 2005 (PDT)
          • I still can't get the blend file to work, or rather it seems I can't download it. It downloads at 0.3 kb/s and seems to cancel after a while, says it's done though. Weird, very weird. There other files download fast and are okay. I tried, however, the obj file. With success. Radiosity baked okay and the texture baked dandily too. Are you using the latest version of blender? --tiny paintings 12:52, 25 Sep 2005 (PDT)
            • I'm using the Blender Bersion 2.37a here (most recent Debian package). Just sent you a mail with the file attached. Dunno why downlaod doesn't work for you. It certainly does for me :-/ --Pontiac 13:08, 25 Sep 2005 (PDT)
            • Okay, I'm able to reproduce your problems now. After a little stdout-debugging I (think I) have found the problem. The object center changes after the radio baking => sorting is messed up because it's done on object space coords. As I see it there are two possible solutions: 1) Transform object space coords -> world space and sort on that (how??) 2) change the object centers (again, how??). --tiny paintings 05:45, 26 Sep 2005 (PDT)
              • I have a working remedy. I did object -> world transformations. Might not be pretty but it works. I'll post it in a sec... --tiny paintings 06:04, 26 Sep 2005 (PDT)
              • You might need the absolute coordiantes of the object and add them to the relatives (if i understand the documentation at [1] or [2] right that is)
                object_coords = Blender.Object.Get(ObjectName).loc()
                or
                object_coords = ...........getLocation()
                I don't know if this is already with or without the objects transformation data. But that shouldt be a problem for this simple script. --Pontiac 06:34, 26 Sep 2005 (PDT)
              • Ah, i've seen you answer too late ;) --Pontiac 06:09, 26 Sep 2005 (PDT)
              • Go try it out so we can wipe this little talk-abomination clean! :) --tiny paintings 06:15, 26 Sep 2005 (PDT)
              • Ok, i'll try, but this should really be done by the script (if possible, of course). See my comment above. --Pontiac 06:34, 26 Sep 2005 (PDT)
                • It does what you suggested, and then some. Translation, scaling, rotation etc. is all in the object to world space matrix. --tiny paintings 06:37, 26 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+"."