114 cout <<
"FRS_set_context: context 0x" << C <<
" scene 0x" <<
CTX_data_scene(C) << endl;
132 int width = re->
winx;
133 int height = re->
winy;
139 float thickness = 1.0f;
145 thickness = height / 480.0f;
160 cout <<
"\n=== Dimensions of the 2D image coordinate system ===" << endl;
161 cout <<
"Width : " << width << endl;
162 cout <<
"Height : " << height << endl;
164 cout <<
"Border : (" << xmin <<
", " << ymin <<
") - (" << xmax <<
", " << ymax <<
")"
167 cout <<
"Unit line thickness : " << thickness <<
" pixel(s)" << endl;
177 if (
ELEM(*name,
'\'',
'\\')) {
188 const char *fmt =
"__import__('parameter_editor').process('%s', '%s')\n";
208 int target_condition = 0;
209 int num_non_target_positive_conditions = 0;
210 int num_non_target_negative_conditions = 0;
212 for (
int i = 0; i < num_edge_types; i++) {
213 if (conditions[i].edge_type == target) {
214 target_condition = conditions[i].
value;
216 else if (conditions[i].value > 0) {
217 ++num_non_target_positive_conditions;
219 else if (conditions[i].value < 0) {
220 ++num_non_target_negative_conditions;
227 if (num_non_target_positive_conditions > 0) {
230 if (target_condition > 0) {
233 if (target_condition < 0) {
236 if (num_non_target_negative_conditions > 0) {
241 if (target_condition > 0) {
244 if (num_non_target_negative_conditions > 0) {
247 if (target_condition < 0) {
250 if (num_non_target_positive_conditions > 0) {
257 if (target_condition > 0) {
260 if (target_condition < 0) {
264 if (num_non_target_positive_conditions > 0) {
267 if (num_non_target_negative_conditions > 0) {
272 if (num_non_target_negative_conditions > 0) {
275 if (num_non_target_positive_conditions > 0) {
293 if (re->
display->test_break()) {
301 cout <<
"\n=== Rendering options ===" << endl;
305 switch (config->
mode) {
308 cout <<
"Modules :" << endl;
312 const char *id_name = module_conf.
script->id.name + 2;
320 CLOG_WARN(&
LOG,
"Scripts disabled, skipping style module '%s'", id_name);
325 cout <<
" " << layer_count + 1 <<
": " << id_name;
326 if (module_conf.
script->filepath) {
327 cout <<
" (" << module_conf.
script->filepath <<
")";
347 int use_ridges_and_valleys = 0;
348 int use_suggestive_contours = 0;
349 int use_material_boundaries = 0;
363 cout <<
"Linesets:" << endl;
368 cout <<
" " << layer_count + 1 <<
": " << lineset.
name <<
" - "
376 ++use_ridges_and_valleys;
377 ++use_suggestive_contours;
378 ++use_material_boundaries;
382 for (
int i = 0; i < num_edge_types; i++) {
384 conditions[i].
value = 0;
387 conditions[i].
value = 1;
390 conditions[i].
value = -1;
401 for (
int i = 0; i < num_edge_types; i++) {
402 conditions[i].
value *= -1;
404 logical_and = !logical_and;
409 ++use_ridges_and_valleys;
417 ++use_suggestive_contours;
422 ++use_material_boundaries;
448 cout <<
"Ridges and valleys : "
450 cout <<
"Suggestive contours : "
452 cout <<
"Suggestive contour Kr derivative epsilon : "
454 cout <<
"Material boundaries : "
461 bool diffuse =
false,
z =
false;
474 cout <<
"Passes :" << endl;
475 cout <<
" Diffuse = " << (diffuse ?
"enabled" :
"disabled") << endl;
476 cout <<
" Z = " << (
z ?
"enabled" :
"disabled") << endl;
492 if (freestyle_render ==
nullptr || freestyle_render->
result ==
nullptr) {
504 cout <<
"No source render layer to composite" << endl;
512 cout <<
"No source result image to composite" << endl;
518 cout <<
"src: " << rl->
rectx <<
" x " << rl->
recty << endl;
525 cout <<
"No destination render layer to composite to" << endl;
530 const char *dest_pass;
544 cout <<
"No destination result image to composite to" << endl;
550 cout <<
"dest: " << rl->
rectx <<
" x " << rl->
recty << endl;
554 const int rectx = re->
rectx;
555 const int recty = re->
recty;
556 for (
int y = 0;
y < recty;
y++) {
557 for (
int x = 0;
x < rectx;
x++) {
558 const float *pixSrc = src + 4 * (rectx *
y +
x);
559 if (pixSrc[3] > 0.0) {
560 float *pixDest = dest + 4 * (rectx *
y +
x);
602 cout <<
"#===============================================================" << endl;
603 cout <<
"# Freestyle" << endl;
604 cout <<
"#===============================================================" << endl;
623 cout <<
"----------------------------------------------------------" << endl;
624 cout <<
"| " << (re->
scene->
id.
name + 2) <<
"|" << view_layer->
name << endl;
625 cout <<
"----------------------------------------------------------" << endl;
648 prepare(re, view_layer, depsgraph);
650 if (re->
display->test_break()) {
653 cout <<
"Break" << endl;
665 Render *freestyle_render =
nullptr;
666 if (strokeCount > 0) {
674 if (freestyle_render) {
695 printf(
"View map cache freed\n");
746 if (lineset->
group) {
748 lineset->
group =
nullptr;
Blender kernel freestyle line style functionality.
#define SNPRINTF_UTF8(dst, format,...)
#define CLOG_WARN(clg_ref,...)
The spinal tap of the system.
Object groups, one object can be in many groups at once.
#define RE_PASSNAME_COMBINED
#define RE_PASSNAME_DEPTH
#define RE_PASSNAME_DIFFUSE_COLOR
#define RE_PASSNAME_FREESTYLE
Read Blender memory allocation and freeing.
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
void setWidth(uint width)
void setBorder(int xmin, int ymin, int xmax, int ymax)
void setThickness(float thickness)
void setHeight(uint height)
static blender::Material * GetStrokeShader(blender::Main *bmain, blender::bNodeTree *iNodeTree, bool do_id_user)
int LoadMesh(blender::Render *re, blender::ViewLayer *view_layer, blender::Depsgraph *depsgraph)
void setComputeSuggestiveContoursFlag(bool b)
void setPassZ(float *buf, int width, int height)
bool getFaceSmoothness() const
bool getComputeMaterialBoundariesFlag() const
void setSphereRadius(float s)
void setComputeMaterialBoundariesFlag(bool b)
void setVisibilityAlgo(int algo)
void setComputeRidgesAndValleysFlag(bool b)
void setFaceSmoothness(bool iBool)
void setPassDiffuse(float *buf, int width, int height)
float getSphereRadius() const
void setContext(blender::bContext *C)
blender::Render * RenderStrokes(blender::Render *re, bool render)
void DeleteViewMap(bool freeCache=false)
bool getComputeSuggestiveContoursFlag() const
void setViewMapCache(bool iBool)
void toggleLayer(uint index, bool iDisplay)
void setSuggestiveContourKrDerivativeEpsilon(float dkr)
void setCreaseAngle(float angle)
float getCreaseAngle() const
bool getComputeRidgesAndValleysFlag() const
float getSuggestiveContourKrDerivativeEpsilon() const
void setView(AppView *iView)
void setRenderMonitor(RenderMonitor *iRenderMonitor)
void InsertStyleModule(uint index, const char *iFileName)
static char * create_lineset_handler(char *layer_name, char *lineset_name)
int FRS_is_freestyle_enabled(struct ViewLayer *view_layer)
void FRS_delete_active_lineset(struct FreestyleConfig *config)
void BKE_scene_graph_update_for_newframe(Depsgraph *depsgraph)
char * STRNCPY(char(&dst)[N], const char *src)
@ FREESTYLE_SEL_EDGE_TYPES
void RE_FreeRender(Render *re)
void FRS_free_view_map_cache(void)
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
MINLINE void blend_color_mix_float(float dst[4], const float src1[4], const float src2[4])
static int displayed_layer_count(ViewLayer *view_layer)
static void init_view(Render *re)
void DEG_graph_free(Depsgraph *graph)
struct FreestyleGlobals g_freestyle
RenderLayer * RE_GetRenderLayer(RenderResult *rr, const char *name)
static Config::Path * pathconfig
bool FRS_move_active_lineset(struct FreestyleConfig *config, int direction)
char * BLI_sprintfN(const char *__restrict format,...) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_PRINTF_FORMAT(1
Depsgraph * DEG_graph_new(Main *bmain, Scene *scene, ViewLayer *view_layer, eEvaluationMode mode)
void * BLI_findstring(const ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
@ FREESTYLE_RIDGES_AND_VALLEYS_FLAG
@ FREESTYLE_SUGGESTIVE_CONTOURS_FLAG
@ FREESTYLE_FACE_SMOOTHNESS_FLAG
@ FREESTYLE_VIEW_MAP_CACHE
@ FREESTYLE_MATERIAL_BOUNDARIES_FLAG
@ FREESTYLE_AS_RENDER_PASS
void BKE_freestyle_lineset_unique_name(struct FreestyleConfig *config, struct FreestyleLineSet *lineset)
void RE_GetCameraWindow(Render *re, const Object *camera, float r_winmat[4][4])
ImBuf * RE_RenderLayerGetPassImBuf(RenderLayer *rl, const char *name, const char *viewname)
static bCallbackFuncStore load_post_callback_funcstore
void FRS_end_stroke_rendering(struct Render *re)
void FRS_init_stroke_renderer(struct Render *re)
static bool test_edge_type_conditions(edge_type_condition *conditions, int num_edge_types, bool logical_and, int target, bool distinct)
void FRS_set_context(struct bContext *C)
void FRS_do_stroke_rendering(struct Render *re, struct ViewLayer *view_layer)
void BKE_callback_add(bCallbackFuncStore *funcstore, eCbEvent evt)
static bool freestyle_is_initialized
T * DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
struct FreestyleLineSet * BKE_freestyle_lineset_get_active(struct FreestyleConfig *config)
bool BKE_freestyle_lineset_delete(struct FreestyleConfig *config, struct FreestyleLineSet *lineset)
float * RE_RenderLayerGetPass(RenderLayer *rl, const char *name, const char *viewname)
constexpr size_t ARRAY_SIZE(const T(&arg)[N]) noexcept
void unit_m4(float m[4][4])
void IMB_partial_update_mark_full(ImBuf *ibuf)
static char * escape_quotes(char *name)
static void load_post_callback(Main *, PointerRNA **, const int, void *)
MINLINE void zero_v3(float r[3])
@ R_LINE_THICKNESS_RELATIVE
@ R_LINE_THICKNESS_ABSOLUTE
@ FREESTYLE_LINESET_FE_NOT
@ FREESTYLE_LINESET_CURRENT
@ FREESTYLE_LINESET_ENABLED
@ FREESTYLE_LINESET_FE_AND
static bool lineset_copied
void FRS_begin_stroke_rendering(struct Render *re)
@ G_FLAG_SCRIPT_AUTOEXEC_FAIL_QUIET
@ G_FLAG_SCRIPT_AUTOEXEC_FAIL
void FRS_composite_result(struct Render *re, struct ViewLayer *view_layer, struct Render *freestyle_render)
static FreestyleLineSet lineset_buffer
void RE_create_render_pass(RenderResult *rr, const char *name, int channels, const char *chan_id, const char *layername, const char *viewname, const bool allocate)
@ FREESTYLE_FE_SILHOUETTE
@ FREESTYLE_FE_EXTERNAL_CONTOUR
@ FREESTYLE_FE_RIDGE_VALLEY
@ FREESTYLE_FE_SUGGESTIVE_CONTOUR
@ FREESTYLE_FE_MATERIAL_BOUNDARY
static void prepare(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph)
Scene * CTX_data_scene(const bContext *C)
void FRS_copy_active_lineset(struct FreestyleConfig *config)
@ FREESTYLE_ALGO_CULLED_ADAPTIVE_CUMULATIVE
@ FREESTYLE_ALGO_ADAPTIVE_CUMULATIVE
void FRS_paste_active_lineset(struct FreestyleConfig *config)
Scene * DEG_get_evaluated_scene(const Depsgraph *graph)
struct Material * FRS_create_stroke_material(struct Main *bmain, struct FreestyleLineStyle *linestyle)
static Controller * controller
RenderLayer * render_get_single_layer(Render *re, RenderResult *rr)
void void void bool BLI_listbase_link_move(ListBase *listbase, void *vlink, int step) ATTR_NONNULL()
Object * RE_GetCamera(Render *re)
@ FREESTYLE_CONTROL_EDITOR_MODE
@ FREESTYLE_CONTROL_SCRIPT_MODE
std::shared_ptr< RenderDisplay > display
ListBaseT< FreestyleModuleConfig > modules
eFreestyleControl_Mode mode
eFreestyleConfig_Flags flags
ListBaseT< FreestyleLineSet > linesets
eFreestyleLineSet_EdgeTypes exclude_edge_types
eFreestyleLineSet_Selection selection
struct FreestyleLineStyle * linestyle
eFreestyleLineSet_EdgeTypes edge_types
struct Collection * group
eFreestyleLineSet_Flags flags
struct bNodeTree * nodetree
float * float_data_for_write()
float unit_line_thickness
ListBaseT< RenderPass > passes
ListBaseT< ViewLayer > view_layers
struct FreestyleConfig freestyle_config