[Bf-blender-cvs] [f129e48993d] blender2.8: Merge branch 'master' into blender2.8

Campbell Barton noreply at git.blender.org
Thu May 11 14:16:03 CEST 2017


Commit: f129e48993df81c55e0b4ec68708588e4e178e7d
Author: Campbell Barton
Date:   Thu May 11 22:15:58 2017 +1000
Branches: blender2.8
https://developer.blender.org/rBf129e48993df81c55e0b4ec68708588e4e178e7d

Merge branch 'master' into blender2.8

===================================================================



===================================================================

diff --cc source/blender/blenkernel/intern/pbvh.c
index 02b4479df4f,dacaad8d703..69028a0c96c
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@@ -1163,10 -1163,10 +1165,10 @@@ static void pbvh_draw_BB(PBVH *bvh
  	for (int a = 0; a < bvh->totnode; a++) {
  		PBVHNode *node = &bvh->nodes[a];
  
- 		GPU_draw_pbvh_BB(node->vb.bmin, node->vb.bmax, ((node->flag & PBVH_Leaf) != 0), pos);
 -		GPU_pbvh_BB_draw(node->vb.bmin, node->vb.bmax, ((node->flag & PBVH_Leaf) != 0));
++		GPU_pbvh_BB_draw(node->vb.bmin, node->vb.bmax, ((node->flag & PBVH_Leaf) != 0), pos);
  	}
  
 -	GPU_pbvh_BB_draw_end();
 +	immUnbindProgram();
  }
  
  static int pbvh_flush_bb(PBVH *bvh, PBVHNode *node, int flag)
