Paste Code
Paste Blends
Paste Images

import bpy
import random
import time

class DummyRenderEngine(bpy.types.RenderEngine):
__label__ = "Dummy"

# callback to render scene
def render(self, scene):
r = scene.render_data

# set string in stats
self.update_stats("", "Rendering!")

# compute resolution
x= int(r.resolution_x*r.resolution_percentage*0.01)
y= int(r.resolution_y*r.resolution_percentage*0.01)

# get a render result to write into
result = self.begin_result(0, 0, x, y)
lay = result.layers[0]

# start writing pixels
i = 0

for c in lay.rect:
if scene.dummy_random:
c.value = random.random()
else:
c.value = 1.0

# test if we are getting interrupt
if self.test_break():
break

# display what we have until now, and sleep to
# pretend we are doing non-trivial computations
if i % 10000 == 0:
self.update_result(result)
time.sleep(0.01)

i += 1

# done
self.end_result(result)
self.update_stats("", "")

class RENDER_PT_dummy(bpy.types.Panel):
__space_type__ = "BUTTONS_WINDOW"
__region_type__ = "WINDOW"
__context__ = "scene"
__label__ = "Dummy"

def poll(self, context):
rd = context.scene.render_data
return (rd.engine == 'DummyRenderEngine')

def draw(self, context):
layout = self.layout
scene = context.scene

layout.itemR(scene, "dummy_random")

# extend scene with new property
scene = bpy.types.Scene
scene.BoolProperty(attr="dummy_random", name="Random", description="", default=True)

# register engine and panel
bpy.types.register(DummyRenderEngine)
bpy.types.register(RENDER_PT_dummy)
  1.  
  2. import bpy
  3. import random
  4. import time
  5.  
  6. class DummyRenderEngine(bpy.types.RenderEngine):
  7.         __label__ = "Dummy"
  8.  
  9.         # callback to render scene
  10.         def render(self, scene):
  11.                 r = scene.render_data
  12.  
  13.                 # set string in stats
  14.                 self.update_stats("", "Rendering!")
  15.  
  16.                 # compute resolution
  17.                 x= int(r.resolution_x*r.resolution_percentage*0.01)
  18.                 y= int(r.resolution_y*r.resolution_percentage*0.01)
  19.  
  20.                 # get a render result to write into
  21.                 result = self.begin_result(0, 0, x, y)
  22.                 lay = result.layers[0]
  23.  
  24.                 # start writing pixels
  25.                 i = 0
  26.  
  27.                 for c in lay.rect:
  28.                         if scene.dummy_random:
  29.                                 c.value = random.random()
  30.                         else:
  31.                                 c.value = 1.0
  32.  
  33.                         # test if we are getting interrupt
  34.                         if self.test_break():
  35.                                 break
  36.  
  37.                         # display what we have until now, and sleep to
  38.                         # pretend we are doing non-trivial computations
  39.                         if i % 10000 == 0:
  40.                                 self.update_result(result)
  41.                                 time.sleep(0.01)
  42.  
  43.                         i += 1
  44.  
  45.                 # done
  46.                 self.end_result(result)
  47.                 self.update_stats("", "")
  48.  
  49. class RENDER_PT_dummy(bpy.types.Panel):
  50.         __space_type__ = "BUTTONS_WINDOW"
  51.         __region_type__ = "WINDOW"
  52.         __context__ = "scene"
  53.         __label__ = "Dummy"
  54.  
  55.         def poll(self, context):
  56.                 rd = context.scene.render_data
  57.                 return (rd.engine == 'DummyRenderEngine')
  58.  
  59.         def draw(self, context):
  60.                 layout = self.layout
  61.                 scene = context.scene
  62.  
  63.                 layout.itemR(scene, "dummy_random")
  64.  
  65. # extend scene with new property
  66. scene = bpy.types.Scene
  67. scene.BoolProperty(attr="dummy_random", name="Random", description="", default=True)
  68.  
  69. # register engine and panel
  70. bpy.types.register(DummyRenderEngine)
  71. bpy.types.register(RENDER_PT_dummy)
  72.  
go to heaven