[Bf-blender-cvs] [6a21045] strand_gpu: Use the correct buffer for the control points texture.

Lukas Tönne noreply at git.blender.org
Tue Jul 5 09:57:14 CEST 2016


Commit: 6a210450fdeeb46acf3320df595e94653e50fc4d
Author: Lukas Tönne
Date:   Sat Jul 2 14:32:19 2016 +0200
Branches: strand_gpu
https://developer.blender.org/rB6a210450fdeeb46acf3320df595e94653e50fc4d

Use the correct buffer for the control points texture.

Also a bit of cleanup renaming to use "control" consistently instead
of "guide".

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

M	source/blender/gpu/GPU_buffers.h
M	source/blender/gpu/intern/gpu_buffers.c
M	source/blender/gpu/intern/gpu_strands.c

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

diff --git a/source/blender/gpu/GPU_buffers.h b/source/blender/gpu/GPU_buffers.h
index 71829b7..f18aad3 100644
--- a/source/blender/gpu/GPU_buffers.h
+++ b/source/blender/gpu/GPU_buffers.h
@@ -153,8 +153,8 @@ typedef struct GPUDrawStrands {
 	GPUBuffer *control_edges;
 	GPUBuffer *root_points;
 
-	/* GL texture id for root point texture buffer */
-	GPUBufferTexture root_tex;
+	/* GL texture id for control point texture buffer */
+	GPUBufferTexture control_points_tex;
 
 	unsigned int totverts;
 	unsigned int totcurves;
diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c
index 3728119..0782b52 100644
--- a/source/blender/gpu/intern/gpu_buffers.c
+++ b/source/blender/gpu/intern/gpu_buffers.c
@@ -2097,8 +2097,8 @@ void GPU_end_draw_pbvh_BB(void)
 
 typedef struct RootVertex {
 	float co[3];
-	unsigned int guide_index[4];
-	float guide_weight[4];
+	unsigned int control_index[4];
+	float control_weight[4];
 } RootVertex;
 
 typedef enum GPUStrandBufferType {
@@ -2135,9 +2135,9 @@ static GPUBufferTexture *gpu_strands_buffer_texture_from_type(GPUDrawStrands *gd
                                                               GLenum *format)
 {
 	switch (type) {
-		case GPU_STRAND_BUFFER_ROOT_VERTEX:
+		case GPU_STRAND_BUFFER_CONTROL_VERTEX:
 			*format = GL_RGB32F;
-			return &gds->root_tex;
+			return &gds->control_points_tex;
 		default:
 			*format = 0;
 			return NULL;
@@ -2213,8 +2213,8 @@ static void strands_copy_root_buffer(StrandData *strands, RootVertex *varray)
 	for (v = 0; v < totroots; ++v, ++root) {
 		copy_v3_v3(varray->co, root->co);
 		for (int k = 0; k < 4; ++k) {
-			varray->guide_index[k] = root->control_index[k];
-			varray->guide_weight[k] = root->control_weight[k];
+			varray->control_index[k] = root->control_index[k];
+			varray->control_weight[k] = root->control_weight[k];
 		}
 		++varray;
 	}
@@ -2366,8 +2366,8 @@ void GPU_strands_setup_roots(StrandData *strands)
 	GLStates |= (GPU_BUFFER_VERTEX_STATE);
 
 	glActiveTexture(GL_TEXTURE0);
-	if (strands->gpu_buffer->root_tex.id != 0) {
-		glBindTexture(GL_TEXTURE_BUFFER, strands->gpu_buffer->root_tex.id);
+	if (strands->gpu_buffer->control_points_tex.id != 0) {
+		glBindTexture(GL_TEXTURE_BUFFER, strands->gpu_buffer->control_points_tex.id);
 	}
 }
 
diff --git a/source/blender/gpu/intern/gpu_strands.c b/source/blender/gpu/intern/gpu_strands.c
index 1a7434d..2764d96 100644
--- a/source/blender/gpu/intern/gpu_strands.c
+++ b/source/blender/gpu/intern/gpu_strands.c
@@ -68,12 +68,12 @@ struct GPUStrandsShader {
 };
 
 const char *vertex_shader = STRINGIFY(
-	in uvec3 guide_index;
-	in vec3 guide_weight;
+	in uvec3 control_index;
+	in vec3 control_weight;
 	
 	void main()
 	{
-		vec4 co = gl_ModelViewMatrix * (gl_Vertex + vec4(guide_weight.xyz, 0.0));
+		vec4 co = gl_ModelViewMatrix * (gl_Vertex + vec4(control_weight.xyz, 0.0));
 		gl_Position = gl_ProjectionMatrix * co;
 	}
 );
@@ -91,6 +91,8 @@ const char *geometry_shader = STRINGIFY(
 	layout(points) in;
 	layout(line_strip, max_vertices = 2) out;
 	
+	uniform samplerBuffer guides;
+	
 	void main()
 	{
 		gl_Position = gl_in[0].gl_Position + vec4(-0.1, 0.0, 0.0, 0.0);
@@ -192,13 +194,13 @@ GPUStrandsShader *GPU_strand_shader_get(struct Strands *strands)
 		attr->size = 3;
 		
 		attr = &gpu_shader->attributes[GPU_STRAND_ATTRIB_GUIDE_INDEX];
-		attr->index = GPU_shader_get_attribute(gpu_shader->shader, "guide_index");
+		attr->index = GPU_shader_get_attribute(gpu_shader->shader, "control_index");
 		attr->info_index = -1;
 		attr->type = GL_UNSIGNED_INT;
 		attr->size = 4;
 		
 		attr = &gpu_shader->attributes[GPU_STRAND_ATTRIB_GUIDE_WEIGHT];
-		attr->index = GPU_shader_get_attribute(gpu_shader->shader, "guide_weight");
+		attr->index = GPU_shader_get_attribute(gpu_shader->shader, "control_weight");
 		attr->info_index = -1;
 		attr->type = GL_FLOAT;
 		attr->size = 4;




More information about the Bf-blender-cvs mailing list