Integrated Freestyle to rendering pipeline
[blender.git] / release / ui / buttons_world.py
1
2 import bpy
3
4 class WorldButtonsPanel(bpy.types.Panel):
5         __space_type__ = 'PROPERTIES'
6         __region_type__ = 'WINDOW'
7         __context__ = "world"
8         # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here
9         
10         def poll(self, context):
11                 rd = context.scene.render_data
12                 return (context.world) and (not rd.use_game_engine) and (rd.engine in self.COMPAT_ENGINES)
13
14 class WORLD_PT_preview(WorldButtonsPanel):
15         __label__ = "Preview"
16         COMPAT_ENGINES = set(['BLENDER_RENDER'])
17         
18         def draw(self, context):
19                 self.layout.template_preview(context.world)
20         
21 class WORLD_PT_context_world(WorldButtonsPanel):
22         __show_header__ = False
23         COMPAT_ENGINES = set(['BLENDER_RENDER'])
24
25         def poll(self, context):
26                 rd = context.scene.render_data
27                 return (not rd.use_game_engine) and (rd.engine in self.COMPAT_ENGINES)
28
29         def draw(self, context):
30                 layout = self.layout
31                 
32                 scene = context.scene
33                 world = context.world
34                 space = context.space_data
35
36                 split = layout.split(percentage=0.65)
37
38                 if scene:
39                         split.template_ID(scene, "world", new="world.new")
40                 elif world:
41                         split.template_ID(space, "pin_id")
42
43 class WORLD_PT_world(WorldButtonsPanel):
44         __label__ = "World"
45         COMPAT_ENGINES = set(['BLENDER_RENDER'])
46
47         def draw(self, context):
48                 layout = self.layout
49
50                 world = context.world
51
52                 row = layout.row()
53                 row.itemR(world, "paper_sky")
54                 row.itemR(world, "blend_sky")
55                 row.itemR(world, "real_sky")
56                         
57                 row = layout.row()
58                 row.column().itemR(world, "horizon_color")
59                 col = row.column()
60                 col.itemR(world, "zenith_color")
61                 col.active = world.blend_sky
62                 row.column().itemR(world, "ambient_color")
63                 
64 class WORLD_PT_mist(WorldButtonsPanel):
65         __label__ = "Mist"
66         COMPAT_ENGINES = set(['BLENDER_RENDER'])
67
68         def draw_header(self, context):
69                 world = context.world
70
71                 self.layout.itemR(world.mist, "enabled", text="")
72
73         def draw(self, context):
74                 layout = self.layout
75                 
76                 world = context.world
77
78                 layout.active = world.mist.enabled
79
80                 flow = layout.column_flow()
81                 flow.itemR(world.mist, "intensity", slider=True)
82                 flow.itemR(world.mist, "start")
83                 flow.itemR(world.mist, "depth")
84                 flow.itemR(world.mist, "height")
85
86                 layout.itemR(world.mist, "falloff")
87                 
88 class WORLD_PT_stars(WorldButtonsPanel):
89         __label__ = "Stars"
90         COMPAT_ENGINES = set(['BLENDER_RENDER'])
91
92         def draw_header(self, context):
93                 world = context.world
94
95                 self.layout.itemR(world.stars, "enabled", text="")
96
97         def draw(self, context):
98                 layout = self.layout
99                 
100                 world = context.world
101
102                 layout.active = world.stars.enabled
103
104                 flow = layout.column_flow()
105                 flow.itemR(world.stars, "size")
106                 flow.itemR(world.stars, "color_randomization", text="Colors")
107                 flow.itemR(world.stars, "min_distance", text="Min. Dist")
108                 flow.itemR(world.stars, "average_separation", text="Separation")
109                 
110 class WORLD_PT_ambient_occlusion(WorldButtonsPanel):
111         __label__ = "Ambient Occlusion"
112         COMPAT_ENGINES = set(['BLENDER_RENDER'])
113
114         def draw_header(self, context):
115                 world = context.world
116
117                 self.layout.itemR(world.ambient_occlusion, "enabled", text="")
118
119         def draw(self, context):
120                 layout = self.layout
121                 
122                 ao = context.world.ambient_occlusion
123                 
124                 layout.active = ao.enabled
125                 
126                 layout.itemR(ao, "gather_method", expand=True)
127
128                 split = layout.split()
129                 
130                 col = split.column()
131                 col.itemL(text="Attenuation:")
132                 col.itemR(ao, "distance")
133                 col.itemR(ao, "falloff")
134                 sub = col.row()
135                 sub.active = ao.falloff
136                 sub.itemR(ao, "falloff_strength", text="Strength")
137         
138                 if ao.gather_method == 'RAYTRACE':
139                         col = split.column()
140                         
141                         col.itemL(text="Sampling:")
142                         col.itemR(ao, "sample_method", text="")
143
144                         sub = col.column()
145                         sub.itemR(ao, "samples")
146
147                         if ao.sample_method == 'ADAPTIVE_QMC':
148                                 sub.itemR(ao, "threshold")
149                                 sub.itemR(ao, "adapt_to_speed", slider=True)
150                         elif ao.sample_method == 'CONSTANT_JITTERED':
151                                 sub.itemR(ao, "bias")
152                                                 
153                 if ao.gather_method == 'APPROXIMATE':
154                         col = split.column()
155                         
156                         col.itemL(text="Sampling:")
157                         col.itemR(ao, "error_tolerance", text="Error")
158                         col.itemR(ao, "pixel_cache")
159                         col.itemR(ao, "correction")
160                         
161                 col = layout.column()
162                 col.itemL(text="Influence:")
163                 
164                 col.row().itemR(ao, "blend_mode", expand=True)
165                 
166                 split = layout.split()
167                 
168                 col = split.column()
169                 col.itemR(ao, "energy")
170                 
171                 col = split.column()
172                 colsub = col.split(percentage=0.3)
173                 colsub.itemL(text="Color:")
174                 colsub.itemR(ao, "color", text="")
175                 
176
177 bpy.types.register(WORLD_PT_context_world)      
178 bpy.types.register(WORLD_PT_preview)
179 bpy.types.register(WORLD_PT_world)
180 bpy.types.register(WORLD_PT_ambient_occlusion)
181 bpy.types.register(WORLD_PT_mist)
182 bpy.types.register(WORLD_PT_stars)