Expand Cycles to use the new baking API in Blender. It works on the selected object, and the panel can be accessed in the Render panel (similar to where it is for the Blender Internal). It bakes for the active texture of each material of the object. The active texture is currently defined as the active Image Texture node present in the material nodetree. If you don't want the baking to override an existent material, make sure the active Image Texture node is not connected to the nodetree. The active texture is also the texture shown in the viewport in the rendered mode. Remember to save your images after the baking is complete. Note: Bake currently only works in the CPU Note: This is not supported by Cycles standalone because a lot of the work is done in Blender as part of the operator only, not the engine (Cycles). Documentation: http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Bake Supported Passes: ----------------- Data Passes * Normal * UV * Diffuse/Glossy/Transmission/Subsurface/Emit Color Light Passes * AO * Combined * Shadow * Diffuse/Glossy/Transmission/Subsurface/Emit Direct/Indirect * Environment Review: D421 Reviewed by: Campbell Barton, Brecht van Lommel, Sergey Sharybin, Thomas Dinge Original design by Brecht van Lommel. The entire commit history can be found on the branch: bake-cycles
102 lines
2.5 KiB
Python
102 lines
2.5 KiB
Python
#
|
|
# Copyright 2011-2013 Blender Foundation
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License
|
|
#
|
|
|
|
# <pep8 compliant>
|
|
|
|
|
|
def init():
|
|
import bpy
|
|
import _cycles
|
|
import os.path
|
|
|
|
path = os.path.dirname(__file__)
|
|
user_path = os.path.dirname(os.path.abspath(bpy.utils.user_resource('CONFIG', '')))
|
|
|
|
_cycles.init(path, user_path)
|
|
|
|
|
|
def create(engine, data, scene, region=0, v3d=0, rv3d=0, preview_osl=False):
|
|
import bpy
|
|
import _cycles
|
|
|
|
data = data.as_pointer()
|
|
userpref = bpy.context.user_preferences.as_pointer()
|
|
scene = scene.as_pointer()
|
|
if region:
|
|
region = region.as_pointer()
|
|
if v3d:
|
|
v3d = v3d.as_pointer()
|
|
if rv3d:
|
|
rv3d = rv3d.as_pointer()
|
|
|
|
engine.session = _cycles.create(engine.as_pointer(), userpref, data, scene, region, v3d, rv3d, preview_osl)
|
|
|
|
|
|
def free(engine):
|
|
if hasattr(engine, "session"):
|
|
if engine.session:
|
|
import _cycles
|
|
_cycles.free(engine.session)
|
|
del engine.session
|
|
|
|
|
|
def render(engine):
|
|
import _cycles
|
|
if hasattr(engine, "session"):
|
|
_cycles.render(engine.session)
|
|
|
|
|
|
def bake(engine, obj, pass_type, pixel_array, num_pixels, depth, result):
|
|
import _cycles
|
|
session = getattr(engine, "session", None)
|
|
if session is not None:
|
|
_cycles.bake(engine.session, obj.as_pointer(), pass_type, pixel_array.as_pointer(), num_pixels, depth, result.as_pointer())
|
|
|
|
def reset(engine, data, scene):
|
|
import _cycles
|
|
data = data.as_pointer()
|
|
scene = scene.as_pointer()
|
|
_cycles.reset(engine.session, data, scene)
|
|
|
|
|
|
def update(engine, data, scene):
|
|
import _cycles
|
|
_cycles.sync(engine.session)
|
|
|
|
|
|
def draw(engine, region, v3d, rv3d):
|
|
import _cycles
|
|
v3d = v3d.as_pointer()
|
|
rv3d = rv3d.as_pointer()
|
|
|
|
# draw render image
|
|
_cycles.draw(engine.session, v3d, rv3d)
|
|
|
|
|
|
def available_devices():
|
|
import _cycles
|
|
return _cycles.available_devices()
|
|
|
|
|
|
def with_osl():
|
|
import _cycles
|
|
return _cycles.with_osl
|
|
|
|
|
|
def with_network():
|
|
import _cycles
|
|
return _cycles.with_network
|