Skip to content

Commit

Permalink
blender: Enable material preview in UI
Browse files Browse the repository at this point in the history
It's not fully working yet. It does render the preview, but for some
reason, all the preview objects are shown overlapping at once. I haven't
found the flag that blender uses to hide the extra meshes yet.
  • Loading branch information
vkoskiv committed Dec 20, 2023
1 parent 8dd64ce commit f0619c0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bindings/blender_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def dump(obj):
class CrayRender(bpy.types.RenderEngine):
bl_idname = "C_RAY"
bl_label = "c-ray for Blender"
bl_use_preview = False
bl_use_preview = True
bl_use_shading_nodes_custom = False

def __init__(self):
Expand Down
14 changes: 14 additions & 0 deletions bindings/blender_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,19 @@ def draw(self, context):
col = layout.column()
col.prop(context.scene.c_ray, "bounces", text="Total")

class C_RAY_MATERIAL_PT_preview(CrayButtonsPanel, Panel):
bl_label = "Preview"
bl_context = "material"
bl_options = {'DEFAULT_CLOSED'}

@classmethod
def poll(cls, context):
mat = context.material
return mat and (not mat.grease_pencil) and CrayButtonsPanel.poll(context)

def draw(self, context):
self.layout.template_preview(context.material)

class C_RAY_CAMERA_PT_dof(CrayButtonsPanel, Panel):
bl_label = "Depth of Field"
bl_context = "data"
Expand Down Expand Up @@ -165,6 +178,7 @@ def get_panels():
C_RAY_RENDER_PT_performance_clustering,
C_RAY_RENDER_PT_light_paths,
C_RAY_RENDER_PT_light_paths_bounces,
C_RAY_MATERIAL_PT_preview,
C_RAY_CAMERA_PT_dof,
C_RAY_CAMERA_PT_dof_aperture,
)
Expand Down

0 comments on commit f0619c0

Please sign in to comment.