Posted: Fri May 21, 2004 2:26 am
Joined: 25 Feb 2003
Posts: 998
Now blender has AO, raytracing etc, some renders are taking longer (though still fast)
To yse run the folling scripts from the command line with the latest CVS bf-blender since this relys on a python function I added for this script. ( context.setBorder() )
blender myscene.blend -P render_client.py
This script is working but needs some intergration.
All the tiles need to be composited, I can do this using PIL but need to make a script that composites a directory of images.
It renders an image as many tiles (128px x 128px default)
Each tile is indexed and blender only renders if there are mo existing image of that index (a dummy is created before the render so computers dont render the same tile)
This requires all PC's to be able to accsess a networked filesystem.
if the file has a num at the end eg.
blender myscene_256.blend -P render_client.py
Then a 256 x 256 tile will be used.
Here is render_client.py
| Code: |
import Blender
from Blender import sys, Scene, Noise
from Blender.Scene import Render
import string
NUM = '0123456789'
DEFAULT_TILE_SIZE=64 # px
# Clamp
def max(number):
if number > 1.0:
number = 1.0
return number
def isfile(file):
try:
open(file)
return 1
except:
return 0
def randList(list):
randList = []
lenList = len(list)
while lenList != len(randList):
randIndex = int( Noise.random() * len(list) )
randList.append( list[randIndex] )
list.remove( list[randIndex] )
return randList
# Strip all chars after a '.'
def stripExt(text):
return text[:text.index('.')]
def getParts():
name = Blender.Get('filename')
name = stripExt(name)
# Check that there is a number at the end of the filename.
if name[-1] not in NUM:
tileSize = DEFAULT_TILE_SIZE
else:
# Work out the tile size from the file name.
tileSize = ''
while name[-1] in NUM: # Keep pulling in the numbers as long as they are nums.
tileSize = name[-1] + tileSize
name = name[0:-1]
tileSize = eval(tileSize)
# OK either way we have a tile size.
# Get the data
scn = Scene.GetCurrent()
context = scn.getRenderingContext()
xPix = context.imageSizeX()
yPix = context.imageSizeY()
xParts = int(xPix / tileSize)
yParts = int(yPix / tileSize)
# Incase the tile size is larger then the render size.
if xParts < 2:
xParts = 2
if yParts < 2:
yParts = 2
return xParts, yParts
# Makes a list of rects that setBorder will pass.
def makeBorderList(xparts, yparts):
borderRectList=[] #We store all the rects here and then return them.
xlen = 1.0 / xparts
ylen = 1.0 / yparts
xPoint = 0.0 # This stores the current X value, and incriments xlen each iteration until its equel to 1.0
yPoint = 0.0
counter = 1 # Inde each border
while xPoint < 0.999:
while yPoint < 0.999:
# Write the rect to the list
borderRectList.append( (counter, max(xPoint), max(yPoint), max(xPoint+xlen), max(yPoint+ylen)) )
counter += 1 # Keep a tag of which index this one is.
yPoint += ylen
# Reset yPoint for the next colum.
yPoint = 0.0
xPoint += xlen
return borderRectList
# SETS UP DEFAULTS NEEDED FOR OUTPUTTING AN IMAGE THAT CAN BE COMPOSITED.
scn = Scene.GetCurrent()
context = scn.getRenderingContext()
context.enableBorderRender(1)
context.enableRGBAColor() # Save RGBA
context.setImageType(Render.PNG) # Save RGBA
context.enableExtensions(1)
# Make image name
imageName = Blender.Get('filename')
# Remove .blend
imageName = stripExt(imageName)
renderName = imageName + '_' # frameNum.png will be added.
xParts, yParts = getParts()
randBorderList = randList( makeBorderList(xParts,yParts) )
# Set the start and end frame to the current frame.
curFrame = Blender.Get( 'curframe')
context.startFrame(curFrame)
context.endFrame(curFrame)
# Keep track of frames rendered, only for a report.
renderedFrames = 0
for border in randBorderList:
# Set the new file name WITH X/Y parts
# blendfilename_partnum_framenum.ext
# eg. render_01_0001.png
partNum = str(border[0])
while len(partNum) < 4:
partNum = '0' + partNum
uniqueRenderName = renderName + partNum + '_' # We add 1 so that the first image is 1, not 0
# CREATE THE REAL NAME OF THE OYTPUT FILE
frameNum = str(curFrame)
while len(frameNum) < 5:
frameNum = '0' + frameNum
fileToRender = uniqueRenderName + frameNum + '.png'
# Chech that the file isnt alredy there
if isfile(fileToRender) == 0:
# TOUCH FILE SO NOBODY OVERWRITES IT.
#Create a dummy file so no other nodes try to render the image.
file = open(fileToRender,"w")
file.close()
# SET RENDER NAME AND PATH.
context.setRenderPath('//' + uniqueRenderName) # // is the currentdir
# Set border
context.setBorder(border[1], border[2], border[3], border[4] )
# RENDER THE IMAGE
context.renderAnim() # This saves the pics.
renderedFrames += 1
# Print report
print 'XParts', xParts,' YParts', yParts
print renderedFrames, ' of ', len(randBorderList), ' rendered'
# Quit
Blender.Quit()
|
Last edited by ideasman on Tue May 25, 2004 12:23 am; edited 1 time in total
Posted: Mon May 24, 2004 2:07 pm
Joined: 08 Apr 2004
Posts: 24
Has anyone tried this script with Xgrid? For stills...
http://www.blenderman.org/tutorials/xgrid/
Posted: Mon May 24, 2004 2:44 pm
Joined: 16 Oct 2002
Posts: 1177
Can you edit your first post to put the [ code ][ /code ] tags properly please?
Martin
_________________
Life is what happens to you when you're busy making other plans.
- John Lennon
Posted: Tue May 25, 2004 12:35 am
Joined: 25 Feb 2003
Posts: 998
done-
I was just thinking...
It would not be hard to do this (mabe time consuming though)
Have a button/menu item that activates a python script.
This script copys a blend file to a remote location that other PC's on the internet can accsess. (FTP/WEBDAV/RSYNC)
Computers all over the internet render tiles of the pic.
As each tile as compleated it is downloaded and removed from the net and composited into the base image (empty file is kept for as a place holder, so no other PC's render it.)
- This would make blender MUCH more attractive to users who wanted to do raytracing renders/preview renders.
It would also be good to use some DIFF type uploading system (like RSYNC??) So if the user makes changes to their blend file, it can be updated quickly and re-rendered without re-uploading all the data in the file that hasent changed.
Posted: Thu Jun 10, 2004 3:24 am
Joined: 07 Jan 2004
Posts: 92
Another Idea-
The master computer has a screen that shows the status of all the computers in the the renderfarm. The status would be something simple like a line with each nodes address, frame number that it's working on, time elapsed, and ping time (for internet use). The lines would update as each node completes a frame through a message system between nodes and master.
I don't know if it could be entirely run in python, it might require some code to be written in blender for the messaging system.
just an idea
here's a mock-up picture
Also, Do the particle generators use random number generators? If they do, do the random number generators need to be synced with the master?
Cheers,
Bob
_________________
Halfway down the trail to hell....
Posted: Thu Jun 10, 2004 3:54 am
Joined: 25 Feb 2003
Posts: 998
Teah this could be done but Id would be be done after intergrating the script into blender.
Posted: Sat Jun 12, 2004 12:10 pm
Joined: 18 Nov 2003
Posts: 255
Are you going to keep this python or are you truly integrating it with blender?
Posted: Sat Jun 12, 2004 4:33 pm
Joined: 25 Feb 2003
Posts: 998
I think I'll just keep it python. It could be added into a python menu- Or a gui could be made so users can easerly activate it.
Posted: Tue Jun 15, 2004 5:00 pm
Joined: 13 Mar 2003
Posts: 122
Can you post a tutorial how to get that renderfarm working? Like: Do I have to open blender on 2 or more computers? Or do I need to run the script on 2 computers? Do I have to enable sharing over network to share the .blend file? Please give some more info on how to set up a working renderfarm. I think many people would be interested in that.
Posted: Wed Jun 16, 2004 12:32 am
Joined: 25 Feb 2003
Posts: 998
Tonight I will add some features which allow the user to configre the renderfarm from within blender, than a tutorial.
Posted: Wed Jun 23, 2004 12:35 am
Joined: 22 Mar 2003
Posts: 187
This is great ideasman! Thanks.
It would also be nice if were possible to render a still file by assigning this job out to as many cpu's that you have in your computer for AO renders.
Posted: Wed Jun 23, 2004 1:42 am
Joined: 25 Feb 2003
Posts: 998
Good point. Do you know how to get python to know how many CPU's the PC has?
Failing that it could be configured within blender, this would also be good for hyperthreading.
- Cam
Posted: Wed Jun 23, 2004 10:33 pm
Joined: 22 Mar 2003
Posts: 187
| ideasman wrote: |
Good point. Do you know how to get python to know how many CPU's the PC has?
Failing that it could be configured within blender, this would also be good for hyperthreading.
- Cam |
Sorry, I don't know how to get python to access CPU threads in a PC. I like the speed increase that we get with this option for rendering in Yafray in Blender. I guess that it is just a matter of time before someone gets this working for Blenders raytraced renders.
Posted: Sat Nov 13, 2010 1:45 pm
Joined: 13 Nov 2010
Posts: 1
In what language that code is written ? I familiar with c++ but it do not like a c++.
astigmatism
Last edited by tarapozan on Sun Jun 12, 2011 11:28 am; edited 6 times in total
Posted: Sat Nov 13, 2010 3:49 pm
Joined: 05 Aug 2003
Posts: 3518
Blender uses an extended version of Python for its scripting language.