sidebar features
sidebar content

Go Back   Blender Artists Forums > General Forums > Python & Plugins

Reply
 
Thread Tools
jms's Avatar
jms jms is offline
Member
 
Join Date: Mar 2002
Location: PACA, France
Posts: 3,475
http://jmsoler.free.fr/didacticiel/b...3d2uv2d_en.htm
Code:
#!BPY """ Registration info for Blender menus: Name: 'Texture Baker' Blender: 239 Group: 'UV' Tooltip: 'Procedural to uvmapped texture baker' """ __author__ = "Jean-Michel Soler (jms)" __url__ = ("blender", "elysiun", "Official Page, http://jmsoler.free.fr/didacticiel/blender/tutor/cpl_mesh3d2uv2d_en.htm", "Communicate problems and errors, http://www.zoo-logique.org/3D.Blender/newsportal/thread.php?group=3D.Blender") __version__ = "0.3.2 2005/12/28" __bpydoc__ = """\ This script "bakes" Blender procedural materials (including textures): it saves them as 2d uv-mapped images. This script saves an uv texture layout of the chosen mesh, that can be used as an uv map for it. It is a way to export procedurals from Blender as normal image textures that can be edited with a 2d image manipulation program or used with the mesh in games and other 3d applications. Usage: a) Enter face mode and define uv coordinates for your mesh; b) Define its materials and textures ; c) Run this script and check the console. Global variables a) FRAME integer, the last frame of the animation, autodocumented . b) LIMIT integer, 0 or 1, uvcoords may exceed limits 0.0 to 1.0 , this variable let the script make a complete framing of the uvcoord Notes: The first version of this script was based on a suggestion by Martin (Theeth) Poirier; """ #--------------------------------------------- # Last release : 0.3.2 , 2005/12/28 , 13h00 #--------------------------------------------- #--------------------------------------------- # (c) jm soler 07/2004 : 'Procedural Texture Baker' # Based on a Martin 'Theeth' Poirier's really # good idea : makes a rvk mesh with uv coords # of the original mesh. # # Released under Blender Artistic Licence # # 0.3.2 # -- modified to deal with the new blender 2.40's # shape key system # # 0.3.0 # -- the variable TAILLEIMAGE has been added # 0.2.9 # -- suppression of a test on an unused variable # 0.2.8 # -- added the forgotten image property in face # data. a little longer but better. # ( a remove double in the resulting mesh may be # useful .) # -- the data.update() function problem is # corrected too # -- no more layers problem . CAM and MESH are # localised in layer 20 . This layer is # the active one for the image rendering . # -- mesh creation is cleaner, loop in double was # removed and the abskey is set in frame 1 # only . This solves an other deform problem . # -- if user does not want an autosaved image, # the "no replace" option leaves the render # window on the screen # # 0.2.7 # -- minor change at line 147 # # 0.2.6 # -- Creation of LAMP object is removed and replaced # by the use of the shadeless option in material object # # -- helpmsg corrected : the aim of the script # is to bake any type of textures so we do not have t # to mapinput its textures on UV . # # --'pers' camera was replaced by an 'ortho' one. # # 0.2.5 # -- if a image file with the same name already exits the # system returns an error # # 0.2.4 # -- a LIMIT variable is added to unlock the uvcoords # autoframing # # # 0.2.3 : # Great thanks for Apollux who sees a lot of these # problems # # --Everytime you run the script a new set # of objects is created. File size and memory # consumption can go pretty high if you are # not aware of that . # Now it ONLY creates 3 objects: a flattened # mesh, a camera and a lamp. # --all the 3 objects was placed on layer 1, but if # that layer was not visible while you used the script # all you will get a is an empty render. # Now the layer is tst and activated befor the shoot # --The flattened mesh was really flattend only after # frame 100 (if you playbacked the animation, you can # actually see the mesh becoming flat on the first 100 # frames). No more. # -- When the script is run, it changes temporary to # the new cammera, set the render output to a square # (i.e. 1024 x 1024 or else), does the render, and then # resets the render output and the active camera to the # original one. But if no original camera was found # this produce an error. # # 0.2.2 : # if the uv mesh objet exists it used, # no creation of a new one. As the lamp and # the camera # 0.2.1 : # This script automaticaly frame and shoot the # new uv mesh . The image file is saved ine the # /render folder. # #--------------------------------------------- # On user-friendly side : #--------------------------------------------- #- Tadje Vobovnik adds the Select Image Size Menu # #--------------------------------------------- # Official Page : # http://jmsoler.free.fr/didacticiel/blender/tutor/cpl_mesh3d2uv2d_en.htm # For problems and errors: # http://www.zoo-logique.org/3D.Blender/newsportal/thread.php?group=3D.Blender #---------------------------------------------
............................................
Ze French Group : ZOO-Blender | Starter Kit Blender (livre en français)
Daily updated Bpy API | Ze best french tutorials site.
#1   Old 01-Jul-05, 16:50   
Reply With Quote


