61 const float vert[4] = {0.0f, 0.0f, 0.0f, 0.0f};
67 g_dummy_curves_info = MEM_new<blender::draw::UniformBuffer<CurvesInfos>>(
"g_dummy_curves_info");
94 if (final_points_len > 0) {
101 int strands_start = 0;
102 while (strands_start < strands_len) {
103 int batch_strands_len = std::min(strands_len - strands_start, max_strands_per_call);
107 strands_start += batch_strands_len;
121 bool update = particles_ensure_procedural_data(
122 object, psys, md, &cache, gpu_material, subdiv, thickness_res);
141 object, psys, md,
nullptr, subdiv, thickness_res);
149 float (*dupli_mat)[4])
154 if ((dupli_parent !=
nullptr) && (dupli_object !=
nullptr)) {
158 if (collection !=
nullptr) {
159 sub_v3_v3(dupli_mat[3], collection->instance_offset);
161 mul_m4_m4m4(dupli_mat, dupli_parent->object_to_world().ptr(), dupli_mat);
164 copy_m4_m4(dupli_mat, dupli_object->
ob->object_to_world().ptr());
166 mul_m4_m4m4(dupli_mat, object->object_to_world().ptr(), dupli_mat);
182 float dupli_mat[4][4];
188 object, psys, md, gpu_material, subdiv, thickness_res);
221 float hair_rad_shape = part->
shape;
222 float hair_rad_root = part->rad_root * part->rad_scale * 0.5f;
223 float hair_rad_tip = part->rad_tip * part->rad_scale * 0.5f;
246 blender::gpu::Batch *geom = hair_cache->
final[subdiv].
proc_hairs[thickness_res - 1];
275 g_pass = MEM_new<PassSimple>(
"drw_hair g_pass",
"Update Hair Pass");
291 object, psys, md, &cache, gpu_material, subdiv, thickness_res);
298 const int final_points_len = cache->
final[subdiv].
strands_res * strands_len;
299 if (final_points_len > 0) {
311 int strands_start = 0;
312 while (strands_start < strands_len) {
313 int batch_strands_len = std::min(strands_len - strands_start, max_strands_per_call);
317 strands_start += batch_strands_len;
329 int subdiv = scene->r.hair_subdiv;
333 object, psys, md,
nullptr, subdiv, thickness_res);
350template<
typename PassT>
360 int subdiv = scene->r.hair_subdiv;
363 object, psys, md, gpu_material, subdiv, thickness_res);
394 float hair_rad_shape = part->
shape;
395 float hair_rad_root = part->rad_root * part->rad_scale * 0.5f;
396 float hair_rad_tip = part->rad_tip * part->rad_scale * 0.5f;
399 sub_ps.bind_texture(
"hairPointBuffer", hair_cache->
final[subdiv].
proc_buf);
405 sub_ps.push_constant(
"hairStrandsRes", &hair_cache->
final[subdiv].
strands_res, 1);
406 sub_ps.push_constant(
"hairThicknessRes", thickness_res);
407 sub_ps.push_constant(
"hairRadShape", hair_rad_shape);
408 sub_ps.push_constant(
"hairDupliMatrix", dupli_mat);
409 sub_ps.push_constant(
"hairRadRoot", hair_rad_root);
410 sub_ps.push_constant(
"hairRadTip", hair_rad_tip);
411 sub_ps.push_constant(
"hairCloseTip", hair_close_tip);
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
void unit_m4(float m[4][4])
void copy_m4_m4(float m1[4][4], const float m2[4][4])
bool invert_m4(float mat[4][4])
MINLINE void sub_v3_v3(float r[3], const float a[3])
Object groups, one object can be in many groups at once.
#define DRW_shgroup_vertex_buffer(shgroup, name, vert)
#define DRW_shgroup_call_no_cull(shgroup, geom, ob)
#define DRW_shgroup_uniform_block(shgroup, name, ubo)
int GPU_max_work_group_count(int index)
void GPU_memory_barrier(eGPUBarrier barrier)
@ GPU_BARRIER_SHADER_STORAGE
void GPU_vertbuf_use(blender::gpu::VertBuf *)
void GPU_vertbuf_attr_fill(blender::gpu::VertBuf *, uint a_idx, const void *data)
blender::gpu::VertBuf * GPU_vertbuf_create_with_format_ex(const GPUVertFormat &format, GPUUsageType usage)
#define GPU_VERTBUF_DISCARD_SAFE(verts)
void GPU_vertbuf_data_alloc(blender::gpu::VertBuf &verts, uint v_len)
@ GPU_USAGE_FLAG_BUFFER_TEXTURE_ONLY
struct GPUShader GPUShader
void submit(PassSimple &pass, View &view)
void bind_texture(const char *name, GPUTexture *texture, GPUSamplerState state=sampler_auto)
PassBase< DrawCommandBufType > & sub(const char *name)
void dispatch(int group_len)
void state_set(DRWState state, int clip_plane_count=0)
void push_constant(const char *name, const float &data)
void bind_ssbo(const char *name, GPUStorageBuf *buffer)
void shader_set(GPUShader *shader)
void DRW_hair_duplimat_get(Object *object, ParticleSystem *psys, ModifierData *md, float(*dupli_mat)[4])
blender::gpu::VertBuf * DRW_hair_pos_buffer_get(Object *object, ParticleSystem *psys, ModifierData *md)
static void drw_hair_ensure_vbo()
static blender::draw::UniformBuffer< CurvesInfos > * g_dummy_curves_info
DRWShadingGroup * DRW_shgroup_hair_create_sub(Object *object, ParticleSystem *psys, ModifierData *md, DRWShadingGroup *shgrp_parent, GPUMaterial *gpu_material)
static void drw_hair_particle_cache_update_compute(ParticleHairCache *cache, const int subdiv)
static blender::gpu::VertBuf * g_dummy_vbo
static ParticleHairCache * drw_hair_particle_cache_get(Object *object, ParticleSystem *psys, ModifierData *md, GPUMaterial *gpu_material, int subdiv, int thickness_res)
static void drw_hair_particle_cache_shgrp_attach_resources(DRWShadingGroup *shgrp, ParticleHairCache *cache, const int subdiv)
void DRW_hair_duplimat_get(Object *object, ParticleSystem *, ModifierData *, float(*dupli_mat)[4])
static DRWPass * g_tf_pass
@ PART_REFINE_CATMULL_ROM
#define MAX_LAYER_NAME_CT
Object * DRW_object_get_dupli_parent(const Object *)
const DRWContextState * DRW_context_state_get()
DupliObject * DRW_object_get_dupli(const Object *)
DRWShadingGroup * DRW_shgroup_create(GPUShader *shader, DRWPass *pass)
void DRW_shgroup_uniform_float_copy(DRWShadingGroup *shgroup, const char *name, const float value)
void DRW_shgroup_buffer_texture(DRWShadingGroup *shgroup, const char *name, blender::gpu::VertBuf *vertex_buffer)
void DRW_shgroup_uniform_texture(DRWShadingGroup *shgroup, const char *name, const GPUTexture *tex)
DRWPass * DRW_pass_create(const char *name, DRWState state)
DRWShadingGroup * DRW_shgroup_create_sub(DRWShadingGroup *shgroup)
void DRW_shgroup_call_compute(DRWShadingGroup *shgroup, int groups_x_len, int groups_y_len, int groups_z_len)
void DRW_shgroup_uniform_int_copy(DRWShadingGroup *shgroup, const char *name, const int value)
void DRW_shgroup_uniform_int(DRWShadingGroup *shgroup, const char *name, const int *value, int arraysize)
void DRW_shgroup_add_material_resources(DRWShadingGroup *grp, GPUMaterial *material)
void DRW_shgroup_uniform_bool_copy(DRWShadingGroup *shgroup, const char *name, const bool value)
void DRW_shgroup_uniform_mat4_copy(DRWShadingGroup *shgroup, const char *name, const float(*value)[4])
void DRW_draw_pass(DRWPass *pass)
GPUShader * DRW_shader_hair_refine_get(ParticleRefineShader refinement)
static PassSimple * g_pass
gpu::Batch * hair_sub_pass_setup(PassMain::Sub &sub_ps, const Scene *scene, Object *object, ParticleSystem *psys, ModifierData *md, GPUMaterial *gpu_material=nullptr)
blender::gpu::Batch * hair_sub_pass_setup_implementation(PassT &sub_ps, const Scene *scene, Object *object, ParticleSystem *psys, ModifierData *md, GPUMaterial *gpu_material)
void hair_update(Manager &manager)
static gpu::VertBuf * g_dummy_vbo
bool particles_ensure_procedural_data(Object *object, ParticleSystem *psys, ModifierData *md, ParticleHairCache **r_hair_cache, GPUMaterial *gpu_material, int subdiv, int thickness_res)
gpu::VertBuf * hair_pos_buffer_get(Scene *scene, Object *object, ParticleSystem *psys, ModifierData *md)
static ParticleHairCache * hair_particle_cache_get(Object *object, ParticleSystem *psys, ModifierData *md, GPUMaterial *gpu_material, int subdiv, int thickness_res)
VecBase< int32_t, 3 > int3
static void update(bNodeTree *ntree)
struct Collection * instance_collection
GPUTexture * uv_tex[MAX_MTFACE]
blender::gpu::VertBuf * proc_length_buf
blender::gpu::VertBuf * proc_strand_buf
blender::gpu::VertBuf * proc_strand_seg_buf
char uv_layer_names[MAX_MTFACE][MAX_LAYER_NAME_CT][MAX_LAYER_NAME_LEN]
blender::gpu::VertBuf * proc_point_buf
ParticleHairFinalCache final[MAX_HAIR_SUBDIV]
char(* col_layer_names)[MAX_LAYER_NAME_CT][MAX_LAYER_NAME_LEN]
blender::gpu::VertBuf * proc_buf
blender::gpu::Batch * proc_hairs[MAX_THICKRES]
ParticleRefineCall * next
blender::gpu::VertBuf * vbo
const c_style_mat & ptr() const