Cycles/Eeeve: unify film transparent setting
For existing files, it will use the setting from Cycles or Eevee depending on the render engine in the scene. Differential Revision: https://developer.blender.org/D4874
This commit is contained in:
@@ -417,11 +417,6 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
|
|||||||
min=0.0, max=10.0,
|
min=0.0, max=10.0,
|
||||||
default=1.0,
|
default=1.0,
|
||||||
)
|
)
|
||||||
film_transparent: BoolProperty(
|
|
||||||
name="Transparent",
|
|
||||||
description="World background is transparent, for compositing the render over another background",
|
|
||||||
default=False,
|
|
||||||
)
|
|
||||||
film_transparent_glass: BoolProperty(
|
film_transparent_glass: BoolProperty(
|
||||||
name="Transparent Glass",
|
name="Transparent Glass",
|
||||||
description="Render transmissive surfaces as transparent, for compositing glass over another background",
|
description="Render transmissive surfaces as transparent, for compositing glass over another background",
|
||||||
|
|||||||
@@ -528,31 +528,32 @@ class CYCLES_RENDER_PT_film(CyclesButtonsPanel, Panel):
|
|||||||
|
|
||||||
|
|
||||||
class CYCLES_RENDER_PT_film_transparency(CyclesButtonsPanel, Panel):
|
class CYCLES_RENDER_PT_film_transparency(CyclesButtonsPanel, Panel):
|
||||||
bl_label = "Transparency"
|
bl_label = "Transparent"
|
||||||
bl_parent_id = "CYCLES_RENDER_PT_film"
|
bl_parent_id = "CYCLES_RENDER_PT_film"
|
||||||
|
|
||||||
def draw_header(self, context):
|
def draw_header(self, context):
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
|
|
||||||
scene = context.scene
|
scene = context.scene
|
||||||
cscene = scene.cycles
|
rd = scene.render
|
||||||
|
|
||||||
layout.prop(cscene, "film_transparent", text="")
|
layout.prop(rd, "film_transparent", text="")
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
layout.use_property_split = True
|
layout.use_property_split = True
|
||||||
layout.use_property_decorate = False
|
layout.use_property_decorate = False
|
||||||
scene = context.scene
|
scene = context.scene
|
||||||
|
rd = scene.render
|
||||||
cscene = scene.cycles
|
cscene = scene.cycles
|
||||||
|
|
||||||
layout.active = cscene.film_transparent
|
layout.active = rd.film_transparent
|
||||||
|
|
||||||
col = layout.column()
|
col = layout.column()
|
||||||
col.prop(cscene, "film_transparent_glass", text="Transparent Glass")
|
col.prop(cscene, "film_transparent_glass", text="Transparent Glass")
|
||||||
|
|
||||||
sub = col.column()
|
sub = col.column()
|
||||||
sub.active = cscene.film_transparent and cscene.film_transparent_glass
|
sub.active = rd.film_transparent and cscene.film_transparent_glass
|
||||||
sub.prop(cscene, "film_transparent_roughness", text="Roughness Threshold")
|
sub.prop(cscene, "film_transparent_roughness", text="Roughness Threshold")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1354,16 +1354,7 @@ void BlenderSync::sync_world(BL::Depsgraph &b_depsgraph, bool update_all)
|
|||||||
}
|
}
|
||||||
|
|
||||||
PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
|
PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
|
||||||
|
background->transparent = b_scene.render().film_transparent();
|
||||||
/* when doing preview render check for BI's transparency settings,
|
|
||||||
* this is so because Blender's preview render routines are not able
|
|
||||||
* to tweak all cycles's settings depending on different circumstances
|
|
||||||
*/
|
|
||||||
if (b_engine.is_preview() == false)
|
|
||||||
background->transparent = get_boolean(cscene, "film_transparent");
|
|
||||||
else
|
|
||||||
background->transparent = b_scene.render().alpha_mode() ==
|
|
||||||
BL::RenderSettings::alpha_mode_TRANSPARENT;
|
|
||||||
|
|
||||||
if (background->transparent) {
|
if (background->transparent) {
|
||||||
background->transparent_glass = get_boolean(cscene, "film_transparent_glass");
|
background->transparent_glass = get_boolean(cscene, "film_transparent_glass");
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ def do_previews(do_objects, do_collections, do_scenes, do_data_intern):
|
|||||||
scene.collection.objects.link(light)
|
scene.collection.objects.link(light)
|
||||||
|
|
||||||
scene.render.engine = 'CYCLES'
|
scene.render.engine = 'CYCLES'
|
||||||
scene.cycles.film_transparent = True
|
scene.render.film_transparent = True
|
||||||
# TODO: define Cycles world?
|
# TODO: define Cycles world?
|
||||||
|
|
||||||
scene.render.image_settings.file_format = 'PNG'
|
scene.render.image_settings.file_format = 'PNG'
|
||||||
|
|||||||
@@ -850,9 +850,6 @@ class CLIP_OT_setup_tracking_scene(Operator):
|
|||||||
# Ensure no nodes were created on the position of existing node.
|
# Ensure no nodes were created on the position of existing node.
|
||||||
self._offsetNodes(tree)
|
self._offsetNodes(tree)
|
||||||
|
|
||||||
if hasattr(scene, "cycles"):
|
|
||||||
scene.cycles.film_transparent = True
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _createMesh(collection, name, vertices, faces):
|
def _createMesh(collection, name, vertices, faces):
|
||||||
from bpy_extras.io_utils import unpack_list
|
from bpy_extras.io_utils import unpack_list
|
||||||
|
|||||||
@@ -495,7 +495,7 @@ class RENDER_PT_eevee_film(RenderButtonsPanel, Panel):
|
|||||||
|
|
||||||
col = layout.column()
|
col = layout.column()
|
||||||
col.prop(rd, "filter_size")
|
col.prop(rd, "filter_size")
|
||||||
col.prop(rd, "alpha_mode", text="Alpha")
|
col.prop(rd, "film_transparent", text="Transparent")
|
||||||
|
|
||||||
|
|
||||||
class RENDER_PT_eevee_film_overscan(RenderButtonsPanel, Panel):
|
class RENDER_PT_eevee_film_overscan(RenderButtonsPanel, Panel):
|
||||||
@@ -573,7 +573,7 @@ class RENDER_PT_opengl_film(RenderButtonsPanel, Panel):
|
|||||||
layout.use_property_decorate = False # No animation.
|
layout.use_property_decorate = False # No animation.
|
||||||
|
|
||||||
rd = context.scene.render
|
rd = context.scene.render
|
||||||
layout.prop(rd, "alpha_mode")
|
layout.prop(rd, "film_transparent", text="Transparent")
|
||||||
|
|
||||||
|
|
||||||
class RENDER_PT_opengl_lighting(RenderButtonsPanel, Panel):
|
class RENDER_PT_opengl_lighting(RenderButtonsPanel, Panel):
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
* \note Use #STRINGIFY() rather than defining with quotes.
|
* \note Use #STRINGIFY() rather than defining with quotes.
|
||||||
*/
|
*/
|
||||||
#define BLENDER_VERSION 280
|
#define BLENDER_VERSION 280
|
||||||
#define BLENDER_SUBVERSION 67
|
#define BLENDER_SUBVERSION 68
|
||||||
/** Several breakages with 280, e.g. collections vs layers. */
|
/** Several breakages with 280, e.g. collections vs layers. */
|
||||||
#define BLENDER_MINVERSION 280
|
#define BLENDER_MINVERSION 280
|
||||||
#define BLENDER_MINSUBVERSION 0
|
#define BLENDER_MINSUBVERSION 0
|
||||||
|
|||||||
@@ -396,6 +396,20 @@ void blo_do_versions_cycles(FileData *UNUSED(fd), Library *UNUSED(lib), Main *bm
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!MAIN_VERSION_ATLEAST(bmain, 280, 68)) {
|
||||||
|
/* Unify Cycles and EEVEE Film Transparency. */
|
||||||
|
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
|
||||||
|
if (STREQ(scene->r.engine, RE_engine_id_CYCLES)) {
|
||||||
|
IDProperty *cscene = cycles_properties_from_ID(&scene->id);
|
||||||
|
if (cscene) {
|
||||||
|
bool cycles_film_transparency = cycles_property_boolean(
|
||||||
|
cscene, "film_transparent", false);
|
||||||
|
scene->r.alphamode = cycles_film_transparency ? R_ALPHAPREMUL : R_ADDSKY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_versions_after_linking_cycles(Main *bmain)
|
void do_versions_after_linking_cycles(Main *bmain)
|
||||||
|
|||||||
@@ -125,13 +125,6 @@ BlenderStrokeRenderer::BlenderStrokeRenderer(Render *re, int render_count) : Str
|
|||||||
/* Render with transparent background. */
|
/* Render with transparent background. */
|
||||||
freestyle_scene->r.alphamode = R_ALPHAPREMUL;
|
freestyle_scene->r.alphamode = R_ALPHAPREMUL;
|
||||||
|
|
||||||
if (STREQ(freestyle_scene->r.engine, RE_engine_id_CYCLES)) {
|
|
||||||
PointerRNA freestyle_scene_ptr;
|
|
||||||
RNA_id_pointer_create(&freestyle_scene->id, &freestyle_scene_ptr);
|
|
||||||
PointerRNA freestyle_cycles_ptr = RNA_pointer_get(&freestyle_scene_ptr, "cycles");
|
|
||||||
RNA_boolean_set(&freestyle_cycles_ptr, "film_transparent", 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (G.debug & G_DEBUG_FREESTYLE) {
|
if (G.debug & G_DEBUG_FREESTYLE) {
|
||||||
printf("%s: %d thread(s)\n", __func__, BKE_render_num_threads(&freestyle_scene->r));
|
printf("%s: %d thread(s)\n", __func__, BKE_render_num_threads(&freestyle_scene->r));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5498,16 +5498,6 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
|
|||||||
StructRNA *srna;
|
StructRNA *srna;
|
||||||
PropertyRNA *prop;
|
PropertyRNA *prop;
|
||||||
|
|
||||||
static const EnumPropertyItem alpha_mode_items[] = {
|
|
||||||
{R_ADDSKY, "SKY", 0, "Sky", "Transparent pixels are filled with sky color"},
|
|
||||||
{R_ALPHAPREMUL,
|
|
||||||
"TRANSPARENT",
|
|
||||||
0,
|
|
||||||
"Transparent",
|
|
||||||
"World background is transparent with premultiplied alpha"},
|
|
||||||
{0, NULL, 0, NULL, NULL},
|
|
||||||
};
|
|
||||||
|
|
||||||
static const EnumPropertyItem display_mode_items[] = {
|
static const EnumPropertyItem display_mode_items[] = {
|
||||||
{R_OUTPUT_SCREEN,
|
{R_OUTPUT_SCREEN,
|
||||||
"SCREEN",
|
"SCREEN",
|
||||||
@@ -5735,11 +5725,12 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
|
|||||||
prop, "Filter Size", "Width over which the reconstruction filter combines samples");
|
prop, "Filter Size", "Width over which the reconstruction filter combines samples");
|
||||||
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
|
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
|
||||||
|
|
||||||
prop = RNA_def_property(srna, "alpha_mode", PROP_ENUM, PROP_NONE);
|
prop = RNA_def_property(srna, "film_transparent", PROP_BOOLEAN, PROP_NONE);
|
||||||
RNA_def_property_enum_sdna(prop, NULL, "alphamode");
|
RNA_def_property_boolean_sdna(prop, NULL, "alphamode", R_ALPHAPREMUL);
|
||||||
RNA_def_property_enum_items(prop, alpha_mode_items);
|
|
||||||
RNA_def_property_ui_text(
|
RNA_def_property_ui_text(
|
||||||
prop, "Alpha Mode", "Representation of alpha information in the RGBA pixels");
|
prop,
|
||||||
|
"Transparent",
|
||||||
|
"World background is transparent, for compositing the render over another background");
|
||||||
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update");
|
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update");
|
||||||
|
|
||||||
prop = RNA_def_property(srna, "use_freestyle", PROP_BOOLEAN, PROP_NONE);
|
prop = RNA_def_property(srna, "use_freestyle", PROP_BOOLEAN, PROP_NONE);
|
||||||
|
|||||||
Reference in New Issue
Block a user