45 # define USE_TRANSFORM_FEEDBACK
53 #ifndef USE_TRANSFORM_FEEDBACK
54 typedef struct ParticleRefineCall {
55 struct ParticleRefineCall *
next;
61 static ParticleRefineCall *g_tf_calls =
NULL;
62 static int g_tf_id_offset;
63 static int g_tf_target_width;
64 static int g_tf_target_height;
85 #ifdef USE_TRANSFORM_FEEDBACK
86 const char *var_names[1] = {
"finalColor"};
93 "#define blender_srgb_to_framebuffer_space(a) a\n"
94 "#define HAIR_PHASE_SUBDIV\n"
95 "#define TF_WORKAROUND\n");
105 #ifdef USE_TRANSFORM_FEEDBACK
118 const float vert[4] = {0.0f, 0.0f, 0.0f, 0.0f};
144 if (final_points_len > 0) {
147 #ifdef USE_TRANSFORM_FEEDBACK
153 ParticleRefineCall *pr_call =
MEM_mallocN(
sizeof(*pr_call), __func__);
154 pr_call->next = g_tf_calls;
156 pr_call->shgrp = tf_shgrp;
157 pr_call->vert_len = final_points_len;
158 g_tf_calls = pr_call;
191 float (*dupli_mat)[4])
197 if ((dupli_parent !=
NULL) && (dupli_object !=
NULL)) {
201 if (collection !=
NULL) {
229 float dupli_mat[4][4];
235 object, psys, md, subdiv, thickness_res);
266 float hair_rad_shape, hair_rad_root, hair_rad_tip;
271 hair_rad_shape = part->
shape;
278 hair_rad_shape = 1.0f;
279 hair_rad_root = 0.005f;
281 hair_close_tip =
true;
302 #ifndef USE_TRANSFORM_FEEDBACK
313 if (g_tf_calls ==
NULL) {
319 for (ParticleRefineCall *pr_call = g_tf_calls; pr_call; pr_call = pr_call->next) {
320 max_size =
max_ii(max_size, pr_call->vert_len);
329 g_tf_target_height =
height;
330 g_tf_target_width =
width;
333 GPU_framebuffer_ensure_config(&
fb,
336 GPU_ATTACHMENT_TEXTURE(
tex),
342 while (g_tf_calls !=
NULL) {
343 ParticleRefineCall *pr_call = g_tf_calls;
344 g_tf_calls = g_tf_calls->next;
347 while (pr_call->vert_len > 0) {
356 sizeof(
float[4]) * g_tf_id_offset,
357 sizeof(
float[4]) * max_read_px_len,
360 g_tf_id_offset += max_read_px_len;
361 pr_call->vert_len -= max_read_px_len;
MINLINE int min_ii(int a, int b)
MINLINE int max_ii(int a, int b)
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
bool invert_m4(float R[4][4])
void unit_m4(float m[4][4])
void copy_m4_m4(float m1[4][4], const float m2[4][4])
MINLINE void sub_v3_v3(float r[3], const float a[3])
#define BLI_string_joinN(...)
Object groups, one object can be in many groups at once.
#define DRW_shgroup_call_no_cull(shgroup, geom, ob)
#define DRW_SHADER_FREE_SAFE(shader)
#define DRW_shader_create(vert, geom, frag, defines)
#define DRW_TEXTURE_FREE_SAFE(tex)
struct GPUFrameBuffer GPUFrameBuffer
void GPU_framebuffer_free(GPUFrameBuffer *fb)
void GPU_framebuffer_bind(GPUFrameBuffer *fb)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
struct GPUShader GPUShader
struct GPUTexture GPUTexture
GPUTexture * GPU_texture_create_from_vertbuf(const char *name, struct GPUVertBuf *vert)
#define GPU_vertbuf_create_with_format(format)
struct GPUVertBuf GPUVertBuf
void GPU_vertbuf_data_alloc(GPUVertBuf *, uint v_len)
void GPU_vertbuf_update_sub(GPUVertBuf *verts, uint start, uint len, void *data)
#define GPU_VERTBUF_DISCARD_SAFE(verts)
void GPU_vertbuf_use(GPUVertBuf *)
void GPU_vertbuf_attr_fill(GPUVertBuf *, uint a_idx, const void *data)
bool hair_ensure_procedural_data(Object *object, ParticleHairCache **r_hair_cache, int subdiv, int thickness_res)
bool particles_ensure_procedural_data(Object *object, ParticleSystem *psys, ModifierData *md, ParticleHairCache **r_hair_cache, int subdiv, int thickness_res)
char datatoc_gpu_shader_3D_smooth_color_frag_glsl[]
DRWShadingGroup * DRW_shgroup_hair_create_sub(Object *object, ParticleSystem *psys, ModifierData *md, DRWShadingGroup *shgrp_parent)
static GPUShader * hair_refine_shader_get(ParticleRefineShader sh)
static GPUTexture * g_dummy_texture
void DRW_hair_update(void)
static GPUVertBuf * g_dummy_vbo
static ParticleHairCache * drw_hair_particle_cache_get(Object *object, ParticleSystem *psys, ModifierData *md, int subdiv, int thickness_res)
char datatoc_common_hair_lib_glsl[]
@ PART_REFINE_CATMULL_ROM
void DRW_hair_duplimat_get(Object *object, ParticleSystem *psys, ModifierData *UNUSED(md), float(*dupli_mat)[4])
static GPUShader * g_refine_shaders[PART_REFINE_MAX_SHADER]
GPUVertBuf * DRW_hair_pos_buffer_get(Object *object, ParticleSystem *psys, ModifierData *md)
char datatoc_common_hair_refine_vert_glsl[]
static DRWPass * g_tf_pass
#define MAX_LAYER_NAME_CT
struct Object * DRW_object_get_dupli_parent(const Object *UNUSED(ob))
struct DupliObject * DRW_object_get_dupli(const Object *UNUSED(ob))
const DRWContextState * DRW_context_state_get(void)
void DRW_shgroup_uniform_float_copy(DRWShadingGroup *shgroup, const char *name, const float value)
void DRW_shgroup_uniform_texture(DRWShadingGroup *shgroup, const char *name, const GPUTexture *tex)
void DRW_shgroup_call_procedural_points(DRWShadingGroup *shgroup, Object *ob, uint point_count)
void DRW_shgroup_uniform_vec4_array_copy(DRWShadingGroup *shgroup, const char *name, const float(*value)[4], int arraysize)
void DRW_shgroup_uniform_int_copy(DRWShadingGroup *shgroup, const char *name, const int value)
DRWShadingGroup * DRW_shgroup_create(struct GPUShader *shader, DRWPass *pass)
void DRW_shgroup_uniform_int(DRWShadingGroup *shgroup, const char *name, const int *value, int arraysize)
DRWShadingGroup * DRW_shgroup_transform_feedback_create(struct GPUShader *shader, DRWPass *pass, GPUVertBuf *tf_target)
DRWShadingGroup * DRW_shgroup_create_sub(DRWShadingGroup *shgroup)
DRWPass * DRW_pass_create(const char *name, DRWState state)
void DRW_shgroup_uniform_bool_copy(DRWShadingGroup *shgroup, const char *name, const bool value)
void DRW_draw_pass(DRWPass *pass)
void DRW_draw_pass_subset(DRWPass *pass, DRWShadingGroup *start_group, DRWShadingGroup *end_group)
GPUShader * DRW_shader_create_with_transform_feedback(const char *vert, const char *geom, const char *defines, const eGPUShaderTFBType prim_type, const char **varying_names, const int varying_count)
GPUTexture * DRW_texture_pool_query_2d(int w, int h, eGPUTextureFormat format, DrawEngineType *engine_type)
void GPU_framebuffer_read_color(GPUFrameBuffer *gpu_fb, int x, int y, int w, int h, int channels, int slot, eGPUDataFormat format, void *data)
BLI_INLINE float fb(float length, float L)
void(* MEM_freeN)(void *vmemh)
void *(* MEM_mallocN)(size_t len, const char *str)
static void update(bNodeTree *ntree)
struct Collection * instance_collection
GPUTexture * uv_tex[MAX_MTFACE]
char uv_layer_names[MAX_MTFACE][MAX_LAYER_NAME_CT][MAX_LAYER_NAME_LEN]
GPUTexture * strand_seg_tex
char col_layer_names[MAX_MCOL][MAX_LAYER_NAME_CT][MAX_LAYER_NAME_LEN]
GPUTexture * col_tex[MAX_MCOL]
ParticleHairFinalCache final[MAX_HAIR_SUBDIV]
GPUBatch * proc_hairs[MAX_THICKRES]