17#include "RNA_prototypes.hh"
109 cout <<
"Stroke rendering engine : " <<
freestyle_scene->r.engine << endl;
153 object_camera->
loc[2] = 1.0f;
192 self->_z_delta *= 10.0f;
212 bNode *output_linestyle =
nullptr;
226 output_linestyle = node;
234 nullptr, &ma->
id,
"stroke_shader",
"ShaderNodeTree");
239 input_attr_color->
location[0] = 0.0f;
240 input_attr_color->
location[1] = -200.0f;
247 mix_rgb_color->
location[0] = 200.0f;
248 mix_rgb_color->
location[1] = -200.0f;
254 input_attr_alpha->
location[0] = 400.0f;
255 input_attr_alpha->
location[1] = 300.0f;
262 mix_rgb_alpha->
location[0] = 600.0f;
263 mix_rgb_alpha->
location[1] = 300.0f;
269 shader_emission->
location[0] = 400.0f;
270 shader_emission->
location[1] = -200.0f;
274 input_light_path->
location[0] = 400.0f;
275 input_light_path->
location[1] = 100.0f;
279 mix_shader_color->
location[0] = 600.0f;
280 mix_shader_color->
location[1] = -100.0f;
284 shader_transparent->
location[0] = 600.0f;
285 shader_transparent->
location[1] = 100.0f;
289 mix_shader_alpha->
location[0] = 800.0f;
290 mix_shader_alpha->
location[1] = 100.0f;
294 output_material->
location[0] = 1000.0f;
295 output_material->
location[1] = 100.0f;
333 if (output_linestyle) {
379 color[0] = color[1] = color[2] =
RNA_float_get(&fromptr,
"default_value");
404 input_uvmap->
location[0] = node->location[0] - 200.0f;
405 input_uvmap->
location[1] = node->location[1];
407 if (node->custom1 & 1) {
419 *ntree, *input_uvmap, *fromsock, *link->
tonode, *link->
tosock);
448 const vector<Strip *> &strips = iStrokeRep->
getStrips();
449 const bool hasTex = iStrokeRep->
hasTex();
450 int totvert = 0, totedge = 0, faces_num = 0, totloop = 0;
451 int visible_faces, visible_segments;
452 for (vector<Strip *>::const_iterator s = strips.begin(), send = strips.end(); s != send; ++s) {
453 Strip::vertex_container &strip_vertices = (*s)->vertices();
457 if (visible_faces == 0) {
461 totvert += visible_faces + visible_segments * 2;
462 totedge += visible_faces * 2 + visible_segments;
463 faces_num += visible_faces;
464 totloop += visible_faces * 3;
468 vector<StrokeGroup *> *groups = hasTex ? &
self->texturedStrokeGroups : &
self->strokeGroups;
470 if (groups->empty() || !(groups->back()->totvert + totvert <
MESH_MAX_VERTS &&
471 groups->back()->materials.size() + 1 <
MAXMAT))
474 groups->push_back(group);
477 group = groups->back();
479 group->
strokes.push_back(iStrokeRep);
496 xl = xu = yl = yu = 0;
497 for (
int i = 0;
i < 3;
i++) {
512 return !(xl == 3 || xu == 3 || yl == 3 || yu == 3);
518 int *visible_segments)
const
520 const int strip_vertex_count = strip_vertices.size();
521 Strip::vertex_container::iterator
v[3];
528 v[0] = strip_vertices.begin();
531 *visible_faces = *visible_segments = 0;
533 for (
int n = 2; n < strip_vertex_count; n++,
v[0]++,
v[1]++,
v[2]++) {
540 (*visible_segments)++;
553 vector<StrokeGroup *>::const_iterator it, itend;
566 vector<StrokeGroup *>::const_iterator it, itend;
614 float3 *vert_positions = position_attr.
span.data();
615 int2 *edges = edge_verts_attr.span.data();
616 int *corner_verts = corner_vert_attr.span.data();
617 int *corner_edges = corner_edge_attr.span.data();
618 int *material_indices = material_index_attr.span.data();
645 const int matnr = item.value;
646 mesh->
mat[matnr] = material;
656 int vertex_index = 0, edge_index = 0, loop_index = 0, face_index = 0;
657 int visible_faces, visible_segments;
659 Strip::vertex_container::iterator
v[3];
663 for (vector<StrokeRep *>::const_iterator it = group->
strokes.begin(),
670 vector<Strip *> &strips = (*it)->getStrips();
671 for (vector<Strip *>::const_iterator s = strips.begin(), send = strips.end(); s != send; ++s) {
672 Strip::vertex_container &strip_vertices = (*s)->vertices();
673 int strip_vertex_count = strip_vertices.size();
677 if (visible_faces == 0) {
681 v[0] = strip_vertices.begin();
689 for (
int n = 2; n < strip_vertex_count; n++,
v[0]++,
v[1]++,
v[2]++) {
699 vert_positions[vertex_index][0] = svRep[0]->
point2d()[0];
700 vert_positions[vertex_index][1] = svRep[0]->
point2d()[1];
706 vert_positions[vertex_index][0] = svRep[1]->
point2d()[0];
707 vert_positions[vertex_index][1] = svRep[1]->
point2d()[1];
713 edges[edge_index][0] = vertex_index - 2;
714 edges[edge_index][1] = vertex_index - 1;
720 vert_positions[vertex_index][0] = svRep[2]->
point2d()[0];
721 vert_positions[vertex_index][1] = svRep[2]->
point2d()[1];
726 edges[edge_index][0] = vertex_index - 1;
727 edges[edge_index][1] = vertex_index - 3;
730 edges[edge_index][0] = vertex_index - 1;
731 edges[edge_index][1] = vertex_index - 2;
735 face_offsets[face_index] = loop_index;
736 *material_indices = matnr;
744 corner_verts[0] = vertex_index - 1;
745 corner_edges[0] = edge_index - 2;
747 corner_verts[1] = vertex_index - 3;
748 corner_edges[1] = edge_index - 3;
750 corner_verts[2] = vertex_index - 2;
751 corner_edges[2] = edge_index - 1;
754 corner_verts[0] = vertex_index - 1;
755 corner_edges[0] = edge_index - 1;
757 corner_verts[1] = vertex_index - 2;
758 corner_edges[1] = edge_index - 3;
760 corner_verts[2] = vertex_index - 3;
761 corner_edges[2] = edge_index - 2;
771 for (
int L = 0;
L < 2;
L++) {
800 for (
int i = 0;
i < 3;
i++) {
802 rgba[
i][3] = svRep[
i]->
alpha();
815 transp[0].
r = transp[0].
g = transp[0].
b = colors[0].
a;
816 transp[1].
r = transp[1].
g = transp[1].
b = colors[1].
a;
817 transp[2].
r = transp[2].
g = transp[2].
b = colors[2].
a;
828 edge_verts_attr.finish();
829 corner_vert_attr.finish();
830 corner_edge_attr.finish();
831 material_index_attr.finish();
873 cout <<
"clip_start " << camera->
clip_start <<
", clip_end " << camera->
clip_end << endl;
880 RE_RenderFreestyleStrokes(
883 return freestyle_render;
void BKE_id_attributes_active_color_set(struct ID *id, std::optional< blender::StringRef > name)
bool BKE_collection_object_add(Main *bmain, Collection *collection, Object *ob)
CustomData interface, see also DNA_customdata_types.h.
void * CustomData_add_layer_named(CustomData *data, eCustomDataType type, eCDAllocType alloctype, int totelem, blender::StringRef name)
const char * CustomData_get_layer_name(const CustomData *data, eCustomDataType type, int n)
void CustomData_set_layer_active(CustomData *data, eCustomDataType type, int n)
IDProperty * IDP_CopyProperty_ex(const IDProperty *prop, int flag) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
void BKE_main_free(Main *bmain)
General operations, lookup, etc. for materials.
void BKE_object_materials_sync_length(Main *bmain, Object *ob, ID *id)
Material * BKE_material_add(Main *bmain, const char *name)
bool BKE_mesh_validate(Mesh *mesh, bool do_verbose, bool cddata_check_mask)
Mesh * BKE_mesh_add(Main *bmain, const char *name)
void BKE_mesh_face_offsets_ensure_alloc(Mesh *mesh)
#define SH_NODE_MIX_SHADER
#define SH_NODE_MIX_RGB_LEGACY
#define SH_NODE_UVALONGSTROKE
#define SH_NODE_BSDF_TRANSPARENT
#define SH_NODE_OUTPUT_MATERIAL
#define SH_NODE_OUTPUT_LINESTYLE
#define SH_NODE_ATTRIBUTE
#define SH_NODE_LIGHT_PATH
void BKE_ntree_update_after_single_tree_change(Main &bmain, bNodeTree &modified_tree, const NodeTreeUpdateExtraParams ¶ms={})
General operations, lookup, etc. for blender objects.
Object * BKE_object_add(Main *bmain, Scene *scene, ViewLayer *view_layer, int type, const char *name) ATTR_NONNULL(1
Object * BKE_object_add_only_object(Main *bmain, int type, const char *name) ATTR_RETURNS_NONNULL
void BKE_scene_copy_data_eevee(Scene *sce_dst, const Scene *sce_src)
int BKE_render_num_threads(const RenderData *r)
Scene * BKE_scene_add(Main *bmain, const char *name)
void BKE_scene_set_background(Main *bmain, Scene *sce)
GHash * BLI_ghash_ptr_new(const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
void * BLI_ghash_lookup(const GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
void BLI_ghash_insert(GHash *gh, void *key, void *val)
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
#define LISTBASE_FOREACH(type, var, list)
BLI_INLINE void BLI_listbase_clear(ListBase *lb)
void * BLI_findptr(const struct ListBase *listbase, const void *ptr, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE void linearrgb_to_srgb_uchar4(unsigned char srgb[4], const float linear[4])
MINLINE void copy_v3fl_v3db(float r[3], const double a[3])
#define SNPRINTF(dst, format,...)
char * STRNCPY(char(&dst)[N], const char *src)
Class to define a canvas designed to draw style modules.
Depsgraph * DEG_graph_new(Main *bmain, Scene *scene, ViewLayer *view_layer, eEvaluationMode mode)
void DEG_graph_id_tag_update(Main *bmain, Depsgraph *depsgraph, ID *id, unsigned int flags)
void DEG_graph_free(Depsgraph *graph)
void DEG_relations_tag_update(Main *bmain)
void DEG_graph_tag_relations_update(Depsgraph *graph)
void DEG_graph_relations_update(Depsgraph *graph)
Object groups, one object can be in many groups at once.
These structs are the foundation for all linked lists in the library system.
Object is a sort of wrapper for general info.
Read Guarded memory(de)allocation.
ATTR_WARN_UNUSED_RESULT const BMVert * v
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
bool test_triangle_visibility(StrokeVertexRep *svRep[3]) const
vector< StrokeGroup * > texturedStrokeGroups
vector< StrokeGroup * > strokeGroups
Render * RenderScene(Render *re, bool render)
void test_strip_visibility(Strip::vertex_container &strip_vertices, int *visible_faces, int *visible_segments) const
static const char * uvNames[]
void GenerateStrokeMesh(StrokeGroup *group, bool hasTex)
virtual ~BlenderStrokeRenderer()
static Material * GetStrokeShader(Main *bmain, bNodeTree *iNodeTree, bool do_id_user)
virtual void RenderStrokeRep(StrokeRep *iStrokeRep) const
uint get_stroke_mesh_id(void) const
float get_stroke_vertex_z(void) const
BlenderStrokeRenderer(Render *re, int render_count)
Depsgraph * freestyle_depsgraph
int get_stroke_count() const
struct GHash * _nodetree_hash
virtual void RenderStrokeRepBasic(StrokeRep *iStrokeRep) const
void setMaterial(Material *mat)
vector< Strip * > & getStrips()
bNodeTree * getNodeTree() const
Vec2r & texCoord(bool tips=false)
Value lookup_default(const Key &key, const Value &default_value) const
void add_new(const Key &key, const Value &value)
bool contains(const Key &key) const
ItemIterator items() const &
GSpanAttributeWriter lookup_or_add_for_write_span(StringRef attribute_id, AttrDomain domain, AttrType data_type, const AttributeInit &initializer=AttributeInitDefaultValue())
void * MEM_malloc_arrayN(size_t len, size_t size, const char *str)
VecMat::Vec2< real > Vec2r
bNodeTree * node_tree_add_tree_embedded(Main *bmain, ID *owner_id, StringRefNull name, StringRefNull idname)
bNode * node_add_static_node(const bContext *C, bNodeTree &ntree, int type)
bNodeTree * node_tree_copy_tree_ex(const bNodeTree &ntree, Main *bmain, bool do_id_user)
bNodeLink & node_add_link(bNodeTree &ntree, bNode &fromnode, bNodeSocket &fromsock, bNode &tonode, bNodeSocket &tosock)
void node_remove_socket_links(bNodeTree &ntree, bNodeSocket &sock)
void node_set_active(bNodeTree &ntree, bNode &node)
VecBase< float, 2 > float2
VecBase< float, 3 > float3
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
float RNA_float_get(PointerRNA *ptr, const char *name)
void RNA_float_set(PointerRNA *ptr, const char *name, float value)
void RNA_float_set_array(PointerRNA *ptr, const char *name, const float *values)
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
Render * RE_NewSceneRender(const Scene *scene)
vector< StrokeRep * > strokes
blender::Map< Material *, int > materials
struct bNodeTree * nodetree
MutableVArraySpan< T > span