@@@ -1739,8 -1739,26 +1741,8 @@@ void BKE_pbvh_node_draw(PBVHNode *node
  {
  	PBVHNodeDrawData *data = data_v;
  
 -#if 0
 -	/* XXX: Just some quick code to show leaf nodes in different colors */
 -	float col[3];
 -	float spec[3] = {0.0f, 0.0f, 0.0f};
 -
 -	if (0) { //is_partial) {
 -		col[0] = (rand() / (float)RAND_MAX); col[1] = col[2] = 0.6;
 -	}
 -	else {
 -		srand((long long)node);
 -		for (int i = 0; i < 3; ++i)
 -			col[i] = (rand() / (float)RAND_MAX) * 0.3 + 0.7;
 -	}
 -
 -	GPU_basic_shader_colors(col, spec, 0, 1.0f);
 -	glColor3f(1, 0, 0);
 -#endif
 -
  	if (!(node->flag & PBVH_FullyHidden)) {
- 		GPU_draw_pbvh_buffers(node->draw_buffers,
+ 		GPU_pbvh_buffers_draw(node->draw_buffers,
  		                 data->setMaterial,
  		                 data->wireframe,
  		                 data->fast);
@@@ -1845,67 -1863,6 +1847,67 @@@ void BKE_pbvh_draw(PBVH *bvh, float (*p
  		pbvh_draw_BB(bvh);
  }
  
 +struct PBVHNodeDrawCallbackData {
 +
 +	void (*draw_fn)(void *user_data, Batch *batch);
 +	void *user_data;
 +	bool fast;
 +};
 +
 +static void pbvh_node_draw_cb(PBVHNode *node, void *data_v)
 +{
 +	struct PBVHNodeDrawCallbackData *data = data_v;
 +
 +	if (!(node->flag & PBVH_FullyHidden)) {
- 		Batch *triangles = GPU_draw_pbvh_buffers_get_batch(node->draw_buffers, data->fast);
++		Batch *triangles = GPU_pbvh_buffers_batch_get(node->draw_buffers, data->fast);
 +		if (triangles != NULL) {
 +			data->draw_fn(data->user_data, triangles);
 +		}
 +	}
 +}
 +
 +/**
 + * Version of #BKE_pbvh_draw that runs a callback.
 + */
 +void BKE_pbvh_draw_cb(
 +        PBVH *bvh, float (*planes)[4], float (*fnors)[3], bool fast,
 +        void (*draw_fn)(void *user_data, Batch *batch), void *user_data)
 +{
 +	struct PBVHNodeDrawCallbackData draw_data = {
 +		.fast = fast,
 +		.draw_fn = draw_fn,
 +		.user_data = user_data,
 +	};
 +	PBVHNode **nodes;
 +	int totnode;
 +
 +	for (int a = 0; a < bvh->totnode; a++)
 +		pbvh_node_check_diffuse_changed(bvh, &bvh->nodes[a]);
 +
 +	BKE_pbvh_search_gather(bvh, update_search_cb, SET_INT_IN_POINTER(PBVH_UpdateNormals | PBVH_UpdateDrawBuffers),
 +	                       &nodes, &totnode);
 +
 +	pbvh_update_normals(bvh, nodes, totnode, fnors);
 +	pbvh_update_draw_buffers(bvh, nodes, totnode);
 +
 +	if (nodes) MEM_freeN(nodes);
 +
 +	if (planes) {
 +		BKE_pbvh_search_callback(
 +		        bvh, BKE_pbvh_node_planes_contain_AABB,
 +		        planes, pbvh_node_draw_cb, &draw_data);
 +	}
 +	else {
 +		BKE_pbvh_search_callback(
 +		        bvh, NULL,
 +		        NULL, pbvh_node_draw_cb, &draw_data);
 +	}
 +#if 0
 +	if (G.debug_value == 14)
 +		pbvh_draw_BB(bvh);
 +#endif
 +}
 +
  void BKE_pbvh_grids_update(PBVH *bvh, CCGElem **grids, void **gridfaces,
                             DMFlagMat *flagmats, BLI_bitmap **grid_hidden)
  {
diff --cc source/blender/draw/engines/eevee/shaders/effect_motion_blur_frag.glsl
index 1505e02bfb7,00000000000..8960b339a61
mode 100644,000000..100644
--- a/source/blender/draw/engines/eevee/shaders/effect_motion_blur_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_motion_blur_frag.glsl
@@@ -1,65 -1,0 +1,63 @@@
 +
 +uniform sampler2D colorBuffer;
 +uniform sampler2D depthBuffer;
 +
 +
 +/* current frame */
 +uniform mat4 currInvViewProjMatrix;
 +
 +/* past frame frame */
 +uniform mat4 pastViewProjMatrix;
 +
 +in vec4 uvcoordsvar;
 +
 +out vec4 FragColor;
 +
 +#define MAX_SAMPLE 64
 +
 +uniform int samples;
 +
 +float wang_hash_noise(uint s)
 +{
 +	uint seed = (uint(gl_FragCoord.x) * 1664525u + uint(gl_FragCoord.y)) + s;
 +
 +	seed = (seed ^ 61u) ^ (seed >> 16u);
 +	seed *= 9u;
 +	seed = seed ^ (seed >> 4u);
 +	seed *= 0x27d4eb2du;
 +	seed = seed ^ (seed >> 15u);
 +
 +	float value = float(seed);
 +	value *= 1.0 / 4294967296.0;
 +	return fract(value);
 +}
 +
 +void main()
 +{
 +	vec3 ndc_pos;
 +	ndc_pos.xy = uvcoordsvar.xy;
 +	ndc_pos.z = texture(depthBuffer, uvcoordsvar.xy).x;
 +
 +	float inv_samples = 1.0 / float(samples);
 +	float noise = 2.0 * wang_hash_noise(0u) * inv_samples;
 +
 +	/* Normalize Device Coordinates are [-1, +1]. */
 +	ndc_pos = ndc_pos * 2.0 - 1.0;
 +
 +	vec4 p = currInvViewProjMatrix * vec4(ndc_pos, 1.0);
 +	vec3 world_pos = p.xyz / p.w; /* Perspective divide */
 +
 +	/* Now find where was this pixel position
 +	 * inside the past camera viewport */
 +	vec4 old_ndc = pastViewProjMatrix * vec4(world_pos, 1.0);
 +	old_ndc.xyz /= old_ndc.w; /* Perspective divide */
 +
 +	vec2 motion = (ndc_pos.xy - old_ndc.xy) * 0.25; /* 0.25 fit cycles ref */
 +
 +	float inc = 2.0 * inv_samples;
 +	float i = -1.0 + noise;
- 
- 	FragColor = vec4(0.0);
 +	for (int j = 0; j < samples && j < MAX_SAMPLE; j++) {
 +		FragColor += texture(colorBuffer, uvcoordsvar.xy + motion * i) * inv_samples;
 +		i += inc;
 +	}
 +}
diff --cc source/blender/gpu/GPU_buffers.h
index 661562e2e4c,e4a837d0a5f..b4d271ed3b9
--- a/source/blender/gpu/GPU_buffers.h
+++ b/source/blender/gpu/GPU_buffers.h
@@@ -243,25 -242,29 +243,28 @@@ void GPU_pbvh_mesh_buffers_update
          const int *vert_indices, int totvert, const float *vmask,
          const int (*face_vert_indices)[3], bool show_diffuse_color);
  
- void GPU_update_bmesh_pbvh_buffers(GPU_PBVH_Buffers *buffers,
-                               struct BMesh *bm,
-                               struct GSet *bm_faces,
-                               struct GSet *bm_unique_verts,
-                               struct GSet *bm_other_verts,
-                               bool show_diffuse_color);
+ void GPU_pbvh_bmesh_buffers_update(
+         GPU_PBVH_Buffers *buffers,
+         struct BMesh *bm,
+         struct GSet *bm_faces,
+         struct GSet *bm_unique_verts,
+         struct GSet *bm_other_verts,
+         bool show_diffuse_color);
  
- void GPU_update_grid_pbvh_buffers(GPU_PBVH_Buffers *buffers, struct CCGElem **grids,
-                              const struct DMFlagMat *grid_flag_mats,
-                              int *grid_indices, int totgrid, const struct CCGKey *key,
-                              bool show_diffuse_color);
+ void GPU_pbvh_grid_buffers_update(
+         GPU_PBVH_Buffers *buffers, struct CCGElem **grids,
+         const struct DMFlagMat *grid_flag_mats,
+         int *grid_indices, int totgrid, const struct CCGKey *key,
+         bool show_diffuse_color);
  
  /* draw */
- void GPU_draw_pbvh_buffers(GPU_PBVH_Buffers *buffers, DMSetMaterial setMaterial,
-                            bool wireframe, bool fast);
- struct Batch *GPU_draw_pbvh_buffers_get_batch(GPU_PBVH_Buffers *buffers, bool fast);
+ void GPU_pbvh_buffers_draw(
+         GPU_PBVH_Buffers *buffers, DMSetMaterial setMaterial,
+         bool wireframe, bool fast);
++struct Batch *GPU_pbvh_buffers_batch_get(GPU_PBVH_Buffers *buffers, bool fast);
  
 -/* debug PBVH draw*/
 -void GPU_pbvh_BB_draw(float min[3], float max[3], bool leaf);
 -void GPU_pbvh_BB_draw_init(void);
 -void GPU_pbvh_BB_draw_end(void);
 +/* debug PBVH draw */
- void GPU_draw_pbvh_BB(float min[3], float max[3], bool leaf, unsigned int pos);
++void GPU_pbvh_BB_draw(float min[3], float max[3], bool leaf, unsigned int pos);
  
  bool GPU_pbvh_buffers_diffuse_changed(GPU_PBVH_Buffers *buffers, struct GSet *bm_faces, bool show_diffuse_color);
  
diff --cc source/blender/gpu/intern/gpu_buffers.c
index 8a3c0c91b65,9f1fe3a5a67..81466d156ee
--- a/source/blender/gpu/intern/gpu_buffers.c
+++ b/source/blender/gpu/intern/gpu_buffers.c
@@@ -1473,23 -1435,32 +1473,23 @@@ static ElementList *gpu_get_grid_buffer
  	return gridbuff->mres_buffer;
  }
  
 -#define FILL_FAST_BUFFER(type_) \
 +#define FILL_FAST_BUFFER() \
  { \
 -	type_ *buffer; \
 -	buffers->index_buf_fast = GPU_buffer_alloc(sizeof(type_) * 6 * totgrid); \
 -	buffer = GPU_buffer_lock(buffers->index_buf_fast, GPU_BINDING_INDEX); \
 -	if (buffer) { \
 -		int i; \
 -		for (i = 0; i < totgrid; i++) { \
 -			int currentquad = i * 6; \
 -			buffer[currentquad]     = i * gridsize * gridsize + gridsize - 1; \
 -			buffer[currentquad + 1] = i * gridsize * gridsize; \
 -			buffer[currentquad + 2] = (i + 1) * gridsize * gridsize - gridsize; \
 -			buffer[currentquad + 3] = (i + 1) * gridsize * gridsize - 1; \
 -			buffer[currentquad + 4] = i * gridsize * gridsize + gridsize - 1; \
 -			buffer[currentquad + 5] = (i + 1) * gridsize * gridsize - gridsize; \
 -		} \
 -		GPU_buffer_unlock(buffers->index_buf_fast, GPU_BINDING_INDEX); \
 -	} \
 -	else { \
 -		GPU_buffer_free(buffers->index_buf_fast); \
 -		buffers->index_buf_fast = NULL; \
 +	ElementListBuilder elb; \
 +	ElementListBuilder_init(&elb, PRIM_TRIANGLES, 6 * totgrid, INT_MAX); \
 +	for (int i = 0; i < totgrid; i++) { \
 +		add_generic_vertex(&elb, i * gridsize * gridsize + gridsize - 1); \
 +		add_generic_vertex(&elb, i * gridsize * gridsize); \
 +		add_generic_vertex(&elb, (i + 1) * gridsize * gridsize - gridsize); \
 +		add_generic_vertex(&elb, (i + 1) * gridsize * gridsize - 1); \
 +		add_generic_vertex(&elb, i * gridsize * gridsize + gridsize - 1); \
 +		add_generic_vertex(&elb, (i + 1) * gridsize * gridsize - gridsize); \
  	} \
 +	buffers->index_buf_fast = ElementList_build(&elb); \
  } (void)0
  
- GPU_PBVH_Buffers *GPU_build_grid_pbvh_buffers(
+ GPU_PBVH_Buffers *GPU_pbvh_grid_buffers_build(
 -        int *grid_indices, int totgrid, BLI_bitmap **grid_hidden, int gridsize, const CCGKey *key,
 +        int *grid_indices, int totgrid, BLI_bitmap **grid_hidden, int gridsize, const CCGKey *UNUSED(key),
          GridCommonGPUBuffer **grid_common_gpu_buffer)
  {
  	GPU_PBVH_Buffers *buffers;
@@@

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list