Apollux's Avatar
Apollux Apollux is offline
Member
 
Join Date: Apr 2002
Location: Santo Domingo, Dom. Rep.
Posts: 676
I just tested it and it doesn't work.

No output at all. No error messages on the console, no pop-up.. nothing, nada !!

............................................

#2   Old 13-Jul-05, 06:41   
Reply With Quote
Dr. Seltsam Dr. Seltsam is offline
 
Join Date: Feb 2004
Posts: 12
That's because the script doesn't contain any code, it's just the header :-)

I think you find the complete version here: http://jmsoler.free.fr/didacticiel/b...3d2uv2d_en.htm
#3   Old 13-Jul-05, 06:46   
Reply With Quote
Apollux's Avatar
Apollux Apollux is offline
Member
 
Join Date: Apr 2002
Location: Santo Domingo, Dom. Rep.
Posts: 676
Thanks for the quick replay. Now I get the pop-up and the render window, but the script still doesn't work.

If creates a new camera and a mesh called "uvobject", but the mesh is just an empty holder.. no vertex, no edge, no nothing

So, in the end, all that you get is an empty render.
............................................

#4   Old 13-Jul-05, 07:14   
Reply With Quote
jms's Avatar
jms jms is offline
Member
 
Join Date: Mar 2002
Location: PACA, France
Posts: 3,475
Sorry, winxp pro / blender 2.37a : it works .
............................................
Ze French Group : ZOO-Blender | Starter Kit Blender (livre en français)
Daily updated Bpy API | Ze best french tutorials site.
#5   Old 13-Jul-05, 08:12   
Reply With Quote
Apollux's Avatar
Apollux Apollux is offline
Member
 
Join Date: Apr 2002
Location: Santo Domingo, Dom. Rep.
Posts: 676
Suse Linux 9.1 + Python 2.3.3 +Blender 2.37a = doesn't work.

But thank you anyway
............................................

#6   Old 13-Jul-05, 08:31   
Reply With Quote
jms's Avatar
jms jms is offline
Member
 
Join Date: Mar 2002
Location: PACA, France
Posts: 3,475
Could you send me an example of file where the script does not work ?
With the script in the text window, please .
............................................
Ze French Group : ZOO-Blender | Starter Kit Blender (livre en français)
Daily updated Bpy API | Ze best french tutorials site.
#7   Old 13-Jul-05, 08:52   
Reply With Quote
Apollux's Avatar
Apollux Apollux is offline
Member
 
Join Date: Apr 2002
Location: Santo Domingo, Dom. Rep.
Posts: 676
Just sent you an e-mail, the attached .blend is about 2 MB.
............................................

#8   Old 13-Jul-05, 13:34   
Reply With Quote
jms's Avatar
jms jms is offline
Member
 
Join Date: Mar 2002
Location: PACA, France
Posts: 3,475
seems to do not work at first time but :


For the other part, lowres suzanne, i have a little idea .
Great thank for your help .
............................................
Ze French Group : ZOO-Blender | Starter Kit Blender (livre en français)
Daily updated Bpy API | Ze best french tutorials site.
#9   Old 13-Jul-05, 14:24   
Reply With Quote
Apollux's Avatar
Apollux Apollux is offline
Member
 
Join Date: Apr 2002
Location: Santo Domingo, Dom. Rep.
Posts: 676
You are right, it fails on the first try, but succeeds on the second... weird!!

Also noticed a disturbing behavior on the scrip.. after you run it for the first time it sets both the start frame and endframe to was used to be the endframe..

Before the script is run for the first time:
Start Frame: 001
End Frame : 250
Current Frame : any number

After the script is used:
Start Frame: 250
End Frame : 250
Current Frame: 250

It is trivial work for the user to reset those values to the correct frames, but migh pass unoticed and cause unexpected renders. %|
............................................

#10   Old 13-Jul-05, 21:36   
Reply With Quote
Apollux's Avatar
Apollux Apollux is offline
Member
 
Join Date: Apr 2002
Location: Santo Domingo, Dom. Rep.
Posts: 676
By the way?

JMS, why does the script ask the user if he/she wants to replace the old image? and why it ask for the image name? Why the resulting image is allways saved to disk?

Wouldn't it be a lot simplier if the script just left the rendered image on the render buffer and the user treated it just like any other rendered image?

If I like the end result I can save it just like any other image, if I don't like it I just re-render it.
............................................

#11   Old 13-Jul-05, 21:42   
Reply With Quote
jms's Avatar
jms jms is offline
Member
 
Join Date: Mar 2002
Location: PACA, France
Posts: 3,475
Quote:
Originally Posted by Apollux
By the way?
...
Wouldn't it be a lot simplier if the script just left the rendered image on the render buffer and the user treated it just like any other rendered image?

If I like the end result I can save it just like any other image, if I don't like it I just re-render it.
You can do this now with the last released version (v028) . Just select "no replace"
............................................
Ze French Group : ZOO-Blender | Starter Kit Blender (livre en français)
Daily updated Bpy API | Ze best french tutorials site.
#12   Old 20-Jul-05, 15:43   
Reply With Quote
Room335's Avatar
Room335 Room335 is offline
Member
 
Join Date: Mar 2002
Location: Orange County,CA California
Posts: 595
jms / Apollux

I tried the script as in 2.37. I haven't been able to get the same result as you but here's the bigger problem.


The texture bake is stuck to my camera. Everytime I render I get the baked image.

See the screen shot, in the camera view you'll see the baked texture. Is there a way to clear this?

http://gallery.mudpuddle.co.nz/view_...=ScreenShot005
#13   Old 04-Oct-05, 16:41   
Reply With Quote
Room335's Avatar
Room335 Room335 is offline
Member
 
Join Date: Mar 2002
Location: Orange County,CA California
Posts: 595
I found a solution, I deleted the camera, and added a new one. Had to hit Ctrl 0 on the new camera then it cleared out of the memory.
#14   Old 04-Oct-05, 17:16   
Reply With Quote
NeOmega's Avatar
NeOmega NeOmega is offline
Donating Member
 
Join Date: Jul 2004
Location: Seattle, Wa
Posts: 1,237
your example also appears to have lighting baked into it... how is that?
............................................

#15   Old 04-Oct-05, 20:45   
Reply With Quote
Room335's Avatar
Room335 Room335 is offline
Member
 
Join Date: Mar 2002
Location: Orange County,CA California
Posts: 595
Quote:
Originally Posted by NeOmega
your example also appears to have lighting baked into it... how is that?
I don't know. I have not been able to figure out how to use this script let alone understand it.
#16   Old 04-Oct-05, 20:47   
Reply With Quote
jms's Avatar
jms jms is offline
Member
 
Join Date: Mar 2002
Location: PACA, France
Posts: 3,475
Quote:
Originally Posted by Room335
The texture bake is stuck to my camera. Everytime I render I get the baked image.
I'm testing a simple file with the last version of the script :
http://jmsoler.free.fr/didacticiel/b...3d2uv2d_en.htm
and, sorry, but i can't reproduce the problem for the moment .
............................................
Ze French Group : ZOO-Blender | Starter Kit Blender (livre en français)
Daily updated Bpy API | Ze best french tutorials site.
#17   Old 04-Oct-05, 21:02   
Reply With Quote
Room335's Avatar
Room335 Room335 is offline
Member
 
Join Date: Mar 2002
Location: Orange County,CA California
Posts: 595
I emailed you the blend file.
#18   Old 04-Oct-05, 21:15   
Reply With Quote
jms's Avatar
jms jms is offline
Member
 
Join Date: Mar 2002
Location: PACA, France
Posts: 3,475
Quote:
Originally Posted by Room335
Quote:
Originally Posted by NeOmega
your example also appears to have lighting baked into it... how is that?
I don't know. I have not been able to figure out how to use this script let alone understand it.
To get the color light on the mesh use this script :
Code:
import Blender MESH=Blender.Object.GetSelected()[0].getData() MESH.update(0,0,1)
Then, set the vcolpaint option in this object's material .

You can also make a radiosity map like that :
............................................
Ze French Group : ZOO-Blender | Starter Kit Blender (livre en français)
Daily updated Bpy API | Ze best french tutorials site.
#19   Old 04-Oct-05, 21:16   
Reply With Quote
NeOmega's Avatar
NeOmega NeOmega is offline
Donating Member
 
Join Date: Jul 2004
Location: Seattle, Wa
Posts: 1,237
It also says

"This script saves an uv texture layout of the chosen mesh, that can be used as
an uv map for it."

Is this correct? Does it work for complex objects, liek meshes composed of mulitple parts? Hmm... I am going to have to try this one out when I get home.
............................................

#20   Old 04-Oct-05, 21:31   
Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT. The time now is 11:37.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Logo and website design copyright © 2006 by froodee design bureau. All rights reserved.
Other Blender Sites
new icon Blender Homepage »
The official Blender homepage
new icon BlenderNation »
Fresh Blender News, Every Day
new icon Blenderart Magazine »
Blender articles, tutorials and images.
Blender Headlines
Featured Artwork
Short animation: Barrel by Phlopper
Woolly mammoth by sebastian_k
Photorealistic classic furniture by eMirage
Social BlenderArtists